xserver: Branch 'xorg-server-1.6-apple' - 33 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Dec 17 13:57:07 PST 2008


 Xext/sync.c                          |   51 ++++++++++++---
 Xi/exevents.c                        |   10 ++-
 acinclude.m4                         |    2 
 glx/dispatch.h                       |    2 
 glx/glapi.h                          |   17 ++++-
 glx/glapitable.h                     |    1 
 glx/glthread.c                       |    1 
 glx/indirect_dispatch.c              |   11 +--
 glx/indirect_dispatch_swap.c         |   11 +--
 glx/indirect_reqsize.c               |    3 
 hw/xfree86/common/xf86Xinput.c       |    4 -
 hw/xfree86/modes/xf86Crtc.c          |   10 ---
 hw/xfree86/modes/xf86Crtc.h          |    7 ++
 hw/xfree86/modes/xf86Rotate.c        |   14 ++--
 hw/xfree86/os-support/bsd/bsd_init.c |   88 ++++++++++++++++-----------
 hw/xfree86/os-support/shared/sigio.c |    2 
 hw/xfree86/ramdac/xf86Cursor.c       |    3 
 hw/xquartz/bundle/Info.plist.cpp     |    2 
 hw/xquartz/bundle/X11.sh             |    2 
 hw/xquartz/bundle/mk_bundke.sh       |    2 
 hw/xquartz/mach-startup/Makefile.am  |   16 ++---
 randr/randr.c                        |    3 
 randr/randrstr.h                     |    8 ++
 randr/rrdispatch.c                   |    2 
 randr/rroutput.c                     |  112 ++++++++++++++++++++++++++++++++++-
 randr/rrscreen.c                     |   17 ++++-
 randr/rrsdispatch.c                  |   27 ++++++++
 randr/rrxinerama.c                   |   48 +++++++++------
 xkb/xkbInit.c                        |   29 +++++++--
 29 files changed, 382 insertions(+), 123 deletions(-)

New commits:
commit 102abeda37d6b62971a9952efa0453e38504ae0b
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 17 13:54:53 2008 -0800

    XQuartz: Name the startup shell script X11 for better compatability
    (cherry picked from commit f84613d6fcbbb5f769ee34cff0900353a13693cf)

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 9713289..16434f2 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -5,7 +5,7 @@
 	<key>CFBundleDevelopmentRegion</key>
 		<string>English</string>
 	<key>CFBundleExecutable</key>
-		<string>X11.sh</string>
+		<string>X11</string>
 	<key>CFBundleGetInfoString</key>
 		<string>APPLE_APPLICATION_NAME</string>
 	<key>CFBundleIconFile</key>
diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 2f953d1..87c52b3 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,3 +1,3 @@
 #!/bin/bash --login
 
-"$(dirname $0)"/X11 "${@}"
+"$(dirname $0)"/X11.bin "${@}"
diff --git a/hw/xquartz/bundle/mk_bundke.sh b/hw/xquartz/bundle/mk_bundke.sh
index 5c5733a..7c8d148 100755
--- a/hw/xquartz/bundle/mk_bundke.sh
+++ b/hw/xquartz/bundle/mk_bundke.sh
@@ -21,7 +21,7 @@ install -m 644 Info.plist ${BUNDLE_ROOT}/Contents
 install -m 644 PkgInfo ${BUNDLE_ROOT}/Contents
 
 mkdir -p ${BUNDLE_ROOT}/Contents/MacOS
-install -m 755 X11.sh ${BUNDLE_ROOT}/Contents/MacOS
+install -m 755 X11.sh ${BUNDLE_ROOT}/Contents/MacOS/X11
 
 if [[ $(id -u) == 0 ]] ; then
 	chown -R root:admin ${BUNDLE_ROOT}
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index b4e7852..40060d0 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -4,16 +4,16 @@ AM_CPPFLAGS = \
 	-DX11BINDIR=\"$(bindir)\"
 
 x11appdir = $(APPLE_APPLICATIONS_DIR)/X11.app/Contents/MacOS
-x11app_PROGRAMS = X11
+x11app_PROGRAMS = X11.bin
 
-dist_X11_SOURCES = \
+dist_X11_bin_SOURCES = \
 	bundle-main.c 
 
-nodist_X11_SOURCES = \
+nodist_X11_bin_SOURCES = \
 	mach_startupServer.c \
 	mach_startupUser.c
 
-X11_LDADD = \
+X11_bin_LDADD = \
 	$(top_builddir)/hw/xquartz/libXquartz.la \
 	$(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \
 	$(top_builddir)/dix/dixfonts.lo \
@@ -21,7 +21,7 @@ X11_LDADD = \
 	$(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
 	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
-X11_LDFLAGS =  \
+X11_bin_LDFLAGS =  \
 	-XCClinker -Objc \
 	-Wl,-u,_miDCInitialize \
 	-Wl,-framework,Carbon \
@@ -30,17 +30,17 @@ X11_LDFLAGS =  \
 	-Wl,-framework,IOKit
 
 if GLX
-X11_LDADD += \
+X11_bin_LDADD += \
 	$(top_builddir)/hw/xquartz/GL/libCGLCore.la \
 	$(top_builddir)/glx/libglx.la
 
-X11_LDFLAGS += \
+X11_bin_LDFLAGS += \
 	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
 	-Wl,-framework,OpenGL
 endif
 
 if RECORD
-X11_LDADD += \
+X11_bin_LDADD += \
 	$(top_builddir)/record/librecord.la
 endif
 
commit 530dfa569dc14ddfc70326bc4dddf5becabd74ef
Merge: 7398701... 32e8107...
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 17 13:56:36 2008 -0800

    Merge commit 'origin/server-1.6-branch' into xorg-server-1.6-apple

commit 32e81074b967716865aef08b66ec29caf0fec2c5
Author: Robert Noland <rnoland at 2hip.net>
Date:   Tue Dec 16 00:07:42 2008 -0500

    Support -sharevts on FreeBSD
    
    Bugzilla #11179
    
    Submitted-by: Nathan Whitehorn
    
    Signed-off-by: Robert Noland <rnoland at 2hip.net>
    (cherry picked from commit 7aa29b9d66c3cd0f8af4fafbe92efd0c0556d225)

diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index cbb9e48..7698084 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -45,6 +45,7 @@ static int devConsoleFd = -1;
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
 static int VTnum = -1;
 static int initialVT = -1;
+static Bool ShareVTs = FALSE;
 #endif
 
 #ifdef PCCONS_SUPPORT
@@ -269,44 +270,48 @@ xf86OpenConsole()
 	    }
 #endif
 acquire_vt:
-	    /*
-	     * now get the VT
-	     */
-	    SYSCALL(result =
-		    ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
-	    if (result != 0)
-	    {
-    	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-	    }
-	    SYSCALL(result =
+	    if (!ShareVTs) {
+		    /*
+		     * now get the VT
+		     */
+		    SYSCALL(result =
+			    ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+		    if (result != 0)
+		    {
+			xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+		    }
+		    SYSCALL(result =
 		    ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
-	    if (result != 0)
-	    {
-	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
-	    }
+		    if (result != 0)
+		    {
+			xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+		    }
 
-	    signal(SIGUSR1, xf86VTRequest);
+		    signal(SIGUSR1, xf86VTRequest);
 
-	    vtmode.mode = VT_PROCESS;
-	    vtmode.relsig = SIGUSR1;
-	    vtmode.acqsig = SIGUSR1;
-	    vtmode.frsig = SIGUSR1;
-	    if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) 
-	    {
-	        FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
-	    }
-#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
-	    if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
-	    {
-	        FatalError("xf86OpenConsole: KDENABIO failed (%s)",
-		           strerror(errno));
-	    }
-#endif
-	    if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
-	    {
-	        FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
-	    }
-   	    break; 
+		    vtmode.mode = VT_PROCESS;
+		    vtmode.relsig = SIGUSR1;
+		    vtmode.acqsig = SIGUSR1;
+		    vtmode.frsig = SIGUSR1;
+		    if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) 
+		    {
+			FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+		    }
+	#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+		    if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+		    {
+			FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+				   strerror(errno));
+		    }
+	#endif
+		    if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+		    {
+			FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+		    }
+	    } else { /* ShareVTs */
+		    close(xf86Info.consoleFd);
+	    }	
+  	    break; 
 #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
 #ifdef WSCONS_SUPPORT
 	case WSCONS:
@@ -319,7 +324,7 @@ acquire_vt:
     {
 	/* serverGeneration != 1 */
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-    	if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+    	if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
     	{
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
 	    {
@@ -392,6 +397,9 @@ xf86OpenSyscons()
 	    if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
 		initialVT = -1;
 #endif
+            if (ShareVTs)
+		xf86Info.vtno = initialVT;
+
 	    if (xf86Info.vtno == -1)
 	    {
 		/*
@@ -651,6 +659,8 @@ xf86CloseConsole()
     struct vt_mode   VT;
 #endif
 
+    if (ShareVTs) return;
+
     switch (xf86Info.consType)
     {
 #ifdef PCCONS_SUPPORT
@@ -717,6 +727,11 @@ xf86ProcessArgument(int argc, char *argv[], int i)
 		return(1);
 	}
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+	if (!strcmp(argv[i], "-sharevts"))
+	{	
+		ShareVTs = TRUE;
+		return(1);
+	}
 	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
 	{
 		if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
@@ -737,6 +752,7 @@ xf86UseMsg()
 {
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
 	ErrorF("vtXX                   use the specified VT number (1-12)\n");
+	ErrorF("-sharevts              share VTs with another X server\n");
 #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
 	ErrorF("-keeptty               ");
 	ErrorF("don't detach controlling tty (for debugging only)\n");
commit 4c68079c2ae8a2f04363623c44d17bc8c255c3bf
Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sun Dec 14 18:58:33 2008 -0800

    GLX: Changes resulting from changes to Mesa generator scripts / data
    
    Several recent Mesa commits (listed below) make modifications to the
    protocol generator data and scripts.  This commit represents the
    changes to the generated files resulting from the previous changes.
    
        - 0f73302d24f4201813da2939742c5bcb6964b3b1
          GLX: Fix protocol for glTexSubImage#D
    
        - 1709ab01ef24279c782e420568e9257b4b92b224
          Return 0 as the request size when the pixels parameter is NULL
    
        - 63cca2ba10ce7dcc8481cfa4be3872dfc269dded
          GLX: Include glapi.h before glapitable.h
    
    This is the server-side part of the fix for bugzilla #11003.
    (cherry picked from commit f1c9b5ab230cbb4124d8d476ae4886d05022adcb)

diff --git a/glx/dispatch.h b/glx/dispatch.h
index 7123156..f019aa6 100644
--- a/glx/dispatch.h
+++ b/glx/dispatch.h
@@ -28,6 +28,8 @@
 #if !defined( _DISPATCH_H_ )
 #  define _DISPATCH_H_
 
+
+#include "glapitable.h"
 /**
  * \file dispatch.h
  * Macros for handling GL dispatch tables.
diff --git a/glx/glapi.h b/glx/glapi.h
index ddfb1cf..8f2cf66 100644
--- a/glx/glapi.h
+++ b/glx/glapi.h
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -44,12 +44,17 @@
 #ifndef _GLAPI_H
 #define _GLAPI_H
 
+#define GL_GLEXT_PROTOTYPES
 
 #include "GL/gl.h"
-#include "glapitable.h"
+#include "GL/glext.h"
 #include "glthread.h"
 
 
+struct _glapi_table;
+
+typedef void (*_glapi_proc)(void); /* generic function pointer */
+
 typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
 
 
@@ -63,6 +68,12 @@ typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
 #endif
 
 
+/*
+ * Number of extension functions which we can dynamically add at runtime.
+ */
+#define MAX_EXTENSION_FUNCS 300
+
+
 /**
  ** Define the GET_CURRENT_CONTEXT() macro.
  ** \param C local variable which will hold the current context.
diff --git a/glx/glapitable.h b/glx/glapitable.h
index 48941f5..5d9d40a 100644
--- a/glx/glapitable.h
+++ b/glx/glapitable.h
@@ -37,7 +37,6 @@
 # define GLAPIENTRYP GLAPIENTRY *
 #endif
 
-typedef void (*_glapi_proc)(void); /* generic function pointer */
 
 struct _glapi_table
 {
diff --git a/glx/glthread.c b/glx/glthread.c
index 813d6f9..b818f4e 100644
--- a/glx/glthread.c
+++ b/glx/glthread.c
@@ -34,6 +34,7 @@
 #endif
 
 #include <stdlib.h>
+#include <stdio.h>
 #include "glthread.h"
 
 
diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c
index 2afd3eb..6547f5d 100644
--- a/glx/indirect_dispatch.c
+++ b/glx/indirect_dispatch.c
@@ -36,8 +36,8 @@
 #include "glxbyteorder.h"
 #include "indirect_util.h"
 #include "singlesize.h"
-#include "glapitable.h"
 #include "glapi.h"
+#include "glapitable.h"
 #include "glthread.h"
 #include "dispatch.h"
 
@@ -2972,8 +2972,7 @@ void __glXDisp_PrioritizeTextures(GLbyte * pc)
 
 void __glXDisp_TexSubImage1D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 56);
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -2996,8 +2995,7 @@ void __glXDisp_TexSubImage1D(GLbyte * pc)
 
 void __glXDisp_TexSubImage2D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 56);
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3773,8 +3771,7 @@ void __glXDisp_TexImage3D(GLbyte * pc)
 
 void __glXDisp_TexSubImage3D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 84);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 88);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 88);
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c
index f137cbe..0b8c27c 100644
--- a/glx/indirect_dispatch_swap.c
+++ b/glx/indirect_dispatch_swap.c
@@ -36,8 +36,8 @@
 #include "glxbyteorder.h"
 #include "indirect_util.h"
 #include "singlesize.h"
-#include "glapitable.h"
 #include "glapi.h"
+#include "glapitable.h"
 #include "glthread.h"
 #include "dispatch.h"
 
@@ -3092,8 +3092,7 @@ void __glXDispSwap_PrioritizeTextures(GLbyte * pc)
 
 void __glXDispSwap_TexSubImage1D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 56);
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3116,8 +3115,7 @@ void __glXDispSwap_TexSubImage1D(GLbyte * pc)
 
 void __glXDispSwap_TexSubImage2D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 56);
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3909,8 +3907,7 @@ void __glXDispSwap_TexImage3D(GLbyte * pc)
 
 void __glXDispSwap_TexSubImage3D(GLbyte * pc)
 {
-    const CARD32 ptr_is_null = *(CARD32 *)(pc + 84);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 88);
+    const GLvoid * const pixels = (const GLvoid *) (pc + 88);
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
diff --git a/glx/indirect_reqsize.c b/glx/indirect_reqsize.c
index 954eecd..c47f01e 100644
--- a/glx/indirect_reqsize.c
+++ b/glx/indirect_reqsize.c
@@ -572,6 +572,9 @@ __glXTexImage3DReqSize(const GLbyte *pc, Bool swap)
         type = bswap_32(type);
     }
 
+    if (*(CARD32 *) (pc + 76))
+        return 0;
+
     return __glXImageSize(format, type, target, width, height, depth,
                           image_height, row_length, skip_images,
                           skip_rows, alignment);
commit 75bad86992338f5ce0ade6986b758cd6af2a5b9a
Author: Cooper Yuan <Cooper.Yuan at amd.com>
Date:   Mon Dec 15 10:29:34 2008 -0500

    Fix typo in xf86PickCrtcs()
    (cherry picked from commit 2a61397d17339113b9e37995b06ca543589814ce)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 78105b6..b972974 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -976,7 +976,7 @@ xf86PickCrtcs (ScrnInfoPtr	scrn,
 	     * see if they can be cloned
 	     */
 	    if (xf86ModesEqual (modes[o], modes[n]) &&
-		config->output[0]->initial_rotation == config->output[n]->initial_rotation &&
+		config->output[o]->initial_rotation == config->output[n]->initial_rotation &&
 		config->output[o]->initial_x == config->output[n]->initial_x &&
 		config->output[o]->initial_y == config->output[n]->initial_y)
 	    {
commit f427d3aaa7ca58822033ac5486b46671a937b68a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat Dec 13 00:45:27 2008 -0800

    XQuartz: Updated menu item ordering for better HIG compliance
    (cherry picked from commit 4c9bb241ce5fb856fab20ae96fa89bd2b71ef242)
    (cherry picked from commit 73987010b2ef9c67b6614e226c6fae65d834d8f3)

diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
index 1ed46e9..d271625 100644
--- a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9F33</string>
-		<string key="IBDocument.InterfaceBuilderVersion">672</string>
-		<string key="IBDocument.AppKitVersion">949.34</string>
-		<string key="IBDocument.HIToolboxVersion">352.00</string>
+		<string key="IBDocument.SystemVersion">9G55</string>
+		<string key="IBDocument.InterfaceBuilderVersion">677</string>
+		<string key="IBDocument.AppKitVersion">949.43</string>
+		<string key="IBDocument.HIToolboxVersion">353.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 		</object>
@@ -13,6 +13,15 @@
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 		</object>
+		<object class="NSMutableDictionary" key="IBDocument.Metadata">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<object class="NSArray" key="dict.sortedKeys">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+			</object>
+			<object class="NSMutableArray" key="dict.values">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+			</object>
+		</object>
 		<object class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<object class="NSCustomObject" id="815810918">
@@ -256,6 +265,15 @@
 							</object>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="984461797">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Close</string>
+									<string key="NSKeyEquiv">w</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="351811234"/>
+								</object>
 								<object class="NSMenuItem" id="677652931">
 									<reference key="NSMenu" ref="96874957"/>
 									<string key="NSTitle">Minimize</string>
@@ -274,6 +292,17 @@
 									<reference key="NSOnImage" ref="531645050"/>
 									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
+								<object class="NSMenuItem" id="280172320">
+									<reference key="NSMenu" ref="96874957"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="351811234"/>
+								</object>
 								<object class="NSMenuItem" id="1036389925">
 									<reference key="NSMenu" ref="96874957"/>
 									<string key="NSTitle">Cycle Through Windows</string>
@@ -292,26 +321,6 @@
 									<reference key="NSOnImage" ref="531645050"/>
 									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
-								<object class="NSMenuItem" id="280172320">
-									<reference key="NSMenu" ref="96874957"/>
-									<bool key="NSIsDisabled">YES</bool>
-									<bool key="NSIsSeparator">YES</bool>
-									<string key="NSTitle"/>
-									<string key="NSKeyEquiv"/>
-									<int key="NSKeyEquivModMask">1048576</int>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="351811234"/>
-								</object>
-								<object class="NSMenuItem" id="984461797">
-									<reference key="NSMenu" ref="96874957"/>
-									<string key="NSTitle">Close</string>
-									<string key="NSKeyEquiv">w</string>
-									<int key="NSKeyEquivModMask">1048576</int>
-									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="351811234"/>
-								</object>
 								<object class="NSMenuItem" id="155085383">
 									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
@@ -1442,6 +1451,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 									</object>
 									<string key="NSFrame">{{1, 17}, {301, 198}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
+									<reference key="NSNextKeyView" ref="905092943"/>
 									<reference key="NSDocView" ref="905092943"/>
 									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
@@ -1474,6 +1484,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 									</object>
 									<string key="NSFrame">{{1, 0}, {301, 17}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
+									<reference key="NSNextKeyView" ref="792419186"/>
 									<reference key="NSDocView" ref="792419186"/>
 									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
@@ -1482,6 +1493,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							</object>
 							<string key="NSFrame">{{20, 20}, {318, 231}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
+							<reference key="NSNextKeyView" ref="580565898"/>
 							<int key="NSsFlags">50</int>
 							<reference key="NSVScroller" ref="842897584"/>
 							<reference key="NSHScroller" ref="17278747"/>
@@ -2195,11 +2207,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference ref="276216762"/>
 							<reference ref="1066447520"/>
 							<reference ref="1036389925"/>
-							<reference ref="280172320"/>
 							<reference ref="369641893"/>
-							<reference ref="984461797"/>
 							<reference ref="155085383"/>
 							<reference ref="444952046"/>
+							<reference ref="984461797"/>
+							<reference ref="280172320"/>
 						</object>
 						<reference key="parent" ref="931553638"/>
 					</object>
@@ -3626,7 +3638,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{204, 683}, {315, 153}}</string>
+					<string>{{349, 858}, {315, 153}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{271, 666}, {301, 153}}</string>
@@ -3634,7 +3646,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{437, 749}, {484, 308}}</string>
 					<reference ref="9"/>
 					<string>{{184, 290}, {481, 345}}</string>
-					<integer value="0"/>
+					<integer value="0" id="8"/>
 					<reference ref="9"/>
 					<string>{3.40282e+38, 3.40282e+38}</string>
 					<string>{320, 240}</string>
@@ -3654,13 +3666,13 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{68, 585}, {454, 271}}</string>
 					<reference ref="9"/>
 					<string>{{433, 406}, {486, 327}}</string>
-					<integer value="0"/>
+					<reference ref="8"/>
 					<reference ref="9"/>
 					<string>{3.40282e+38, 3.40282e+38}</string>
 					<string>{320, 240}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{8, 844}, {336, 20}}</string>
+					<string>{{145, 1011}, {336, 20}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{67, 819}, {336, 20}}</string>
diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib
index 16c7109..ee6cdf2 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib differ
commit d0eb4337e3468a5854e4801fcb1d2bc7d5c4d81f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 10 23:04:30 2008 -0800

    XQuartz: Tiger fix, don't call Xplugin code in the Appkit thread if Xplugin isn't threadsafe.
    (cherry picked from commit 748d9e5bd756513d42c4046f3b31e1fdc55bccb6)
    (cherry picked from commit fd31984e0c0f9a37087cd1cffaa3ba116b12c2e5)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 371b6d6..2c6b60b 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1008,6 +1008,9 @@ extern int darwin_modifier_flags; // darwinEvents.c
                 pDev = darwinTabletCurrent;
             }
 
+/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
+#ifdef XPLUGIN_VERSION
+#if XPLUGIN_VERSION > 0
             if(!quartzServerVisible) {
                 xp_window_id wid;
 
@@ -1023,6 +1026,8 @@ extern int darwin_modifier_flags; // darwinEvents.c
                     wid == 0)
                     return;        
             }
+#endif
+#endif
             
             DarwinSendPointerEvents(pDev, ev_type, ev_button, pointer_x, pointer_y,
                                     pressure, tilt_x, tilt_y);
commit d9e1fdcd40bf12378c9fa05a8adbe3aefca65676
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 10 01:56:01 2008 -0800

    XQuartz: Fix path to executable
    (cherry picked from commit 7e9d3698e070a0c63dd2556651373c3aca58e2fe)
    (cherry picked from commit 5926b213b39a90601c73f026dc0699723f5ed10d)

diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 5e00a82..2f953d1 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,3 +1,3 @@
 #!/bin/bash --login
 
-./X11 "${@}"
+"$(dirname $0)"/X11 "${@}"
commit e93daf4e7140115f9485c8c0cdc358d50c9575be
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 10 00:00:29 2008 -0800

    XQuartz: fixed make dist
    (cherry picked from commit 2d52367ab92429e58596d1a1ed3ef52a0a38a7aa)
    (cherry picked from commit 13eff12902be1b25d0ccc2089e08305f88949f32)

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 16434f2..9713289 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -5,7 +5,7 @@
 	<key>CFBundleDevelopmentRegion</key>
 		<string>English</string>
 	<key>CFBundleExecutable</key>
-		<string>X11</string>
+		<string>X11.sh</string>
 	<key>CFBundleGetInfoString</key>
 		<string>APPLE_APPLICATION_NAME</string>
 	<key>CFBundleIconFile</key>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index e765d6e..03fa1dd 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -17,6 +17,7 @@ resource_DATA = Xquartz.plist
 
 EXTRA_DIST = \
 	mk_bundke.sh \
+	X11.sh \
 	Info.plist.cpp \
 	PkgInfo \
 	$(resource_DATA) \
commit 1cf76f23c7d210d75a401568c5ad788a2fd268d1
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Dec 9 23:47:32 2008 -0800

    XQuartz: Avoid using login /bin/sh blech.  Just use a bash script to start the app, so it will inherit the right environment
    (cherry picked from commit f4b7ad9cc6b0c99fc7ee8516c4bf858ece938148)
    (cherry picked from commit fdf64256127b2661bd6aa81ac694350028d36c43)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 67a80d3..7222f46 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -314,65 +314,79 @@ BOOL xquartz_resetenv_display = NO;
 
 - (void) launch_client:(NSString *)filename
 {
-  const char *command = [filename UTF8String];
-  const char *argv[7];
-  int child1, child2 = 0;
-  int status;
-	
-  argv[0] = "/usr/bin/login";
-  argv[1] = "-fp";
-  argv[2] = getlogin();
-  argv[3] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
-  argv[4] = "-c";
-  argv[5] = command;
-  argv[6] = NULL;
-
-  /* Do the fork-twice trick to avoid having to reap zombies */
+    const char *command = [filename UTF8String];
+    int child1, child2 = 0;
+    int status;
+    char newcommand[1024];
+    char *newargv[1024];
+    char buf[128];
+    size_t newargc;
+    char *s;
     
-  child1 = fork();
+    if(strlen(command) > 1023) {
+        fprintf(stderr, "Error: command is too long: %s\n", command);
+        return;
+    }
+    
+    strlcpy(newcommand, command, 1024);
     
-  switch (child1) {
-  case -1:                                /* error */
-    break;
+    for(newargc=0, s=newcommand; *s; newargc++) {
+        for(; *s && *s == ' '; s++);
+        if(!*s)
+            break;
+        
+        newargv[newargc] = s;
+        for(; *s && *s != ' '; s++);
+        
+        if(*s) {
+            *s='\0';
+            s++;
+        }
+    }
+    newargv[newargc] = NULL;
+    
+    s = getenv("DISPLAY");
+    if (xquartz_resetenv_display || s == NULL || s[0] == 0) {
+        snprintf(buf, sizeof(buf), ":%s", display);
+        setenv("DISPLAY", buf, TRUE);
+    }
+
+    /* Do the fork-twice trick to avoid having to reap zombies */
+    child1 = fork();
+    switch (child1) {
+        case -1:                                /* error */
+            break;
       
-  case 0:                                 /* child1 */
-    child2 = fork();
+        case 0:                                 /* child1 */
+            child2 = fork();
       
-    switch (child2) {
-      int max_files, i;
-      char buf[1024], *temp;
-	
-    case -1:                            /* error */
-      _exit(1);
-	
-    case 0:                             /* child2 */
-      /* close all open files except for standard streams */
-      max_files = sysconf(_SC_OPEN_MAX);
-      for (i = 3; i < max_files; i++)	close(i);
-	
-      /* ensure stdin is on /dev/null */
-      close(0);
-      open("/dev/null", O_RDONLY);
-	
-      /* Setup environment */
-      temp = getenv("DISPLAY");
-      if (xquartz_resetenv_display || temp == NULL || temp[0] == 0) {
-    snprintf(buf, sizeof(buf), ":%s", display);
-	setenv("DISPLAY", buf, TRUE);
-      }
-
-      execvp(argv[0], (char **const) argv);
-	
-      _exit(2);
-	
-    default:                            /* parent (child1) */
-      _exit(0);
-    }
-    break;
+            switch (child2) {
+                int max_files, i;
+	
+                case -1:                            /* error */
+                    _exit(1);
+	 
+                case 0:                             /* child2 */
+                /* close all open files except for standard streams */
+                max_files = sysconf(_SC_OPEN_MAX);
+                for(i = 3; i < max_files; i++)
+                    close(i);
+	
+                /* ensure stdin is on /dev/null */
+                close(0);
+                open("/dev/null", O_RDONLY);
+	
+                execvp(newargv[0], (char **const) newargv);
+                _exit(2);
+	
+                default:                            /* parent (child1) */
+                _exit(0);
+            }
+            break;
       
-  default:                                /* parent */
-    waitpid(child1, &status, 0);
-  }
+        default:                                /* parent */
+            waitpid(child1, &status, 0);
+    }
 }
 
 - (void) app_selected:sender
diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
new file mode 100755
index 0000000..5e00a82
--- /dev/null
+++ b/hw/xquartz/bundle/X11.sh
@@ -0,0 +1,3 @@
+#!/bin/bash --login
+
+./X11 "${@}"
diff --git a/hw/xquartz/bundle/mk_bundke.sh b/hw/xquartz/bundle/mk_bundke.sh
index 0b2a144..5c5733a 100755
--- a/hw/xquartz/bundle/mk_bundke.sh
+++ b/hw/xquartz/bundle/mk_bundke.sh
@@ -20,6 +20,9 @@ install -m 644 Resources/X11.icns ${BUNDLE_ROOT}/Contents/Resources
 install -m 644 Info.plist ${BUNDLE_ROOT}/Contents
 install -m 644 PkgInfo ${BUNDLE_ROOT}/Contents
 
+mkdir -p ${BUNDLE_ROOT}/Contents/MacOS
+install -m 755 X11.sh ${BUNDLE_ROOT}/Contents/MacOS
+
 if [[ $(id -u) == 0 ]] ; then
 	chown -R root:admin ${BUNDLE_ROOT}
 fi
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 6b48c13..7677a9a 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -529,22 +529,39 @@ int main(int argc, char **argv, char **envp) {
     
     return EXIT_SUCCESS;
 }
-    
-static int execute(const char *command) {
-    const char *newargv[7];
-    const char **s;
 
-    newargv[0] = "/usr/bin/login";
-    newargv[1] = "-fp";
-    newargv[2] = getlogin();
-    newargv[3] = command_from_prefs("login_shell", DEFAULT_SHELL);
-    newargv[4] = "-c";
-    newargv[5] = command;
-    newargv[6] = NULL;
+static int execute(const char *command) {
+    char newcommand[1024];
+    char *newargv[1024];
+    size_t newargc;
+    char *s;
+    char **p;
+    
+    if(strlen(command) > 1023) {
+        fprintf(stderr, "Error: command is too long: %s\n", command);
+        return 1;
+    }
+    
+    strlcpy(newcommand, command, 1024);
+    
+    for(newargc=0, s=newcommand; *s; newargc++) {
+        for(; *s && *s == ' '; s++);
+        if(!*s)
+            break;
+        
+        newargv[newargc] = s;
+        for(; *s && *s != ' '; s++);
+        
+        if(*s) {
+            *s='\0';
+            s++;
+        }
+    }
+    newargv[newargc] = NULL;
     
     fprintf(stderr, "X11.app: Launching %s:\n", command);
-    for(s=newargv; *s; s++) {
-        fprintf(stderr, "\targv[%ld] = %s\n", (long int)(s - newargv), *s);
+    for(p=newargv; *p; p++) {
+        fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p);
     }
 
     execvp (newargv[0], (char * const *) newargv);
commit 22d3ecda18ba799966d08237d8041ad80b20d0f2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 8 21:59:49 2008 -0800

    XQuartz: unset DISPLAY if we didn't get a launchd socket handoff
    (cherry picked from commit b959727f38733009c6381cc8ca06b5984257bdac)
    (cherry picked from commit 9cbed0a325175e7ddb751db54fe6c0f5a5cedd16)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8b6d458..6b48c13 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -278,8 +278,12 @@ static int create_socket(char *filename_out) {
     return 0;
 }
 
+static int launchd_socket_handed_off = 0;
+
 kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
     socket_handoff_t *handoff_data;
+    
+    launchd_socket_handed_off = 1;
 
     handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
     if(!handoff_data) {
@@ -318,6 +322,12 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
     char **_envp = alloca((envpCnt + 1) * sizeof(char *));
     size_t i;
     
+    /* If we didn't get handed a launchd DISPLAY socket, we shoul
+     * unset DISPLAY or we can run into problems with pbproxy
+     */
+    if(!launchd_socket_handed_off)
+        unsetenv("DISPLAY");
+    
     if(!_argv || !_envp) {
         return KERN_FAILURE;
     }
commit 9eb5f3092984206ac7cab9a9fdb4b19448db3a24
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 8 21:00:11 2008 -0800

    XQuartz: unsetenv(DISPLAY) if we're not org.x.X11
    Also some prefix related fixes.
    (cherry picked from commit fd459e96581a883e30323c840b71004aa0747169)
    (cherry picked from commit 99b2cbf061a9d074e66e6220dc08f8b4624ea6bb)

diff --git a/configure.ac b/configure.ac
index 486dad8..efe347f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,7 @@ AC_PROG_LEX
 AC_PROG_YACC
 AC_SYS_LARGEFILE
 XORG_PROG_RAWCPP
+AC_PATH_PROG(SED,sed)
 
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
@@ -485,6 +486,14 @@ AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir
 				[ APPLE_APPLICATIONS_DIR="${withval}" ],
 				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
 AC_SUBST([APPLE_APPLICATIONS_DIR])
+AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], [Name for the .app (default: X11)]),
+				[ APPLE_APPLICATION_NAME="${withval}" ],
+				[ APPLE_APPLICATION_NAME="X11" ])
+AC_SUBST([APPLE_APPLICATION_NAME])
+AC_ARG_WITH(apple-application-id,AS_HELP_STRING([--with-apple-application-id=VALUE], [CFBundleIdentification for the .app (default: org.x.X11)]),
+				[ APPLE_APPLICATION_ID="${withval}" ],
+				[ APPLE_APPLICATION_ID="org.x.X11" ])
+AC_SUBST([APPLE_APPLICATION_ID])
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index d1eb283..e5e2e9e 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -7,7 +7,8 @@ AM_CPPFLAGS = \
 	-DINXQUARTZ \
 	-DUSE_NEW_CLUT \
 	-DXFree86Server \
-	-I$(top_srcdir)/miext/rootless
+	-I$(top_srcdir)/miext/rootless \
+	-DX11LIBDIR=\"$(libdir)\"
 
 if GLX
 GL_DIR = GL
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 21013d9..371b6d6 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -54,7 +54,7 @@
 // pbproxy/pbproxy.h
 extern BOOL xpbproxy_init (void);
 
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
 
 #ifndef XSERVER_VERSION
 #define XSERVER_VERSION "?"
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
deleted file mode 100644
index f4a9287..0000000
--- a/hw/xquartz/bundle/Info.plist
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-		<string>English</string>
-	<key>CFBundleExecutable</key>
-		<string>X11</string>
-	<key>CFBundleGetInfoString</key>
-		<string>X11</string>
-	<key>CFBundleIconFile</key>
-		<string>X11.icns</string>
-	<key>CFBundleIdentifier</key>
-		<string>org.x.X11</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-		<string>6.0</string>
-	<key>CFBundleName</key>
-		<string>X11</string>
-	<key>CFBundlePackageType</key>
-		<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-		<string>2.3.2</string>
-	<key>CFBundleVersion</key>
-		<string>2.3.2</string>
-	<key>CFBundleSignature</key>
-		<string>x11a</string>
-	<key>CSResourcesFileMapped</key>
-		<true/>
-	<key>NSHumanReadableCopyright</key>
-		<string>Copyright © 2003-2008, Apple Inc.
-Copyright © 2003, XFree86 Project, Inc.
-Copyright © 2003-2008, X.org Foundation, Inc.
-</string>
-	<key>NSMainNibFile</key>
-		<string>main</string>
-	<key>NSPrincipalClass</key>
-		<string>X11Application</string>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
new file mode 100644
index 0000000..16434f2
--- /dev/null
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+		<string>English</string>
+	<key>CFBundleExecutable</key>
+		<string>X11</string>
+	<key>CFBundleGetInfoString</key>
+		<string>APPLE_APPLICATION_NAME</string>
+	<key>CFBundleIconFile</key>
+		<string>X11.icns</string>
+	<key>CFBundleIdentifier</key>
+		<string>APPLE_APPLICATION_ID</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+		<string>6.0</string>
+	<key>CFBundleName</key>
+		<string>APPLE_APPLICATION_NAME</string>
+	<key>CFBundlePackageType</key>
+		<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+		<string>2.3.2</string>
+	<key>CFBundleVersion</key>
+		<string>2.3.2</string>
+	<key>CFBundleSignature</key>
+		<string>x11a</string>
+	<key>CSResourcesFileMapped</key>
+		<true/>
+	<key>NSHumanReadableCopyright</key>
+		<string>Copyright © 2003-2008, Apple Inc.
+Copyright © 2003, XFree86 Project, Inc.
+Copyright © 2003-2008, X.org Foundation, Inc.
+</string>
+	<key>NSMainNibFile</key>
+		<string>main</string>
+	<key>NSPrincipalClass</key>
+		<string>X11Application</string>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 7b76f84..e765d6e 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -1,12 +1,23 @@
+include cpprules.in
+
+CPP_FILES_FLAGS = \
+	-DAPPLE_APPLICATION_ID="$(APPLE_APPLICATION_ID)" \
+	-DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
+
 install-data-hook:
-	./mk_bundke.sh $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/X11.app
+	./mk_bundke.sh $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app
+
+noinst_PRE = Info.plist.cpp
+noinst_DATA = $(noinst_PRE:plist.cpp=plist)
+
+CLEANFILES = $(noinst_DATA)
 
 resourcedir=$(libdir)/X11/xserver
 resource_DATA = Xquartz.plist
 
 EXTRA_DIST = \
 	mk_bundke.sh \
-	Info.plist \
+	Info.plist.cpp \
 	PkgInfo \
 	$(resource_DATA) \
 	Resources/da.lproj/InfoPlist.strings \
diff --git a/hw/xquartz/bundle/cpprules.in b/hw/xquartz/bundle/cpprules.in
new file mode 100644
index 0000000..f32eafc
--- /dev/null
+++ b/hw/xquartz/bundle/cpprules.in
@@ -0,0 +1,37 @@
+# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
+# to cpp, because that trick does not work on all ANSI C preprocessors.
+# Delete line numbers from the cpp output (-P is not portable, I guess).
+# Allow XCOMM to be preceded by whitespace and provide a means of generating
+# output lines with trailing backslashes.
+# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
+
+CPP_SED_MAGIC = $(SED) -e '/^\#  *[0-9][0-9]*  *.*$$/d' \
+                       -e '/^\#line  *[0-9][0-9]*  *.*$$/d' \
+                       -e '/^[ 	]*XCOMM$$/s/XCOMM/\#/' \
+                       -e '/^[ 	]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
+                       -e '/^[ 	]*XHASH/s/XHASH/\#/' \
+                       -e '/XSLASHGLOB/s/XSLASHGLOB/\/\*/' \
+                       -e '/\@\@$$/s/\@\@$$/\\/'
+
+# Strings to replace in man pages
+XORGRELSTRING = @PACKAGE_STRING@
+  XORGMANNAME = X Version 11
+
+MANDEFS =  \
+	-D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \
+	-D__appmansuffix__=$(APP_MAN_SUFFIX) \
+	-D__filemansuffix__=$(FILE_MAN_SUFFIX) \
+	-D__libmansuffix__=$(LIB_MAN_SUFFIX) \
+	-D__miscmansuffix__=$(MISC_MAN_SUFFIX) \
+	-D__XSERVERNAME__=Xorg -D__XCONFIGFILE__=xorg.conf \
+	-D__xinitdir__=$(XINITDIR) \
+	-D__bindir__=$(bindir) \
+	-DSHELL_CMD=$(SHELL_CMD) $(ARCHMANDEFS)
+
+SUFFIXES = .$(APP_MAN_SUFFIX) .man .cpp
+
+.cpp:
+	$(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@
+
+.man.$(APP_MAN_SUFFIX):
+	$(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 0e4ed34..8b6d458 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -59,8 +59,8 @@ extern int noPanoramiXExtension;
 
 extern int xquartz_resetenv_display;
 
-#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
-#define DEFAULT_STARTX "/usr/X11/bin/startx"
+#define DEFAULT_CLIENT X11BINDIR "/xterm"
+#define DEFAULT_STARTX X11BINDIR "/startx"
 #define DEFAULT_SHELL  "/bin/sh"
 
 #ifndef BUILD_DATE
@@ -420,19 +420,49 @@ int startup_trigger(int argc, char **argv, char **envp) {
 }
 
 /** Setup the environment we want our child processes to inherit */
-static void setup_env() {
+static void ensure_path(const char *dir) {
     char buf[1024], *temp;
-
+    
     /* Make sure /usr/X11/bin is in the $PATH */
     temp = getenv("PATH");
     if(temp == NULL || temp[0] == 0) {
-        snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", X11BINDIR);
+        snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
         setenv("PATH", buf, TRUE);
     } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
-        snprintf(buf, sizeof(buf), "%s:%s", temp, X11BINDIR);
+        snprintf(buf, sizeof(buf), "%s:%s", temp, dir);
         setenv("PATH", buf, TRUE);
     }
+}
+
+static void setup_env() {
+    char *temp;
+    const char *pds = NULL;
+
+    /* Pass on our prefs domain to startx and its inheritors (mainly for
+     * quartz-wm and the Xquartz stub's MachIPC)
+     */
+    CFBundleRef bundle = CFBundleGetMainBundle();
+    if(bundle) {
+        CFStringRef pd = CFBundleGetIdentifier(bundle);
+        if(pd) {
+            pds = CFStringGetCStringPtr(pd, 0);
+            if(pds) {
+                server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
+                strcpy(server_bootstrap_name, pds);
+                setenv("X11_PREFS_DOMAIN", pds, 1);
+            }
+        }
+    }
 
+    /* If we're not org.x.X11, we want to unset DISPLAY, so we don't
+     * use the launchd DISPLAY socket.
+     */
+    if(pds == NULL || strcmp(pds, "org.x.X11") != 0)
+        unsetenv("DISPLAY");
+
+    /* Make sure PATH is right */
+    ensure_path(X11BINDIR);
+    
     /* cd $HOME */
     temp = getenv("HOME");
     if(temp != NULL && temp[0] != '\0')
@@ -455,22 +485,6 @@ int main(int argc, char **argv, char **envp) {
 
     /* Setup the initial crasherporter info */
     strlcpy(__crashreporter_info__, __crashreporter_info__base, __crashreporter_info__len);
-
-    /* Pass on our prefs domain to startx and its inheritors (mainly for
-     * quartz-wm and the Xquartz stub's MachIPC)
-     */
-    CFBundleRef bundle = CFBundleGetMainBundle();
-    if(bundle) {
-        CFStringRef pd = CFBundleGetIdentifier(bundle);
-        if(pd) {
-            const char *pds = CFStringGetCStringPtr(pd, 0);
-            if(pds) {
-                server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1));
-                strcpy(server_bootstrap_name, pds);
-                setenv("X11_PREFS_DOMAIN", pds, 1);
-            }
-        }
-    }
     
     fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
     for(i=0; i < argc; i++) {
commit 19e6f73710776aee0b76dcbd62596a448029611e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat Dec 6 12:01:28 2008 -0800

    XQuartz: Removed some debug spew
    (cherry picked from commit 370dcf11b360b87aa24cace35eb615419057fda0)
    (cherry picked from commit 8065953ea8c3b7d10c775f6b7fec629bb5a2c83c)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 2fcd35b..0e4ed34 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -433,8 +433,6 @@ static void setup_env() {
         setenv("PATH", buf, TRUE);
     }
 
-    fprintf(stderr, "PATH: %s\n", getenv("PATH"));
-    
     /* cd $HOME */
     temp = getenv("HOME");
     if(temp != NULL && temp[0] != '\0')
commit ced368287bad65c126cd6a5304969d0a0f9dc4eb
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat Dec 6 14:11:25 2008 -0800

    XQuartz: darwinPointer reports the actual pixel position now rather than a relative position
    (cherry picked from commit a41e7f75decd340d064fdc0d2c4fe6c88d7dbc82)
    (cherry picked from commit 70930f6d31cc2ca16b40c17e101b106506a8337a)

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 97791e6..07b243b 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -347,10 +347,10 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
             InitPointerDeviceStruct((DevicePtr)pPointer, map, 7,
                                     (PtrCtrlProcPtr)NoopDDA,
                                     GetMotionHistorySize(), 2);
-			InitAbsoluteClassDeviceStruct(pPointer);
             pPointer->valuator->mode = Absolute; // Relative
-            InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
-            InitValuatorAxisStruct(pPointer, 1, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitAbsoluteClassDeviceStruct(pPointer);
+//            InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+//            InitValuatorAxisStruct(pPointer, 1, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
             break;
         case DEVICE_ON:
             pPointer->public.on = TRUE;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 21fd768..7fc390d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -370,7 +370,7 @@ static void DarwinPokeEQ(void) {
  * Note: pointer_x and pointer_y are relative to the upper-left of primary
  *       display.
  */
-static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
+static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr screen,
                                    float pointer_x, float pointer_y, 
                                    float pressure, float tilt_x, float tilt_y) {
     /* Fix offset between darwin and X screens */
@@ -382,14 +382,21 @@ static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
 
     if(pointer_y < 0.0)
         pointer_y = 0.0;
-
-    /* Setup our array of values */
-    valuators[0] = pointer_x * XQUARTZ_VALUATOR_LIMIT / (float)screenInfo.screens[0]->width;
-    valuators[1] = pointer_y * XQUARTZ_VALUATOR_LIMIT / (float)screenInfo.screens[0]->height;
-    valuators[2] = pressure * XQUARTZ_VALUATOR_LIMIT;
-    valuators[3] = tilt_x * XQUARTZ_VALUATOR_LIMIT;
-    valuators[4] = tilt_y * XQUARTZ_VALUATOR_LIMIT;
     
+    if(pDev == darwinPointer) {
+        valuators[0] = pointer_x;
+        valuators[1] = pointer_y;
+        valuators[2] = 0;
+        valuators[3] = 0;
+        valuators[4] = 0;
+    } else {
+        /* Setup our array of values */
+        valuators[0] = XQUARTZ_VALUATOR_LIMIT * (pointer_x / (float)screenInfo.screens[0]->width);
+        valuators[1] = XQUARTZ_VALUATOR_LIMIT * (pointer_y / (float)screenInfo.screens[0]->height);
+        valuators[2] = XQUARTZ_VALUATOR_LIMIT * pressure;
+        valuators[3] = XQUARTZ_VALUATOR_LIMIT * tilt_x;
+        valuators[4] = XQUARTZ_VALUATOR_LIMIT * tilt_y;
+    }
     //DEBUG_LOG("Pointer (%f, %f), Valuators: {%d,%d,%d,%d,%d}\n", pointer_x, pointer_y,
     //          valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
 }
@@ -446,7 +453,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
         darwinFakeMouseButtonDown = 0;
 	}
 
-    DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+    DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
     darwinEvents_lock(); {
         num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, 
                                       POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators);
@@ -473,7 +480,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
 	int i, num_events;
     ScreenPtr screen;
-    DeviceIntPtr dev = darwinTabletCurrent;
+    DeviceIntPtr pDev = darwinTabletCurrent;
     int valuators[5];
 
 	DEBUG_LOG("DarwinSendProximityEvents(%d, %f, %f)\n", ev_type, pointer_x, pointer_y);
@@ -483,17 +490,17 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
 		return;
 	}
     
-    screen = miPointerGetScreen(dev);
+    screen = miPointerGetScreen(pDev);
     if(!screen) {
         DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
         return;
     }    
 
-    DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f);
+    DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, 0.0f, 0.0f, 0.0f);
     darwinEvents_lock(); {
-        num_events = GetProximityEvents(darwinEvents, dev, ev_type,
+        num_events = GetProximityEvents(darwinEvents, pDev, ev_type,
                                         0, 5, valuators);
-        for(i=0; i<num_events; i++) mieqEnqueue (dev,darwinEvents[i].event);
+        for(i=0; i<num_events; i++) mieqEnqueue (pDev,darwinEvents[i].event);
         DarwinPokeEQ();
     } darwinEvents_unlock();
 }
commit b5687a9d129f6eea7ebe590120f9d90f9d7ed48b
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Dec 5 12:42:31 2008 -0800

    XQuartz: Corrected name/command labels in the customization widget
    (cherry picked from commit a689c23f17eb445c36b97eb617ef4b8bd157985f)
    (cherry picked from commit 9ac2e68d86ed1eb6e3f6c900c60908813eca140e)

diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
index 8f7c503..1ed46e9 100644
--- a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
@@ -1,28 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
 		<string key="IBDocument.SystemVersion">9F33</string>
-		<string key="IBDocument.InterfaceBuilderVersion">674</string>
+		<string key="IBDocument.InterfaceBuilderVersion">672</string>
 		<string key="IBDocument.AppKitVersion">949.34</string>
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="348"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 		</object>
-		<object class="NSMutableDictionary" key="IBDocument.Metadata">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSArray" key="dict.sortedKeys">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-			<object class="NSMutableArray" key="dict.values">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-		</object>
 		<object class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<object class="NSCustomObject" id="815810918">
@@ -401,7 +391,7 @@
 				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSWindowContentMinSize">{320, 240}</string>
 				<object class="NSView" key="NSWindowView" id="941366957">
-					<reference key="NSNextResponder"/>
+					<nil key="NSNextResponder"/>
 					<int key="NSvFlags">256</int>
 					<object class="NSMutableArray" key="NSSubviews">
 						<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1217,7 +1207,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 					</object>
 					<string key="NSFrameSize">{484, 308}</string>
-					<reference key="NSSuperview"/>
 				</object>
 				<string key="NSScreenRect">{{0, 0}, {1280, 938}}</string>
 				<string key="NSMinSize">{320, 262}</string>
@@ -1333,7 +1322,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
 														<int key="NSCellFlags">75628032</int>
 														<int key="NSCellFlags2">0</int>
-														<string key="NSContents">Command</string>
+														<string key="NSContents">Name</string>
 														<reference key="NSSupport" ref="26"/>
 														<object class="NSColor" key="NSBackgroundColor" id="113872566">
 															<int key="NSColorSpace">3</int>
@@ -1370,7 +1359,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
 														<int key="NSCellFlags">75628032</int>
 														<int key="NSCellFlags2">0</int>
-														<string key="NSContents">Name</string>
+														<string key="NSContents">Command</string>
 														<reference key="NSSupport" ref="26"/>
 														<reference key="NSBackgroundColor" ref="113872566"/>
 														<reference key="NSTextColor" ref="249576247"/>
@@ -1453,7 +1442,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 									</object>
 									<string key="NSFrame">{{1, 17}, {301, 198}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
-									<reference key="NSNextKeyView" ref="905092943"/>
 									<reference key="NSDocView" ref="905092943"/>
 									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
@@ -1486,7 +1474,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 									</object>
 									<string key="NSFrame">{{1, 0}, {301, 17}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
-									<reference key="NSNextKeyView" ref="792419186"/>
 									<reference key="NSDocView" ref="792419186"/>
 									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
@@ -1495,7 +1482,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							</object>
 							<string key="NSFrame">{{20, 20}, {318, 231}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
-							<reference key="NSNextKeyView" ref="580565898"/>
 							<int key="NSsFlags">50</int>
 							<reference key="NSVScroller" ref="842897584"/>
 							<reference key="NSHScroller" ref="17278747"/>
@@ -3648,7 +3634,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{437, 749}, {484, 308}}</string>
 					<reference ref="9"/>
 					<string>{{184, 290}, {481, 345}}</string>
-					<boolean value="NO"/>
+					<integer value="0"/>
 					<reference ref="9"/>
 					<string>{3.40282e+38, 3.40282e+38}</string>
 					<string>{320, 240}</string>
diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib
index 0972124..16c7109 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib differ
commit 53d93d0d29f0bef6b2b7e312fb09e498b68636f9
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Dec 2 14:54:10 2008 -0800

    Removed unised option from configure.ac for launchd
    (cherry picked from commit 87e4de0a9a8af6e5e0cbba74e585761f1160a6ab)
    (cherry picked from commit 451050b1e2dc0f2f6356d74ddb6f52183a794e8f)

diff --git a/configure.ac b/configure.ac
index b7d9979..486dad8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -485,10 +485,6 @@ AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir
 				[ APPLE_APPLICATIONS_DIR="${withval}" ],
 				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
 AC_SUBST([APPLE_APPLICATIONS_DIR])
-AC_ARG_WITH(launchagents-dir,AS_HELP_STRING([--with-launchagents-dir=PATH], [Path to launchd's LaunchAgents directory (default: /Library/LaunchAgents)]),
-				[ launchagentsdir="${withval}" ],
-				[ launchagentsdir="/Library/LaunchAgents" ])
-AC_SUBST([launchagentsdir])
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
commit df3f23fe8d13be74e58c894c44683024a190b0f6
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Dec 2 14:53:21 2008 -0800

    XQuartz: pbproxy: Simplify linking
    (cherry picked from commit 909cc5c4dca0f63e90505575bbd454b46a4670cc)
    (cherry picked from commit cbb9ee57f8f29d2a1c39946381471fcd3b8e495e)

diff --git a/configure.ac b/configure.ac
index 2bfa296..b7d9979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1553,8 +1553,7 @@ if test "x$XQUARTZ" = xyes; then
 
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
 
-	PKG_CHECK_MODULES(APPLEWMPROTO, [applewmproto >= 1.1.1])
-	PKG_CHECK_MODULES(APPLEWM, [applewm >= 1.0.0])
+	PKG_CHECK_MODULES(XPBPROXY, [applewmproto >= 1.1.1] [applewm >= 1.0.0] xfixes fixesproto)
 
 	if test "x$STANDALONE_XPBPROXY" = xyes ; then
 		AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 65ee2fa..b4e7852 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -19,7 +19,7 @@ X11_LDADD = \
 	$(top_builddir)/dix/dixfonts.lo \
 	$(top_builddir)/miext/rootless/librootless.la \
 	$(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
-	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin -lX11
+	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
 X11_LDFLAGS =  \
 	-XCClinker -Objc \
diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index 65e5e4a..e1c537f 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -1,5 +1,5 @@
 AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
-AM_LDFLAGS=-L/usr/X11/lib -lX11 -lXfixes -lAppleWM -framework AppKit -framework Foundation -framework ApplicationServices
+AM_CFLAGS=$(XPBPROXY_CFLAGS)
 
 noinst_LTLIBRARIES = libxpbproxy.la
 libxpbproxy_la_SOURCES = \
@@ -8,6 +8,8 @@ libxpbproxy_la_SOURCES = \
 	x-input.m \
 	x-selection.m
 
+libxpbproxy_la_LDFLAGS=$(XPBPROXY_LIBS)
+
 if STANDALONE_XPBPROXY
 
 bin_PROGRAMS = xpbproxy
commit 6e8626f2eb31a3699bf49597974e01ea4757f31e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Dec 8 15:58:15 2008 +1000

    Xi: silence compiler warning
    
    Don't mix declarations and statements.
    (cherry picked from commit fb2a8d0e59a3d187255538f6add22ec67551507a)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 1b60099..6141f5e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -804,8 +804,8 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
                  *      dev = event
                  *      event = delta
                  */
-		axisvals = v->axisVal;
                 int delta;
+                axisvals = v->axisVal;
                 if (v->mode == Relative) /* device reports relative */
                     change = TRUE;
 
commit e56059dfa5f2835625b9f74a2af1f128d6eaf265
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Thu Dec 4 09:47:25 2008 +1000

    xfree86: fix compiler warning (use of uninitialized variable)
    
    drv and idev are only set for SDs, but are only dereferenced for SDs too, so
    initializing them to NULL is safe.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    (cherry picked from commit 8e3279134987a45f2a89c963ef2d33bc3d3c8179)

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 9558b77..94185da 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -650,8 +650,8 @@ _X_EXPORT void
 DeleteInputDeviceRequest(DeviceIntPtr pDev)
 {
     LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
-    InputDriverPtr drv;
-    IDevRec *idev;
+    InputDriverPtr drv = NULL;
+    IDevRec *idev = NULL;
     IDevPtr *it;
     Bool isMaster = pDev->isMaster;
 
commit 0d12c44d832b98da10dccc3b8bac7676d8ea2c96
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Mon Dec 1 16:57:06 2008 +1000

    xfree86: don't render SW cursors for devices attached to VCP (#16805)
    
    When leaving 3D games such as quake3 or sauerbraten, a cursor may stay on the
    screen. This is caused by one run of SW rendering for the SD, even though the
    SD was attached to the VCP and thus has HW rendering capabilities.
    
    Check for the SD's attachment (like in all other functions) before deciding on
    SW or HW rendering.
    
    X.Org Bug 16805 <http://bugs.freedesktop.org/show_bug.cgi?id=16805>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    (cherry picked from commit bb072019fa8dd292a50ef433d05caeefd1304a73)

diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index aea1d33..2b73b16 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -314,7 +314,8 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
 
     /* only update for VCP, otherwise we get cursor jumps when removing a
        sprite. The second cursor is never HW rendered anyway. */
-    if (pDev == inputInfo.pointer)
+    if (pDev == inputInfo.pointer ||
+        (!pDev->isMaster && pDev->u.master == inputInfo.pointer))
     {
 	ScreenPriv->CurrentCursor = pCurs;
 	ScreenPriv->x = x;
commit 63b3bf85ed4e11ace433e6aa21b311cce7144007
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Wed Dec 3 15:06:37 2008 +1000

    xkb: Allow NULL as rulesFile in XkbSetRulesDflts.
    
    If no rules file is given, simply re-use the previous one. If no RF is given
    the first time this function is called, use the built-in default.
    This includes fixing the built-in default to something that actually exists.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    (cherry picked from commit 463e02e7de5da3e582a3a049110a476713c7210e)

diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 0b93e87..3a0e375 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -93,7 +93,7 @@ typedef struct	_SrvXkmInfo {
 #define	XKB_BIN_DIRECTORY	XKB_BASE_DIRECTORY
 #endif
 #ifndef XKB_DFLT_RULES_FILE
-#define	XKB_DFLT_RULES_FILE	"rules"
+#define	XKB_DFLT_RULES_FILE	"base"
 #endif
 #ifndef XKB_DFLT_KB_LAYOUT
 #define	XKB_DFLT_KB_LAYOUT	"us"
@@ -240,14 +240,33 @@ XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
     return;
 }
 
+/**
+ * Set the default RMLVO for the next device to be initialised.
+ * If a parameter is NULL, the previous setting will be used. Use empty
+ * strings if you want to delete a previous setting.
+ *
+ * If @rulesFile is NULL and no previous @rulesFile has been set, the
+ * built-in default is chosen as default.
+ */
 _X_EXPORT void
 XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
 					char *variant,char *options)
 {
-    if (XkbRulesFile)
-	_XkbFree(XkbRulesFile);
-    XkbRulesFile= _XkbDupString(rulesFile);
-    rulesDefined= True;
+    if (!rulesFile && !XkbRulesFile)
+    {
+	LogMessage(X_WARNING, "[xkb] No rule given, and no previous rule "
+		              "defined. Defaulting to '%s'.\n",
+                              XKB_DFLT_RULES_FILE);
+	rulesFile = XKB_DFLT_RULES_FILE;
+    }
+
+    if (rulesFile) {
+	if (XkbRulesFile)
+	    _XkbFree(XkbRulesFile);
+	XkbRulesFile= _XkbDupString(rulesFile);
+	rulesDefined= True;
+    }
+
     if (model) {
 	if (XkbModelDflt)
 	    _XkbFree(XkbModelDflt);
commit 9a44cc619f3296b0faca97b0959e19c208f143bb
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Dec 8 14:16:00 2008 +1000

    Xi: don't update VCP's valuators from DeviceValuator events #18882
    
    The VCP doesn't need to update the valuators anyway since it cannot send XI
    events. Just skip that bit.
    
    X.Org Bug 18882 <http://bugs.freedesktop.org/show_bug.cgi?id=18882>
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index a976802..1b60099 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -781,12 +781,14 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
     }
 
     /* Update device axis */
-    for (i = 1; i < count; i++) {
+    /* Don't update valuators for the VCP, it never sends XI events anyway */
+    for (i = 1; !device->isMaster && i < count; i++) {
 	if ((++xV)->type == DeviceValuator) {
 	    int *axisvals;
             int first = xV->first_valuator;
             BOOL change = FALSE;
 
+
 	    if (xV->num_valuators &&
                 (!v || (xV->num_valuators &&
                       (first + xV->num_valuators > v->numAxes))))
@@ -1009,7 +1011,9 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
     }
 
     /* Valuator event handling */
-    for (i = 1; i < count; i++) {
+    /* Don't care about valuators for the VCP, it never sends XI events */
+
+    for (i = 1; !device->isMaster && i < count; i++) {
 	if ((++xV)->type == DeviceValuator) {
 	    int first = xV->first_valuator;
 	    if (xV->num_valuators
commit c7fffe9e1354f816b6e2adedff045999fba9f1be
Author: Stuart Bennett <sb476 at cam.ac.uk>
Date:   Fri Dec 12 00:08:44 2008 +0000

    dolt: allow older versions of bash to compile the xserver (#19031)
    
    Signed-off-by: James Cloos <cloos at jhcloos.com>
    (cherry picked from commit 7be6520d94df874c6bbd46d06a1830a12d0967f2)

diff --git a/acinclude.m4 b/acinclude.m4
index efece2a..c3e36f8 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -157,7 +157,7 @@ for arg in "$[]@"; do
     case "$arg" in
         --mode=compile) modeok=true ;;
         --tag=CC|--tag=CXX) tagok=true ;;
-        *) args+=("$arg")
+        *) args@<:@${#args[@]}@:>@="$arg" ;;
     esac
 done
 if $modeok && $tagok ; then
commit ca56d764d2be28c64fe15c9e37d534ef00117ad2
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Dec 10 16:13:20 2008 -0500

    xsync: Fix wakeup storm in idletime counter.
    
    Wakeup scheduling only considered the threshold values, and not whether
    the trigger was edge or level.
    
    See also:
    https://bugzilla.redhat.com/show_bug.cgi?id=474586
    http://svn.gnome.org/viewvc/gnome-screensaver/trunk/src/test-idle-ext.c?view=markup
    (cherry picked from commit 1f4fb0225b278d1cf4145aebeb0bdd23dc8f62d5)

diff --git a/Xext/sync.c b/Xext/sync.c
index 63f6fa2..1b37366 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2533,7 +2533,7 @@ SyncInitServerTime(void)
  * IDLETIME implementation
  */
 
-static pointer IdleTimeCounter;
+static SyncCounter *IdleTimeCounter;
 static XSyncValue *pIdleTimeValueLess;
 static XSyncValue *pIdleTimeValueGreater;
 
@@ -2545,38 +2545,69 @@ IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
 }
 
 static void
-IdleTimeBlockHandler (pointer env,
-                      struct timeval **wt,
-                      pointer LastSelectMask)
+IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
 {
-    XSyncValue idle;
+    XSyncValue idle, old_idle;
+    SyncTriggerList *list = IdleTimeCounter->pTriglist;
+    SyncTrigger *trig;
 
     if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
 	return;
 
+    old_idle = IdleTimeCounter->value;
     IdleTimeQueryValue (NULL, &idle);
+    IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
 
     if (pIdleTimeValueLess &&
         XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
     {
-	AdjustWaitForDelay (wt, 0);
+	/*
+	 * We've been idle for less than the threshold value, and someone
+	 * wants to know about that, but now we need to know whether they
+	 * want level or edge trigger.  Check the trigger list against the
+	 * current idle time, and if any succeed, bomb out of select()
+	 * immediately so we can reschedule.
+	 */
+
+	for (list = IdleTimeCounter->pTriglist; list; list = list->next) {
+	    trig = list->pTrigger;
+	    if (trig->CheckTrigger(trig, old_idle)) {
+		AdjustWaitForDelay(wt, 0);
+		break;
+	    }
+	}
     }
     else if (pIdleTimeValueGreater)
     {
-	unsigned long timeout = 0;
+	/*
+	 * There's a threshold in the positive direction.  If we've been
+	 * idle less than it, schedule a wakeup for sometime in the future.
+	 * If we've been idle more than it, and someone wants to know about
+	 * that level-triggered, schedule an immediate wakeup.
+	 */
+	unsigned long timeout = -1;
 
-	if (XSyncValueLessThan (idle, *pIdleTimeValueGreater))
-	{
+	if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) {
 	    XSyncValue value;
 	    Bool overflow;
 
 	    XSyncValueSubtract (&value, *pIdleTimeValueGreater,
 	                        idle, &overflow);
-	    timeout = XSyncValueLow32 (value);
+	    timeout = min(timeout, XSyncValueLow32 (value));
+	} else {
+	    for (list = IdleTimeCounter->pTriglist; list; list = list->next) {
+		trig = list->pTrigger;
+		if (trig->CheckTrigger(trig, old_idle)) {
+		    timeout = min(timeout, 0);
+		    break;
+		}
+	    }
 	}
 
 	AdjustWaitForDelay (wt, timeout);
     }
+
+    IdleTimeCounter->value = old_idle; /* pop */
 }
 
 static void
commit a82f10c5dd9fa74ff18759ab288bbd9c8b7ac4de
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Dec 8 17:42:47 2008 -0500

    randr: clear primaryOutput when the output is deleted
    (cherry picked from commit 86c64ddf21763972aa7fc8c5770259123c9907b3)

diff --git a/randr/rroutput.c b/randr/rroutput.c
index 48b5700..82c2530 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -380,6 +380,9 @@ RROutputDestroyResource (pointer value, XID pid)
     {
 	rrScrPriv(pScreen);
 	int		i;
+
+	if (pScrPriv->primaryOutput == output)
+	    pScrPriv->primaryOutput = NULL;
     
 	for (i = 0; i < pScrPriv->numOutputs; i++)
 	{
commit 2bc53ce66828b6c177e3298fa2f326c77c93e136
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Dec 8 17:40:07 2008 -0500

    randr: use primary output for RRFirstOutput()
    (cherry picked from commit fe65f400ed16cb39db8c9518b9446f590c34db1a)

diff --git a/randr/randr.c b/randr/randr.c
index 230d816..2e482f0 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -438,6 +438,9 @@ RRFirstOutput (ScreenPtr pScreen)
     RROutputPtr		    output;
     int	i, j;
     
+    if (pScrPriv->primaryOutput)
+	return pScrPriv->primaryOutput;
+
     for (i = 0; i < pScrPriv->numCrtcs; i++)
     {
 	RRCrtcPtr   crtc = pScrPriv->crtcs[i];
commit f0234a9eb88ed103bca7db73a833c472ab95b48f
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Dec 8 17:37:17 2008 -0500

    randr: Mangle GetScreenResources sort order based on primary output
    (cherry picked from commit cdcb516e561e2f65eb2fa523ca001c57674d5caf)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 7a8f2eb..9b1024e 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -324,7 +324,7 @@ rrGetScreenResources(ClientPtr client, Bool query)
     rrScrPrivPtr		pScrPriv;
     CARD8			*extra;
     unsigned long		extraLen;
-    int				i, n, rc;
+    int				i, n, rc, has_primary;
     RRCrtc			*crtcs;
     RROutput			*outputs;
     xRRModeInfo			*modeinfos;
@@ -401,12 +401,23 @@ rrGetScreenResources(ClientPtr client, Bool query)
 	outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
 	modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
 	names = (CARD8 *) (modeinfos + num_modes);
+
+	has_primary = (pScrPriv->primaryOutput != NULL);
+	if (pScrPriv->primaryOutput)
+	{
+	    crtcs[0] = pScrPriv->primaryOutput->id;
+	    if (client->swapped)
+		swapl (&crtcs[0], n);
+	}
 	
 	for (i = 0; i < pScrPriv->numCrtcs; i++)
 	{
-	    crtcs[i] = pScrPriv->crtcs[i]->id;
+	    if (pScrPriv->primaryOutput &&
+		pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
+		continue;
+	    crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
 	    if (client->swapped)
-		swapl (&crtcs[i], n);
+		swapl (&crtcs[i + has_primary], n);
 	}
 	
 	for (i = 0; i < pScrPriv->numOutputs; i++)
commit 2ef02833d614c42693e019a444560e84f501b5dc
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Dec 8 17:28:55 2008 -0500

    randr: Mangle compat Xinerama reply based on primary output
    (cherry picked from commit d7b316e82bc7051f8829b4f4a640f50ae91c2db9)

diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 544666f..ad40a1e 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -260,6 +260,30 @@ ProcRRXineramaIsActive(ClientPtr client)
     return client->noClientException;
 }
 
+static void
+RRXineramaWriteCrtc(ClientPtr client, RRCrtcPtr crtc)
+{
+    xXineramaScreenInfo scratch;
+
+    if (RRXineramaCrtcActive (crtc))
+    {
+	int width, height;
+	RRCrtcGetScanoutSize (crtc, &width, &height);
+	scratch.x_org  = crtc->x;
+	scratch.y_org  = crtc->y;
+	scratch.width  = width;
+	scratch.height = height;
+	if(client->swapped) {
+	    register int n;
+	    swaps(&scratch.x_org, n);
+	    swaps(&scratch.y_org, n);
+	    swaps(&scratch.width, n);
+	    swaps(&scratch.height, n);
+	}
+	WriteToClient(client, sz_XineramaScreenInfo, &scratch);
+    }
+}
+
 int
 ProcRRXineramaQueryScreens(ClientPtr client)
 {
@@ -291,26 +315,16 @@ ProcRRXineramaQueryScreens(ClientPtr client)
 	rrScrPriv(pScreen);
 	xXineramaScreenInfo scratch;
 	int i;
+	int has_primary = (pScrPriv->primaryOutput != NULL);
+
+	if (has_primary) {
+	    RRXineramaWriteCrtc(client, pScrPriv->primaryOutput->crtc);
+	}
 
 	for(i = 0; i < pScrPriv->numCrtcs; i++) {
 	    RRCrtcPtr	crtc = pScrPriv->crtcs[i];
-	    if (RRXineramaCrtcActive (crtc))
-	    {
-	        int width, height;
-		RRCrtcGetScanoutSize (crtc, &width, &height);
-		scratch.x_org  = crtc->x;
-		scratch.y_org  = crtc->y;
-		scratch.width  = width;
-		scratch.height = height;
-		if(client->swapped) {
-		    register int n;
-		    swaps(&scratch.x_org, n);
-		    swaps(&scratch.y_org, n);
-		    swaps(&scratch.width, n);
-		    swaps(&scratch.height, n);
-		}
-		WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
-	    }
+	    if (!has_primary || (crtc != pScrPriv->primaryOutput->crtc))
+		RRXineramaWriteCrtc(client, crtc);
 	}
     }
 
commit 0bdfdaa7df8105c7ffc3248a4fdd5f64da67103c
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Dec 9 10:51:37 2008 -0500

    randr: Add [GS]etOutputPrimary
    (cherry picked from commit 9d58d2a319059989ccdfa758f586149ccdc16df6)

diff --git a/randr/randrstr.h b/randr/randrstr.h
index f6aa5c7..b5cebdc 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -2,6 +2,7 @@
  * Copyright © 2000 Compaq Computer Corporation
  * Copyright © 2002 Hewlett-Packard Company
  * Copyright © 2006 Intel Corporation
+ * Copyright © 2008 Red Hat, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -272,6 +273,7 @@ typedef struct _rrScrPriv {
 
     int			    numOutputs;
     RROutputPtr		    *outputs;
+    RROutputPtr		    primaryOutput;
 
     int			    numCrtcs;
     RRCrtcPtr		    *crtcs;
@@ -822,6 +824,12 @@ RROutputDestroy (RROutputPtr	output);
 int
 ProcRRGetOutputInfo (ClientPtr client);
 
+extern int
+ProcRRSetOutputPrimary (ClientPtr client);
+
+extern int
+ProcRRGetOutputPrimary (ClientPtr client);
+
 /*
  * Initialize output type
  */
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 0cc0bca..5a2ea71 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -217,5 +217,7 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
     ProcRRGetCrtcTransform,	/* 27 */
     ProcRRGetPanning,		/* 28 */
     ProcRRSetPanning,		/* 29 */
+    ProcRRSetOutputPrimary,	/* 30 */
+    ProcRRGetOutputPrimary,	/* 31 */
 };
 
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 1ecde31..48b5700 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -1,5 +1,6 @@
 /*
  * Copyright © 2006 Keith Packard
+ * Copyright © 2008 Red Hat, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -426,7 +427,7 @@ RROutputInit (void)
 }
 
 #define OutputInfoExtra	(SIZEOF(xRRGetOutputInfoReply) - 32)
-				
+
 int
 ProcRRGetOutputInfo (ClientPtr client)
 {
@@ -533,3 +534,109 @@ ProcRRGetOutputInfo (ClientPtr client)
     
     return client->noClientException;
 }
+
+void
+RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv,
+		   RROutputPtr output)
+{
+    if (pScrPriv->primaryOutput == output)
+	return;
+
+    /* clear the old primary */
+    if (pScrPriv->primaryOutput) {
+	RROutputChanged(pScrPriv->primaryOutput, 0);
+	pScrPriv->primaryOutput = NULL;
+    }
+
+    /* set the new primary */
+    if (output) {
+	pScrPriv->primaryOutput = output;
+	RROutputChanged(output, 0);
+    }
+
+    pScrPriv->layoutChanged = TRUE;
+
+    RRTellChanged(pScreen);
+}
+
+int
+ProcRRSetOutputPrimary(ClientPtr client)
+{
+    REQUEST(xRRSetOutputPrimaryReq);
+    RROutputPtr output = NULL;
+    WindowPtr pWin;
+    rrScrPrivPtr pScrPriv;
+
+    REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
+
+    pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
+				  DixReadAccess);
+
+    if (!pWin) {
+	client->errorValue = stuff->window;
+	return BadWindow;
+    }
+
+    if (stuff->output) {
+	output = LookupOutput(client, stuff->output, DixReadAccess);
+
+	if (!output) {
+	    client->errorValue = stuff->output;
+	    return RRErrorBase + BadRROutput;
+	}
+
+	if (output->crtc) {
+	    client->errorValue = stuff->output;
+	    return BadMatch;
+	}
+
+	if (output->pScreen != pWin->drawable.pScreen) {
+	    client->errorValue = stuff->window;
+	    return BadMatch;
+	}
+    }
+
+    pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
+    RRSetPrimaryOutput(pWin->drawable.pScreen, pScrPriv, output);
+
+    return client->noClientException;
+}
+
+int
+ProcRRGetOutputPrimary(ClientPtr client)
+{
+    REQUEST(xRRGetOutputPrimaryReq);
+    WindowPtr pWin;
+    rrScrPrivPtr pScrPriv;
+    xRRGetOutputPrimaryReply rep;
+    RROutputPtr primary = NULL;
+
+    REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
+
+    pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
+				  DixReadAccess);
+
+    if (!pWin) {
+	client->errorValue = stuff->window;
+	return BadWindow;
+    }
+
+    pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
+    if (pScrPriv)
+	primary = pScrPriv->primaryOutput;
+
+    memset(&rep, 0, sizeof(rep));
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.output = primary ? primary->id : None;
+
+    if (client->swapped) {
+	int n;
+	swaps(&rep.sequenceNumber, n);
+	swapl(&rep.output, n);
+    }
+
+    WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep);
+
+    return client->noClientException;
+}
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 3ff9f3f..9fbf8f0 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -436,6 +436,31 @@ SProcRRSetPanning (ClientPtr client)
     return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
+static int
+SProcRRSetOutputPrimary (ClientPtr client)
+{
+    int n;
+    REQUEST(xRRSetOutputPrimaryReq);
+
+    REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+    swapl(&stuff->output, n);
+    return ProcRandrVector[stuff->randrReqType](client);
+}
+
+static int
+SProcRRGetOutputPrimary (ClientPtr client)
+{
+    int n;
+    REQUEST(xRRSetOutputPrimaryReq);
+
+    REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+    return ProcRandrVector[stuff->randrReqType](client);
+}
+
 int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
     SProcRRQueryVersion,	/* 0 */
 /* we skip 1 to make old clients fail pretty immediately */
@@ -472,5 +497,7 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
     SProcRRGetCrtcTransform,	/* 27 */
     SProcRRGetPanning,		/* 28 */
     SProcRRSetPanning,		/* 29 */
+    SProcRRSetOutputPrimary,	/* 30 */
+    SProcRRGetOutputPrimary,	/* 31 */
 };
 
commit 09039fb89f3fd047f10b575e019bba6762448456
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 15 19:53:45 2008 -0800

    Patch brown-bag fix for bug 19017 (scrn->virtualX/virtualY 0 before PreInit)
    
    When a driver uses a crtc during device detection, the scrn has not yet been
    configured and virtualX/virtualY are still zero. This caused the X server
    to try and allocate a shadow frame buffer, which couldn't work.
    
    Detect this by checking for zero virtualX/virtualY values.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 063eb6743cd0d98dd52d1a9559b804381ee5144d)

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 88b4bdc..65a553e 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -366,6 +366,12 @@ xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
     ScrnInfoPtr		pScrn = crtc->scrn;
     BoxRec		b;
 
+    /* When called before PreInit, the driver is
+     * presumably doing load detect
+     */
+    if (pScrn->virtualX == 0 || pScrn->virtualY == 0)
+	return TRUE;
+
     b.x1 = 0;
     b.y1 = 0;
     b.x2 = crtc->mode.HDisplay;
commit ae2cbbff9fa0f458e133bf1894d8a7f9fb3fbb72
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 15 11:39:24 2008 -0800

    Use scrn->virtualX/virtualY in xf86CrtcFitsScreen. Fix bug 19017.
    
    pScreen->width/height are not initialized when doing initial mode setting,
    which makes this function incorrectly fail. Using scrn->virtualX should work
    in all cases though.
    
    Bug 19017 reports a crash in xf86CrtcSetModeTransform when doing a modeset
    for output probing, long before the screen array is initialized; that was
    caused by a work-around to set pScreen->width/height so that xf86CrtcFitsScreen
    could find the right values.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit fde2f961035609cfff8761ef1e0f23e6a9761be2)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index d3059d7..78105b6 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -244,8 +244,6 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
 			  RRTransformPtr transform, int x, int y)
 {
     ScrnInfoPtr		scrn = crtc->scrn;
-    /* During ScreenInit() scrn->pScreen is still NULL */
-    ScreenPtr		pScreen = screenInfo.screens[scrn->scrnIndex];
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int			i;
     Bool		ret = FALSE;
@@ -295,11 +293,6 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
     } else
 	crtc->transformPresent = FALSE;
 
-    /* xf86CrtcFitsScreen() relies on these values being correct. */
-    /* This should ensure the values are always set at modeset time. */
-    pScreen->width = scrn->virtualX;
-    pScreen->height = scrn->virtualY;
-
     /* Shift offsets that move us out of virtual size */
     if (x + mode->HDisplay > xf86_config->maxWidth ||
 	y + mode->VDisplay > xf86_config->maxHeight)
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 73a235b..88b4bdc 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -364,12 +364,8 @@ static Bool
 xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
 {
     ScrnInfoPtr		pScrn = crtc->scrn;
-    /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
-    ScreenPtr		pScreen = screenInfo.screens[pScrn->scrnIndex];
     BoxRec		b;
 
-    if (!pScreen)
-	return TRUE;
     b.x1 = 0;
     b.y1 = 0;
     b.x2 = crtc->mode.HDisplay;
@@ -383,8 +379,8 @@ xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
 	b.y2 += crtc->y;
     }
 
-    return (0 <= b.x1 && b.x2 <= pScreen->width &&
-	    0 <= b.y1 && b.y2 <= pScreen->height);
+    return (0 <= b.x1 && b.x2 <= pScrn->virtualX &&
+	    0 <= b.y1 && b.y2 <= pScrn->virtualY);
 }
 
 _X_EXPORT Bool
commit 6d671b2dee7d2e5481399f0bdb3323a0250a075d
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 15 11:38:00 2008 -0800

    When disabling SIGIO tracking, use SIG_IGN instead of SIG_DFL.
    
    This avoids a race condition for drivers which mis-order the fd close and
    signal disable.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 29a5b0596b396d3e4a8a014cacd3e3ef77467ab7)

diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
index f51131c..92bdd29 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -229,7 +229,7 @@ xf86RemoveSIGIOHandler(int fd)
 	    sigemptyset(&sa.sa_mask);
 	    sigaddset(&sa.sa_mask, SIGIO);
 	    sa.sa_flags   = 0;
-	    sa.sa_handler = SIG_DFL;
+	    sa.sa_handler = SIG_IGN;
 	    sigaction(SIGIO, &sa, &osa);
 	}
     }
commit 8f17a31aa721e42925cd6b4616ccad90497818f3
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 15 11:36:43 2008 -0800

    Clean up rotation data when crtc is turned off
    
    The shadow frame buffer and other data used for rotation need to be freed
    when the crtc is disabled, not just when rotation is disabled.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 1ba4cbb15919759aadd71960c5c057af9ba94fe3)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 9717620..d3059d7 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2684,6 +2684,7 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
 	{
 	    crtc->funcs->dpms(crtc, DPMSModeOff);
 	    memset(&crtc->mode, 0, sizeof(crtc->mode));
+	    xf86RotateDestroy(crtc);
 	}
     }
     if (pScrn->pScreen)
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 5e47e6f..a2ea2ec 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -704,6 +704,13 @@ Bool
 xf86CrtcRotate (xf86CrtcPtr crtc);
 
 /*
+ * Clean up any rotation data, used when a crtc is turned off
+ * as well as when rotation is disabled.
+ */
+void
+xf86RotateDestroy (xf86CrtcPtr crtc);
+
+/*
  * free shadow memory allocated for all crtcs
  */
 void
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index d7f7b3b..73a235b 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -294,7 +294,7 @@ xf86RotateBlockHandler(int screenNum, pointer blockData,
     }
 }
 
-static void
+void
 xf86RotateDestroy (xf86CrtcPtr crtc)
 {
     ScrnInfoPtr		pScrn = crtc->scrn;


More information about the xorg-commit mailing list