xserver: Branch 'server-1.6-branch' - 34 commits

Keith Packard keithp at kemper.freedesktop.org
Fri Jan 9 11:08:38 PST 2009


 configure.ac                           |   15 ---
 dix/devices.c                          |    2 
 dix/getevents.c                        |    4 -
 exa/exa.c                              |    6 +
 exa/exa_unaccel.c                      |    4 -
 hw/xfree86/common/xf86Xinput.c         |   12 ++-
 hw/xfree86/modes/xf86RandR12.c         |    8 +-
 hw/xfree86/os-support/linux/lnx_init.c |    6 +
 hw/xfree86/xaa/xaaInitAccel.c          |    9 +-
 hw/xquartz/X11Application.m            |  106 ++++++++++++++++++++-------
 hw/xquartz/X11Controller.m             |   30 +------
 hw/xquartz/bundle/Info.plist.cpp       |    6 -
 hw/xquartz/bundle/X11.sh               |   16 +++-
 hw/xquartz/bundle/mk_bundke.sh         |    2 
 hw/xquartz/darwinEvents.c              |   11 ++
 hw/xquartz/doc/Xquartz.man.pre         |    6 +
 hw/xquartz/mach-startup/Makefile.am    |   17 ++--
 hw/xquartz/mach-startup/bundle-main.c  |   32 +-------
 hw/xquartz/pbproxy/main.m              |   29 ++++++-
 hw/xquartz/pbproxy/pbproxy.h           |    2 
 hw/xquartz/pbproxy/x-input.m           |  125 ++++++++++++++-------------------
 hw/xquartz/quartz.c                    |   25 +++---
 hw/xquartz/quartzKeyboard.c            |   30 ++++++-
 hw/xquartz/xpr/xprScreen.c             |    4 -
 include/dix-config-post-verbatim.h     |   10 ++
 include/dix-config.h.in                |   15 ---
 include/input.h                        |    5 +
 include/xorg-server.h.in               |   13 ---
 mi/mieq.c                              |   70 +++++++++---------
 miext/rootless/rootlessWindow.c        |    7 +
 os/connection.c                        |    4 -
 os/log.c                               |    5 -
 xkb/ddxDevBtn.c                        |   15 ++-
 33 files changed, 349 insertions(+), 302 deletions(-)

New commits:
commit 1ffd9ec7606606570980490b91b780e02bc29d7d
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Dec 16 17:10:03 2008 +1000

    xfree86: don't restore the TTY mode if we didn't initialize it ourselves
    
    Restoring it unconditionally means we restore to whatever tty_mode has as
    default value (i.e. 0). K_RAW happens to be 0x00, so we always restore to raw
    mode if allowEmptyInput is off.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    (cherry picked from commit aea6f19f25e13768b1d09fac4991d6a5e6c2cdac)

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index da5ca57..6ee8ed6 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -376,8 +376,10 @@ xf86CloseConsole()
 	xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
 		strerror(errno));
 
-    ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
-    tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+    if (xf86Info.allowEmptyInput) {
+	ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
+	tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+    }
 
     if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) 
 	xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
commit 3c11efd7dc09aa92039f851c2bbf2ca6b5a5ac8c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Dec 23 09:59:28 2008 +1000

    xfree86: If an input device failed to activate, return immediately.
    
    Devices are only activated once - right after they've been added to the
    server. If a device failes activation, it's dead. There's no reason to
    continue. Return the error code from ActivateDevice() without setting up
    sprite information or even sending a event to the client.
    
    Then - in the DDX - just remove the device again.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 27011254c4de4e573a0851bf46892fb488db6522)

diff --git a/dix/devices.c b/dix/devices.c
index f7fef95..6b05050 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -446,6 +446,8 @@ ActivateDevice(DeviceIntPtr dev)
 
     ret = (*dev->deviceProc) (dev, DEVICE_INIT);
     dev->inited = (ret == Success);
+    if (!dev->inited)
+        return ret;
 
     /* Initialize memory for sprites. */
     if (dev->isMaster && dev->spriteInfo->spriteOwner)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 73c098e..96352a4 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -541,7 +541,10 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
     }
 
     dev = pInfo->dev;
-    ActivateDevice(dev);
+    rval = ActivateDevice(dev);
+    if (rval != Success)
+        goto unwind;
+
     /* Enable it if it's properly initialised and we're currently in the VT */
     if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
     {
commit 2ce48363b862db134624797bc071f8c45323a075
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Dec 23 10:00:34 2008 +1000

    xfree86: don't call CheckMotion if a device hasn't been enabled. #19176
    
    X.Org Bug <http://bugs.freedesktop.org/show_bug.cgi?id=19176>
    (cherry picked from commit e1a3a1a0d85c9971aea65c2228b5fd4dbf3bf57a)

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 94185da..73c098e 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -544,10 +544,11 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
     ActivateDevice(dev);
     /* Enable it if it's properly initialised and we're currently in the VT */
     if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
+    {
         EnableDevice(dev);
-
-    /* send enter/leave event, update sprite window */
-    CheckMotion(NULL, dev);
+        /* send enter/leave event, update sprite window */
+        CheckMotion(NULL, dev);
+    }
 
     *pdev = dev;
     return Success;
commit 3225e1378e3929e538941bbfc9ec495638bd407a
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Dec 26 15:51:55 2008 +0100

    exa: preparing as source and finishing access as mask is a bad idea
    (cherry picked from commit 027b440d4f9f0cdd46addff46fd2d5c44cd5c847)

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 64c06c7..c030486 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -57,9 +57,9 @@ void
 exaFinishAccessGC(GCPtr pGC)
 {
     if (pGC->fillStyle == FillTiled)
-	exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_MASK);
+	exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
     if (pGC->stipple)
-        exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
+        exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_MASK);
 }
 
 #if DEBUG_TRACE_FALL
commit 2056c10d12f6b4facf628b861230f9b0a13f3a73
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Dec 26 16:38:27 2008 +0100

    exa: Allow drivers to set non-NULL devPrivate.ptr for !offscreen pixmaps.
    (cherry picked from commit 3534a5e5d9c5af85149c799f324257f89507fa23)

diff --git a/exa/exa.c b/exa/exa.c
index 6dfde4c..9b7091d 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -314,6 +314,11 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
 
         datasize = h * paddedWidth;
 
+	/* Set this before driver hooks, to allow for !offscreen pixmaps.
+	 * !offscreen pixmaps have a valid pointer at all times.
+	 */
+	pPixmap->devPrivate.ptr = NULL;
+
         pExaPixmap->driverPriv = pExaScr->info->CreatePixmap(pScreen, datasize, 0);
         if (!pExaPixmap->driverPriv) {
              fbDestroyPixmap(pPixmap);
@@ -326,7 +331,6 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
         pExaPixmap->fb_ptr = NULL;
         pExaPixmap->pDamage = NULL;
         pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr;
-        pPixmap->devPrivate.ptr = NULL;
 
     } else {
         pExaPixmap->driverPriv = NULL;
commit 4130761f151ff5414694472e1dc29d8f2893f10e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Jan 7 10:56:26 2009 -0800

    XQuartz: Fat binary buildfixes
    
    Let Xarch.h set X_BYTE_ORDER for us.
    Determine _XSERVER64 at build time.
    (cherry picked from commit f54736c2b0b537c8322ecb2db8e9cee5eea68165)
    (cherry picked from commit cc677cb4f458f371a4012ce0dc1121a52a2cb699)

diff --git a/configure.ac b/configure.ac
index f0223a5..c222c95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1182,19 +1182,6 @@ AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
 AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))
 
 XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC"
-AC_DEFINE_UNQUOTED(_X_BYTE_ORDER,[$ENDIAN],[Endian order])
-AH_VERBATIM([X_BYTE_ORDER],[
-/* Deal with multiple architecture compiles on Mac OS X */
-#ifndef __APPLE_CC__
-#define X_BYTE_ORDER _X_BYTE_ORDER
-#else
-#ifdef __BIG_ENDIAN__
-#define X_BYTE_ORDER X_BIG_ENDIAN
-#else
-#define X_BYTE_ORDER X_LITTLE_ENDIAN
-#endif
-#endif
-])
 
 dnl ---------------------------------------------------------------------------
 dnl DDX section.
diff --git a/include/dix-config-post-verbatim.h b/include/dix-config-post-verbatim.h
new file mode 100644
index 0000000..4bbb9b0
--- /dev/null
+++ b/include/dix-config-post-verbatim.h
@@ -0,0 +1,10 @@
+/* Do not include this file directly.  It is included at the end of <dix-config.h> */
+
+/* Correctly set _XSERVER64 for OSX fat binaries */
+#ifdef __APPLE__
+#if defined(__LP64__) && !defined(_XSERVER64)
+#define _XSERVER64 1
+#elif !defined(__LP64__) && defined(_XSERVER64)
+#undef _XSERVER64
+#endif
+#endif
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 65b5950..977bff3 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -363,19 +363,6 @@
 /* Vendor name */
 #undef XVENDORNAME
 
-/* Endian order */
-#undef _X_BYTE_ORDER
-/* Deal with multiple architecture compiles on Mac OS X */
-#ifndef __APPLE_CC__
-#define X_BYTE_ORDER _X_BYTE_ORDER
-#else
-#ifdef __BIG_ENDIAN__
-#define X_BYTE_ORDER X_BIG_ENDIAN
-#else
-#define X_BYTE_ORDER X_LITTLE_ENDIAN
-#endif
-#endif
-
 /* Enable GNU and other extensions to the C environment for GLIBC */
 #undef _GNU_SOURCE
 
@@ -442,4 +429,6 @@
 /* Define to 1 if you have the `ffs' function. */
 #undef HAVE_FFS
 
+#include <dix-config-post-verbatim.h>
+
 #endif /* _DIX_CONFIG_H_ */
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index b8803e7..4cf1bbf 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -145,19 +145,6 @@
 /* Vendor name */
 #undef XVENDORNAME
 
-/* Endian order */
-#undef _X_BYTE_ORDER
-/* Deal with multiple architecture compiles on Mac OS X */
-#ifndef __APPLE_CC__
-#define X_BYTE_ORDER _X_BYTE_ORDER
-#else
-#ifdef __BIG_ENDIAN__
-#define X_BYTE_ORDER X_BIG_ENDIAN
-#else
-#define X_BYTE_ORDER X_LITTLE_ENDIAN
-#endif
-#endif
-
 /* BSD-compliant source */
 #undef _BSD_SOURCE
 
commit 2eb09af56179d570a6d52b65c2029a2b62dcdff3
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Nov 16 15:35:17 2008 -0800

    XQuartz: Use AvailabilityMacros.h instead of availability.h for Tiger
    (cherry picked from commit 91f3c3435716195e6d606c8e2f6b0de52eb5972d)
    (cherry picked from commit 65ab2f44ea7fc4d87e021bed548eda81fc3cbae7)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2cebd2a..ec58ab1 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -47,7 +47,7 @@
 
 #include <mach/mach.h>
 #include <unistd.h>
-#include <available.h>
+#include <AvailabilityMacros.h>
 
 #include <Xplugin.h>
 
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 563b7b5..945f01e 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -44,7 +44,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/stat.h>
-#include <available.h>
+#include <AvailabilityMacros.h>
 
 #include "quartzCommon.h"
 #include "darwin.h"
commit fecc82ee1147cb314725ac774525a18a861ed719
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 2 11:06:12 2009 -0800

    XQuartz: Copyright Update... happy new year
    (cherry picked from commit 9f1c26ae8d9ccf81cba0ab946326968a701f8c36)
    (cherry picked from commit df6ca888b0c04fdf4ff2d7fb4a414275b983ed34)

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 16434f2..47018fd 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -27,9 +27,9 @@
 	<key>CSResourcesFileMapped</key>
 		<true/>
 	<key>NSHumanReadableCopyright</key>
-		<string>Copyright © 2003-2008, Apple Inc.
+		<string>Copyright © 2003-2009, Apple Inc.
 Copyright © 2003, XFree86 Project, Inc.
-Copyright © 2003-2008, X.org Foundation, Inc.
+Copyright © 2003-2009, X.org Foundation, Inc.
 </string>
 	<key>NSMainNibFile</key>
 		<string>main</string>
commit d80e35a9ae507ad742f97ca7254314ff28371688
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 2 10:58:40 2009 -0800

    XQuartz: pbproxy: Push dpy init and CFRunLoop hook setup into the pbproxy thread to avoid possible deadlock
    (cherry picked from commit 49e59d32b88e4fad070f230b5efaa261b47f78db)
    (cherry picked from commit adbfd49da2453b58a9e13b09c62e0611ea1c3f77)

diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 247ff74..5bc5182 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -68,7 +68,20 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
     return 0;
 }
 
-BOOL xpbproxy_init (void) {
+static inline pthread_t create_thread(void *func, void *arg) {
+    pthread_attr_t attr;
+    pthread_t tid;
+    
+    pthread_attr_init(&attr);
+    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    pthread_create(&tid, &attr, func, arg);
+    pthread_attr_destroy(&attr);
+    
+    return tid;
+}
+
+static void *xpbproxy_x_thread(void *args) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     size_t i;
 
@@ -89,7 +102,7 @@ BOOL xpbproxy_init (void) {
     if (xpbproxy_dpy == NULL) {
         fprintf (stderr, "xpbproxy: can't open default display\n");
         [pool release];
-        return FALSE;
+        return NULL;
     }
     
     XSetIOErrorHandler (x_io_error_handler);
@@ -99,7 +112,7 @@ BOOL xpbproxy_init (void) {
                                  &xpbproxy_apple_wm_error_base)) {
         fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
         [pool release];
-        return FALSE;
+        return NULL;
     }
     
     xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
@@ -111,11 +124,17 @@ BOOL xpbproxy_init (void) {
     
     if(!xpbproxy_input_register()) {
         [pool release];
-        return FALSE;
+        return NULL;
     }
 
     [pool release];
-    
+ 
+    xpbproxy_input_loop();
+    return NULL;
+}
+
+BOOL xpbproxy_init (void) {
+    create_thread(xpbproxy_x_thread, NULL);
     return TRUE;
 }
 
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index d24d08b..a6798ef 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -76,6 +76,7 @@ extern BOOL xpbproxy_have_xfixes;
 
 /* from x-input.m */
 extern BOOL xpbproxy_input_register (void);
+extern void xpbproxy_input_loop();
 
 #ifdef DEBUG
 /* BEWARE: this can cause a string memory leak, according to the leaks program. */
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index acd01af..6ba30c6 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -50,19 +50,6 @@ BOOL xpbproxy_prefs_reload = NO;
 static pthread_mutex_t xpbproxy_dpy_rdy_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t xpbproxy_dpy_rdy_cond = PTHREAD_COND_INITIALIZER;
 
-static inline pthread_t create_thread(void *func, void *arg) {
-    pthread_attr_t attr;
-    pthread_t tid;
-    
-    pthread_attr_init(&attr);
-    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&tid, &attr, func, arg);
-    pthread_attr_destroy(&attr);
-    
-    return tid;
-}
-
 /* Timestamp when the X server last told us it's active */
 static Time last_activation_time;
 
@@ -101,7 +88,7 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
     }
 }
 
-static void *xpbproxy_input_thread(void *args) {
+void xpbproxy_input_loop() {
     pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
     while(true) {
         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -153,8 +140,6 @@ static void *xpbproxy_input_thread(void *args) {
         
         pthread_cond_wait(&xpbproxy_dpy_rdy_cond, &xpbproxy_dpy_rdy_lock);
     }
-    
-    return NULL;
 }
 
 static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
@@ -176,7 +161,7 @@ static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
     if (*cf_source == NULL)
         return FALSE;
     
-    CFRunLoopAddSource (CFRunLoopGetCurrent (),
+    CFRunLoopAddSource (CFRunLoopGetMain (),
                         *cf_source, kCFRunLoopDefaultMode);
     return TRUE;
 }
@@ -197,8 +182,6 @@ static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
 }
 
 BOOL xpbproxy_input_register(void) {
-    create_thread(xpbproxy_input_thread, NULL);
-
     return add_input_socket(ConnectionNumber(xpbproxy_dpy), kCFSocketReadCallBack,
                             x_input_callback, NULL, &xpbproxy_dpy_source);
 }
commit c32a680f2670f05902ee323c68f772f52d3a8320
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 12:40:02 2008 -0800

    XQuartz: Don't use NX_SECONDARYFNMASK, NX_NUMERICPADMASK, NX_HELPMASK
    
    We don't have keycodes for them, so don't try to use them
    (cherry picked from commit cb912aca3a2834c4ad8e386c8a0d05c1bb31b0e7)
    (cherry picked from commit 0676a580fcc05d54049269028a34358935a4101c)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index cd5ab5c..2cebd2a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -977,13 +977,6 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
     
     modifierFlags = [e modifierFlags];
     
-    /* These are the "only" modifier keys we care about */
-    modifierFlags &= (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK |
-                      NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK |
-                      NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK |
-                      NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK |
-                      NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK);
-    
 #ifdef NX_DEVICELCMDKEYMASK
     /* This is to workaround a bug in the VNC server where we sometimes see the L
      * modifier and sometimes see no "side"
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 7fc390d..37f0bfb 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -146,7 +146,6 @@ static void DarwinPressModifierKey(int pressed, int key) {
  */
 
 static int modifier_mask_list[] = {
-    NX_SECONDARYFNMASK, NX_NUMERICPADMASK, NX_HELPMASK,
 #ifdef NX_DEVICELCMDKEYMASK
     NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
     NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
@@ -163,6 +162,7 @@ static void DarwinUpdateModifiers(
     int flags )         // modifier flags that have changed
 {
     int *f;
+    int key;
 
     /* Capslock is special.  This mask is the state of capslock (on/off),
      * not the state of the button.  Hopefully we can find a better solution.
@@ -173,8 +173,13 @@ static void DarwinUpdateModifiers(
     }
     
     for(f=modifier_mask_list; *f; f++)
-        if(*f & flags)
-            DarwinPressModifierKey(pressed, DarwinModifierNXMaskToNXKey(*f));
+        if(*f & flags) {
+            key = DarwinModifierNXMaskToNXKey(*f);
+            if(key == -1)
+                ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
+            else
+                DarwinPressModifierKey(pressed, key);
+        }
 }
 
 /* Generic handler for Xquartz-specifc events.  When possible, these should
commit e08ce79152b0887b8d67c4b03b33634f5ef499bc
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 11:57:49 2008 -0800

    XQuartz: Make sure to reset the saved key state when deactivating X11.app
    (cherry picked from commit 3eef78eb321f4f7dbca5a10c80666c621e28a1e0)
    (cherry picked from commit 0d2621b6d4684ec62e67156a5a9dbdd3297f9cb0)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index cbf5cba..cd5ab5c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -202,8 +202,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 
         DarwinUpdateModKeys(0);
         for(i=0; i < NUM_KEYCODES; i++) {
-            if(keyState[i] == NSKeyDown)
+            if(keyState[i] == NSKeyDown) {
                 DarwinSendKeyboardEvents(KeyRelease, i);
+                keyState[i] = NSKeyUp;
+            }
         }
         
         DarwinSendDDXEvent(kXquartzDeactivate, 0);
commit bdf776b4579921dd49316c2ff32ff12cc702720a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 31 12:44:50 2008 -0800

    XQuartz: Honor system key repeat rate
    (cherry picked from commit 4303c9be39a86f5a21de108f72b90a989435905e)
    (cherry picked from commit 9faf3de7e5610af340b92acb1b86bf03b6f2241a)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 228679a..563b7b5 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -323,7 +323,9 @@ static void DarwinKeyboardSetDeviceKeyMap(KeySymsRec *keySyms) {
  */
 void DarwinKeyboardInit(DeviceIntPtr pDev) {
     KeySymsRec keySyms;
-	XkbComponentNamesRec names;
+    XkbComponentNamesRec names;
+    CFIndex value;
+    BOOL ok;
 
     // Open a shared connection to the HID System.
     // Note that the Event Status Driver is really just a wrapper
@@ -332,7 +334,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
 
     DarwinLoadKeyboardMapping(&keySyms);
 
-	bzero(&names, sizeof(names));
+    bzero(&names, sizeof(names));
 
     /* We need to really have rules... or something... */
     //XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
@@ -342,8 +344,26 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
                                        QuartzBell, DarwinChangeKeyboardControl));
     pthread_mutex_unlock(&keyInfo_mutex);
 
-    // TODO: What do we do now in 1.6?
-	//SwitchCoreKeyboard(pDev);   
+    /* Get our key repeat settings from GlobalPreferences */
+    (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+    value = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+    if(!ok)
+        value = 35;
+
+    if(value == 300000) { // off
+        XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
+    } else {
+        pDev->key->xkbInfo->desc->ctrls->repeat_delay = value * 15;
+
+        value = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+        if(!ok)
+            value = 6;
+        pDev->key->xkbInfo->desc->ctrls->repeat_interval = value * 15;
+
+        XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
+    }
+	// TODO: What do we do now in 1.6?
+    SwitchCoreKeyboard(pDev);   
 
     DarwinKeyboardSetDeviceKeyMap(&keySyms);
 }
commit 16560db0c041b24346e186169f6e3bd315ca13ae
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 19:54:12 2008 -0800

    XQuartz: Better avoid stuck keys on context switches
    (cherry picked from commit e9963f1a4f4f12f253eae9d4f01694b6cabe35ad)
    (cherry picked from commit 4be8d7346b9fdc014b72dd6c404ceecc0ef0d245)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index c5e78f9..cbf5cba 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -63,6 +63,9 @@ extern BOOL xpbproxy_init (void);
 #define ProximityIn    0
 #define ProximityOut   1
 
+/* Stuck modifier / button state... force release when we context switch */
+static NSEventType keyState[NUM_KEYCODES];
+
 int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
@@ -179,29 +182,37 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 
 - (void) activateX:(OSX_BOOL)state {
     /* Create a TSM document that supports full Unicode input, and
-	 have it activated while X is active */
+     have it activated while X is active */
     static TSMDocumentID x11_document;
-	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
+    size_t i;
+    DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
-		DarwinSendDDXEvent(kXquartzActivate, 0);
+        DarwinSendDDXEvent(kXquartzActivate, 0);
 
-		if (!_x_active) {
-			if (x11_document == 0) {
-				OSType types[1];
-				types[0] = kUnicodeDocument;
-				NewTSMDocument (1, types, &x11_document, 0);
-			}
+        if (!_x_active) {
+            if (x11_document == 0) {
+                OSType types[1];
+                types[0] = kUnicodeDocument;
+                NewTSMDocument (1, types, &x11_document, 0);
+            }
 
-			if (x11_document != 0)	ActivateTSMDocument (x11_document);
-		}
+            if (x11_document != 0)	ActivateTSMDocument (x11_document);
+        }
     } else {
-		DarwinSendDDXEvent(kXquartzDeactivate, 0);
 
-		if (_x_active && x11_document != 0)
-			DeactivateTSMDocument (x11_document);
-	}
+        DarwinUpdateModKeys(0);
+        for(i=0; i < NUM_KEYCODES; i++) {
+            if(keyState[i] == NSKeyDown)
+                DarwinSendKeyboardEvents(KeyRelease, i);
+        }
+        
+        DarwinSendDDXEvent(kXquartzDeactivate, 0);
 
-	_x_active = state;
+        if (_x_active && x11_document != 0)
+            DeactivateTSMDocument (x11_document);
+    }
+
+    _x_active = state;
 }
 
 - (void) became_key:(NSWindow *)win {
@@ -1126,7 +1137,12 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
                     DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
                 }
             }
-            
+
+            /* Avoid stuck keys on context switch */
+            if(keyState[[e keyCode]] == [e type])
+                return;
+            keyState[[e keyCode]] = [e type];
+
             DarwinSendKeyboardEvents(([e type] == NSKeyDown) ? KeyPress : KeyRelease, [e keyCode]);
             break;
             
commit 66f801f5a06925c303027f856c5ecea4926d80f2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 19:38:31 2008 -0800

    XQuartz: Workaround OSX VNC server bug for modifier key state
    
    A better approach which ensures we have a L modifier key down if we are told neither are down and atleast one is down... =/
    (cherry picked from commit bc13dda345f716bf4de9bfe4e1d85969263b60c2)
    (cherry picked from commit c67a3e2972c75c02f1aeed94bc0a3c5272422267)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 4c8d113..c5e78f9 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -921,6 +921,18 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 @implementation X11Application (Private)
 extern int darwin_modifier_flags; // darwinEvents.c
 
+#ifdef NX_DEVICELCMDKEYMASK
+/* This is to workaround a bug in the VNC server where we sometimes see the L
+ * modifier and sometimes see no "side"
+ */
+static inline int ensure_flag(int flags, int device_independent, int device_dependents, int device_dependent_default) {
+    if( (flags & device_independent) &&
+       !(flags & device_dependents))
+        flags |= device_dependent_default;
+    return flags;
+}
+#endif
+
 - (void) sendX11NSEvent:(NSEvent *)e {
     NSRect screen;
     NSPoint location;
@@ -928,6 +940,7 @@ extern int darwin_modifier_flags; // darwinEvents.c
     int ev_button, ev_type;
     float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
     DeviceIntPtr pDev;
+    int modifierFlags;
 
     /* convert location to be relative to top-left of primary display */
     location = [e locationInWindow];
@@ -949,12 +962,32 @@ extern int darwin_modifier_flags; // darwinEvents.c
     tilt_x = 0;
     tilt_y = 0;
     
+    modifierFlags = [e modifierFlags];
+    
+    /* These are the "only" modifier keys we care about */
+    modifierFlags &= (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK |
+                      NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK |
+                      NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK |
+                      NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK |
+                      NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK);
+    
+#ifdef NX_DEVICELCMDKEYMASK
+    /* This is to workaround a bug in the VNC server where we sometimes see the L
+     * modifier and sometimes see no "side"
+     */
+    modifierFlags = ensure_flag(modifierFlags, NX_CONTROLMASK,   NX_DEVICELCTLKEYMASK   | NX_DEVICERCTLKEYMASK,     NX_DEVICELCTLKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_SHIFTMASK,     NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK,   NX_DEVICELSHIFTKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK,   NX_DEVICELCMDKEYMASK   | NX_DEVICERCMDKEYMASK,     NX_DEVICELCMDKEYMASK);
+    modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK   | NX_DEVICERALTKEYMASK,     NX_DEVICELALTKEYMASK);
+#endif
+
     /* We don't receive modifier key events while out of focus, and 3button
      * emulation mucks this up, so we need to check our modifier flag state
      * on every event... ugg
      */
-    if(darwin_modifier_flags != [e modifierFlags])
-        DarwinUpdateModKeys([e modifierFlags]);
+    
+    if(darwin_modifier_flags != modifierFlags)
+        DarwinUpdateModKeys(modifierFlags);
     
 	switch ([e type]) {
 		case NSLeftMouseDown:     ev_button=1; ev_type=ButtonPress;   goto handle_mouse;
commit a05dbce40248159099c7a7ec7e94bff9ffb700fc
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 29 00:30:31 2008 -0800

    XQuartz: Updated man page fullscreen_hotkeys fullscreen_menu
    (cherry picked from commit 00f3a2e33c8e91da5f855821313a04ea97445656)
    (cherry picked from commit d790c9dd041a2c8e3513d14a556333219d0f8d5e)

diff --git a/hw/xquartz/doc/Xquartz.man.pre b/hw/xquartz/doc/Xquartz.man.pre
index a442c96..04bbee3 100644
--- a/hw/xquartz/doc/Xquartz.man.pre
+++ b/hw/xquartz/doc/Xquartz.man.pre
@@ -32,6 +32,12 @@ Change the modifier keys used to emulate the second mouse button. By default,
 Command is used to emulate the second button. Any combination of the following
 modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
 .TP 8
+.B defaults write org.x.X11 fullscreen_hotkeys -boolean true
+Enable OSX hotkeys while in fullscreen
+.TP 8
+.B defaults write org.x.X11 fullscreen_menu -boolean true
+Show the OSX menu while in fullscreen
+.TP 8
 .B defaults write org.x.X11 no_quit_alert -boolean true
 Disables the alert dialog displayed when attempting to quit X11.
 .TP 8
commit b8877bb9e4c113a400e47a65a7d25d21f0a43116
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 28 15:57:59 2008 -0800

    XQuartz: pbproxy: We explicitly need libX11 for pbproxy
    (cherry picked from commit 32824120da0749b8369c2592f851bb1030dea9f1)
    (cherry picked from commit 8c6e8fa811c782c85e7fefbe75fe5480098739ae)

diff --git a/configure.ac b/configure.ac
index efe347f..f0223a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1558,7 +1558,7 @@ if test "x$XQUARTZ" = xyes; then
 
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
 
-	PKG_CHECK_MODULES(XPBPROXY, [applewmproto >= 1.1.1] [applewm >= 1.0.0] xfixes fixesproto)
+	PKG_CHECK_MODULES(XPBPROXY, [applewmproto >= 1.1.1] [applewm >= 1.0.0] xfixes fixesproto x11)
 
 	if test "x$STANDALONE_XPBPROXY" = xyes ; then
 		AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
commit de78ac43782d7f4ad4b98622e3c419c893d3eeff
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 28 01:53:38 2008 -0800

    XQuartz: Try harder to get the user's login environment
    (cherry picked from commit 6bedaddd78aa04bd303df434a4c49bb87bd7deaa)
    (cherry picked from commit 338f096861136fb6c4f604e93ff21277252676b7)

diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 4295da9..3b8b679 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,8 +1,15 @@
-#!/bin/bash --login
+#!/bin/bash
+
+set "$(dirname "$0")"/X11.bin "${@}"
 
 if [ -x ~/.x11run ]; then
-	exec ~/.x11run "$(dirname "$0")"/X11.bin "${@}"
-else
-	exec "$(dirname "$0")"/X11.bin "${@}"
+	exec ~/.x11run "${@}"
 fi
 
+case $(basename "${SHELL}") in
+	bash)          exec -l "${SHELL}" --login -c 'exec "${@}"' - "${@}" ;;
+	ksh|sh|zsh)    exec -l "${SHELL}" -c 'exec "${@}"' - "${@}" ;;
+	csh|tcsh)      exec -l "${SHELL}" -c 'exec $argv:q' "${@}" ;;
+	es|rc)         exec -l "${SHELL}" -l -c 'exec $*' "${@}" ;;
+	*)             exec    "${@}" ;;
+esac
commit c391114df95109d306e172bea75781d0e9523f62
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 24 00:39:06 2008 -0800

    XQuartz: Reposition windows when we enter fullscreen to ensure our root window
    (cherry picked from commit 7617d3659b5481ef85aecc1f936e7dd2662bdfbd)
    (cherry picked from commit 61ae56f97326c57dda05632ca9f4873238ee18e1)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7f30201..1f0b004 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -324,6 +324,10 @@ void QuartzSetFullscreen(Bool state) {
     if (quartzHasRoot && !quartzEnableRootless)
         RootlessShowAllWindows ();
     
+    if (quartzHasRoot || quartzEnableRootless) {
+        RootlessRepositionWindows(screenInfo.screens[0]);
+    }
+
     /* Somehow the menubar manages to interfere with our event stream
      * in fullscreen mode, even though it's not visible. 
      */
@@ -341,18 +345,18 @@ void QuartzSetRootless(Bool state) {
     
     quartzEnableRootless = state;
 
+    xp_disable_update();
+
     /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */    
     QuartzUpdateScreens();
 
     if (!quartzEnableRootless && !quartzHasRoot) {
-        xp_disable_update();
         RootlessHideAllWindows();
-        xp_reenable_update();
     } else if (quartzEnableRootless && !quartzHasRoot) {
-        xp_disable_update();
         RootlessShowAllWindows();
-        xp_reenable_update();
     }
+
+    xp_reenable_update();
 }
 
 /*
commit beafebef82687d777d88152c62a351954df7c864
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Dec 23 20:33:27 2008 -0800

    XQuartz: Re-enable rlAccel
    
    It was incorrectly blamed for some crashes a few months ago, and it should be
    safe to use until we get an EXA driver to replace it.
    (cherry picked from commit 8121f30bd29591fc74fbc680fbbf20210271fa58)
    (cherry picked from commit 85347902d97f2d4937f63ae1fac62ee46a61c82f)

diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 40060d0..bbad10a 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -18,6 +18,7 @@ X11_bin_LDADD = \
 	$(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \
 	$(top_builddir)/dix/dixfonts.lo \
 	$(top_builddir)/miext/rootless/librootless.la \
+	$(top_builddir)/miext/rootless/accel/librlAccel.la \
 	$(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
 	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 18406b8..7634469 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -364,9 +364,7 @@ xprSetupScreen(int index, ScreenPtr pScreen)
 {
     // Initialize accelerated rootless drawing
     // Note that this must be done before DamageSetup().
-
-    // These are crashing ugly... better to be stable and not crash for now.
-    //RootlessAccelInit(pScreen);
+    RootlessAccelInit(pScreen);
 
 #ifdef DAMAGE
     // The Damage extension needs to wrap underneath the
commit 86ba5eff623336592091b990209eb07b3f74f8b9
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 21 21:03:59 2008 -0800

    XQuartz: Don't use keycode 0 to determine !swallow since our most common key to swallow is actual keycode 0 (a)
    (cherry picked from commit 33f43a7f03023bfbab25a957cb81fc25b4afa4ca)
    (cherry picked from commit 84f0c03418bf74188596635dcac128fc05f204ad)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2c6b60b..4c8d113 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -266,7 +266,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
         case NSKeyDown: case NSKeyUp:
             
             if(_x_active) {
-                static int swallow_up;
+                static BOOL do_swallow = NO;
+                static int swallow_keycode;
                 
                 if([e type] == NSKeyDown) {
                     /* Before that though, see if there are any global
@@ -274,17 +275,20 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 
                     if(darwinAppKitModMask & [e modifierFlags]) {
                         /* Override to force sending to Appkit */
-                        swallow_up = [e keyCode];
+                        swallow_keycode = [e keyCode];
+                        do_swallow = YES;
                         for_x = NO;
 #if XPLUGIN_VERSION >= 1
                     } else if(X11EnableKeyEquivalents &&
-                              xp_is_symbolic_hotkey_event([e eventRef])) {
-                        swallow_up = [e keyCode];
+                             xp_is_symbolic_hotkey_event([e eventRef])) {
+                        swallow_keycode = [e keyCode];
+                        do_swallow = YES;
                         for_x = NO;
 #endif
                     } else if(X11EnableKeyEquivalents &&
                               [[self mainMenu] performKeyEquivalent:e]) {
-                        swallow_up = [e keyCode];
+                        swallow_keycode = [e keyCode];
+                        do_swallow = YES;
                         for_appkit = NO;
                         for_x = NO;
                     } else if(!quartzEnableRootless
@@ -292,7 +296,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
                               && ([e keyCode] == 0 /*a*/ || [e keyCode] == 53 /*Esc*/)) {
                         /* We have this here to force processing fullscreen 
                          * toggle even if X11EnableKeyEquivalents is disabled */
-                        swallow_up = [e keyCode];
+                        swallow_keycode = [e keyCode];
+                        do_swallow = YES;
                         for_x = NO;
                         for_appkit = NO;
                         DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
@@ -303,9 +308,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
                 } else { /* KeyUp */
                     /* If we saw a key equivalent on the down, don't pass
                      * the up through to X. */
-                    
-                    if (swallow_up != 0 && [e keyCode] == swallow_up) {
-                        swallow_up = 0;
+                    if (do_swallow && [e keyCode] == swallow_keycode) {
+                        do_swallow = NO;
                         for_x = NO;
                     }
                 }
commit 2a42a059ce7b259622b36fb3ef909f289d5388d7
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 21 20:40:36 2008 -0800

    XQuartz: Update our "screens" when we toggle rootless rather than when we toggle fullscreen
    
    This old behavior was used as a workaround for the menubar behavior in the older server,
    but we handle it better now and need to update our screens when we toggle the rootless
    state instead.
    (cherry picked from commit 508aa95bc2cd3fdc3dff448ec090919bf807d153)
    (cherry picked from commit 7e7758e1780326ad867be74dbd583a154bad017b)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 077c87c..7f30201 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -324,16 +324,9 @@ void QuartzSetFullscreen(Bool state) {
     if (quartzHasRoot && !quartzEnableRootless)
         RootlessShowAllWindows ();
     
-    /* Only update screen info when something is visible. Avoids the wm
-     * moving the windows out from under the menubar when it shouldn't
-     */
-    if (quartzHasRoot || quartzEnableRootless)
-        QuartzUpdateScreens();
-    
     /* Somehow the menubar manages to interfere with our event stream
      * in fullscreen mode, even though it's not visible. 
      */
-    
     X11ApplicationShowHideMenubar(!quartzHasRoot);
     
     xp_reenable_update ();
@@ -347,7 +340,10 @@ void QuartzSetRootless(Bool state) {
         return;
     
     quartzEnableRootless = state;
-    
+
+    /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */    
+    QuartzUpdateScreens();
+
     if (!quartzEnableRootless && !quartzHasRoot) {
         xp_disable_update();
         RootlessHideAllWindows();
@@ -355,7 +351,6 @@ void QuartzSetRootless(Bool state) {
     } else if (quartzEnableRootless && !quartzHasRoot) {
         xp_disable_update();
         RootlessShowAllWindows();
-        QuartzUpdateScreens();
         xp_reenable_update();
     }
 }
commit 51319550c9bb079c3af1b98c96c5174bc74e0dbd
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 21 14:54:11 2008 -0800

    XQuartz: Run applications via '/bin/sh -c ...' to support users who expect shell parsing
    (cherry picked from commit 67455e716e3ecffd528930479192785958d37988)
    (cherry picked from commit 7dc0dafef1d241d396f215c506ec2d4f7d8e3a24)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 7222f46..9b30fa6 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -314,36 +314,16 @@ BOOL xquartz_resetenv_display = NO;
 
 - (void) launch_client:(NSString *)filename
 {
-    const char *command = [filename UTF8String];
     int child1, child2 = 0;
     int status;
-    char newcommand[1024];
-    char *newargv[1024];
+    const char *newargv[4];
     char buf[128];
-    size_t newargc;
     char *s;
     
-    if(strlen(command) > 1023) {
-        fprintf(stderr, "Error: command is too long: %s\n", command);
-        return;
-    }
-    
-    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;
+    newargv[0] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
+    newargv[1] = "-c";
+    newargv[2] = [filename UTF8String];
+    newargv[3] = NULL;
     
     s = getenv("DISPLAY");
     if (xquartz_resetenv_display || s == NULL || s[0] == 0) {
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 7677a9a..fd70f26 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -531,33 +531,13 @@ int main(int argc, char **argv, char **envp) {
 }
 
 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);
+    const char *newargv[4];
+    const char **p;
     
-    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;
+    newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL);
+    newargv[1] = "-c";
+    newargv[2] = command;
+    newargv[3] = NULL;
     
     fprintf(stderr, "X11.app: Launching %s:\n", command);
     for(p=newargv; *p; p++) {
commit b0503b69f998bcf5398ed0382a38346a3f18a77c
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 21 14:43:12 2008 -0800

    XQuartz: pbproxy: Release display notification lock when not needed to avoid deadlock
    (cherry picked from commit 22f664ab95a0cae981e9cefad6f075d051583ca5)
    (cherry picked from commit 4c256c0e9c4fe61990343c8bcf2e352c83d76e69)

diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index eb1f3ba..d24d08b 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -76,7 +76,6 @@ extern BOOL xpbproxy_have_xfixes;
 
 /* from x-input.m */
 extern BOOL xpbproxy_input_register (void);
-extern void xpbproxy_input_run (void);
 
 #ifdef DEBUG
 /* BEWARE: this can cause a string memory leak, according to the leaks program. */
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index ca7c30d..acd01af 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -47,8 +47,8 @@ static CFRunLoopSourceRef xpbproxy_dpy_source;
 BOOL xpbproxy_prefs_reload = NO;
 #endif
 
-static pthread_mutex_t xpbproxy_dpy_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t xpbproxy_dpy_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t xpbproxy_dpy_rdy_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t xpbproxy_dpy_rdy_cond = PTHREAD_COND_INITIALIZER;
 
 static inline pthread_t create_thread(void *func, void *arg) {
     pthread_attr_t attr;
@@ -63,15 +63,6 @@ static inline pthread_t create_thread(void *func, void *arg) {
     return tid;
 }
 
-static void *xpbproxy_input_thread(void *args) {
-    pthread_mutex_lock(&xpbproxy_dpy_lock);
-    while(true) {
-        xpbproxy_input_run();
-        pthread_cond_wait(&xpbproxy_dpy_cond, &xpbproxy_dpy_lock);
-    }
-}
-
-
 /* Timestamp when the X server last told us it's active */
 static Time last_activation_time;
 
@@ -110,51 +101,60 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
     }
 }
 
-void xpbproxy_input_run (void) {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    
-    if (nil == pool) 
-    {
-        fprintf(stderr, "unable to allocate/init auto release pool!\n");
-        return;
-    }
-    
-    while (XPending (xpbproxy_dpy) != 0) {
-        XEvent e;
-        XNextEvent (xpbproxy_dpy, &e);
+static void *xpbproxy_input_thread(void *args) {
+    pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
+    while(true) {
+        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
         
-        switch (e.type) {                
-            case SelectionClear:
-                if([xpbproxy_selection_object() is_active])
-                    [xpbproxy_selection_object () clear_event:&e.xselectionclear];
-                break;
-                
-            case SelectionRequest:
-                [xpbproxy_selection_object () request_event:&e.xselectionrequest];
-                break;
-                
-            case SelectionNotify:
-                [xpbproxy_selection_object () notify_event:&e.xselection];
-                break;
-                
-            case PropertyNotify:
-                [xpbproxy_selection_object () property_event:&e.xproperty];
-                break;
-                
-            default:
-                if(e.type >= xpbproxy_apple_wm_event_base &&
-                   e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
-                    x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
-                } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
-                    [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
-                }
-                break;
+        if(pool == nil) {
+            fprintf(stderr, "unable to allocate/init auto release pool!\n");
+            break;
         }
         
-        XFlush(xpbproxy_dpy);
+        while (XPending(xpbproxy_dpy) != 0) {
+            XEvent e;
+            
+            pthread_mutex_unlock(&xpbproxy_dpy_rdy_lock);
+            XNextEvent (xpbproxy_dpy, &e);
+            
+            switch (e.type) {                
+                case SelectionClear:
+                    if([xpbproxy_selection_object() is_active])
+                        [xpbproxy_selection_object () clear_event:&e.xselectionclear];
+                    break;
+                    
+                case SelectionRequest:
+                    [xpbproxy_selection_object () request_event:&e.xselectionrequest];
+                    break;
+                    
+                case SelectionNotify:
+                    [xpbproxy_selection_object () notify_event:&e.xselection];
+                    break;
+                    
+                case PropertyNotify:
+                    [xpbproxy_selection_object () property_event:&e.xproperty];
+                    break;
+                    
+                default:
+                    if(e.type >= xpbproxy_apple_wm_event_base &&
+                       e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
+                        x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
+                    } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
+                        [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
+                    }
+                    break;
+            }
+            
+            XFlush(xpbproxy_dpy);
+            pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
+        }
+        
+        [pool release];
+        
+        pthread_cond_wait(&xpbproxy_dpy_rdy_cond, &xpbproxy_dpy_rdy_lock);
     }
     
-    [pool release];
+    return NULL;
 }
 
 static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
@@ -191,9 +191,9 @@ static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
     }
 #endif
 
-    pthread_mutex_lock(&xpbproxy_dpy_lock);
-    pthread_cond_broadcast(&xpbproxy_dpy_cond);
-    pthread_mutex_unlock(&xpbproxy_dpy_lock);
+    pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
+    pthread_cond_broadcast(&xpbproxy_dpy_rdy_cond);
+    pthread_mutex_unlock(&xpbproxy_dpy_rdy_lock);
 }
 
 BOOL xpbproxy_input_register(void) {
commit 6c635faa6ff0474199f4f7375022efe1e8ffa8f1
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun Dec 21 14:42:26 2008 -0800

    XQuartz: update quoting in case X11.app is moved to a directory with a space.
    (cherry picked from commit cc805dc799efa37c8dcefa3db04d87e9b835ffbd)
    (cherry picked from commit ecc3a7b6090552c309fe8e264d527ddd666a5761)

diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index f6fac9f..4295da9 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,8 +1,8 @@
 #!/bin/bash --login
 
 if [ -x ~/.x11run ]; then
-	exec ~/.x11run "$(dirname $0)"/X11.bin "${@}"
+	exec ~/.x11run "$(dirname "$0")"/X11.bin "${@}"
 else
-	exec "$(dirname $0)"/X11.bin "${@}"
+	exec "$(dirname "$0")"/X11.bin "${@}"
 fi
 
commit 14d9ccf0ce4c5b4820e692cb58077c4c5918f12a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Dec 18 09:14:16 2008 -0800

    XQuartz: Changed X11.sh to allow use of a ~/.x11run as requested by users of alternate shells
    (cherry picked from commit b62ed1f8eaf041a946bb591165bb18ee481dedbf)
    (cherry picked from commit c3812aec973b7341a600e5d2d07d5a7f15abd609)

diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 87c52b3..f6fac9f 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -1,3 +1,8 @@
 #!/bin/bash --login
 
-"$(dirname $0)"/X11.bin "${@}"
+if [ -x ~/.x11run ]; then
+	exec ~/.x11run "$(dirname $0)"/X11.bin "${@}"
+else
+	exec "$(dirname $0)"/X11.bin "${@}"
+fi
+
commit 87df8e681988e546ed943b0f3e7df2851ada4712
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Dec 17 15:09:35 2008 -0800

    XQuartz: Get rid of white rectangle bug
    (cherry picked from commit 3269959033ed0c675a3a906666454df34086896a)
    (cherry picked from commit fd6fb6a2771df152b57f9dfb159fa42a3b1d37cd)

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 1b202e1..5ce26bd 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -628,7 +628,7 @@ RootlessReorderWindow(WindowPtr pWin)
 {
     RootlessWindowRec *winRec = WINREC(pWin);
 
-    if (winRec != NULL && !winRec->is_reorder_pending) {
+    if (pWin->realized && winRec != NULL && !winRec->is_reorder_pending && !windows_hidden) {
         WindowPtr newPrevW;
         RootlessWindowRec *newPrev;
         RootlessFrameID newPrevID;
@@ -1567,7 +1567,10 @@ RootlessOrderAllWindows (void)
 {
     int i;
     WindowPtr pWin;
-    
+
+    if (windows_hidden)
+        return;    
+
     RL_DEBUG_MSG("RootlessOrderAllWindows() ");
     for (i = 0; i < screenInfo.numScreens; i++) {
       if (screenInfo.screens[i] == NULL) continue;
commit 5ff6b1e7ed11a37b2878f2f9a37b2afce00baeb0
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)
    (cherry picked from commit 102abeda37d6b62971a9952efa0453e38504ae0b)

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 ffdf0139051c51f94d6a7a9a5fc2ccc68959d14b
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Dec 19 19:10:23 2008 +0100

    randr/xfree86: Fix a one off error in the panning calculations.
    
    - Example: mode 1280x1024, panned area 1281x1024
               panned_area.x2 = 1281
               mode.width = 1280
      If you substract 1280 from 1281, then that leaves you with one.
      Which is the one pixel that you need to move to actually see the last pixel collumn.
      Substracting 1 from this will consistently prevent you from seeing the right and bottom edge.
    (cherry picked from commit aedd2f566df585db7a1614f302cc8d3feda54275)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 362229c..eb6bf27 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -210,14 +210,14 @@ xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
     }
     /* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
     if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
-	if (newX >= crtc->panningTotalArea.x2 - width)
-	    newX =  crtc->panningTotalArea.x2 - width - 1;
+	if (newX > crtc->panningTotalArea.x2 - width)
+	    newX =  crtc->panningTotalArea.x2 - width;
 	if (newX <  crtc->panningTotalArea.x1)
 	    newX =  crtc->panningTotalArea.x1;
     }
     if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
-	if (newY >= crtc->panningTotalArea.y2 - height)
-	    newY =  crtc->panningTotalArea.y2 - height - 1;
+	if (newY > crtc->panningTotalArea.y2 - height)
+	    newY =  crtc->panningTotalArea.y2 - height;
 	if (newY <  crtc->panningTotalArea.y1)
 	    newY =  crtc->panningTotalArea.y1;
     }
commit 2a822c231145afd2b99498d5d4bf96be7dff92c5
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Dec 15 03:18:13 2008 -0800

    mi: Reuse memory in mieqProcessInputEvents rather than making excessive calls to calloc()
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit a939368ab8140d48c1da4ba0bb229d13b221189c)

diff --git a/mi/mieq.c b/mi/mieq.c
index f0d979a..db48f55 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -308,7 +308,8 @@ mieqProcessInputEvents(void)
     int x = 0, y = 0;
     int type, nevents, evlen, i;
     ScreenPtr screen;
-    xEvent *event;
+    static xEvent *event = NULL;
+    static size_t event_size = 0;
     DeviceIntPtr dev = NULL,
                  master = NULL;
 
@@ -318,7 +319,10 @@ mieqProcessInputEvents(void)
         /* GenericEvents always have nevents == 1 */
         nevents = e->nevents;
         evlen   = (nevents > 1) ? sizeof(xEvent) : e->events->evlen;
-        event   = xcalloc(nevents, evlen);
+        if((nevents * evlen) > event_size) {
+            event_size = nevents * evlen;
+            event = (xEvent *)xrealloc(event, event_size);
+        }
 
         if (!event)
             FatalError("[mi] No memory left for event processing.\n");
@@ -376,8 +380,6 @@ mieqProcessInputEvents(void)
                     master->public.processInputProc(masterEvents->event, master,
                                                     nevents);
             }
-
-            xfree(event);
         }
 
         /* Update the sprite now. Next event may be from different device. */
commit a067bd907e9d3e55edd6ca61279968b6cb96236c
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Mon Dec 1 21:20:48 2008 +1000

    mi: Clean up CopyGetMasterEvent, re-use the memory.
    
    Alloc an EventList once and then re-use instead of allocing a new event each
    time we need a master event.
    There's a trick included: because all the event processing handlers only take
    an xEvent, init a size 1 EventList and squash the events into this one.
    
    Events that have count > 1 must be squished into an xEvent array anyway before
    passing into the event handlers, so we don't lose anything here.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Daniel Stone <daniel at fooishbar.org>
    (cherry picked from commit d281866b74f7067f2704c278fe9720eafc0ee5ef)

diff --git a/mi/mieq.c b/mi/mieq.c
index 137be7b..f0d979a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -80,6 +80,7 @@ typedef struct _EventQueue {
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec miEventQueue;
+static EventListPtr masterEvents; /* for use in mieqProcessInputEvents */
 
 Bool
 mieqInit(void)
@@ -98,6 +99,17 @@ mieqInit(void)
             FatalError("Could not allocate event queue.\n");
         miEventQueue.events[i].events = evlist;
     }
+
+    /* XXX: mE is just 1 event long, if we have Motion + Valuator they are
+     * squashed into the first event to make passing it into the event
+     * processing handlers easier. This should be fixed when the processing
+     * handlers switch to EventListPtr instead of xEvent */
+    masterEvents = InitEventList(1);
+    if (!masterEvents)
+        FatalError("Could not allocated MD event queue.\n");
+    SetMinimumEventSize(masterEvents, 1,
+                        (1 + MAX_VALUATOR_EVENTS) * sizeof(xEvent));
+
     SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
     return TRUE;
 }
@@ -270,28 +282,21 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event)
  */
 void
 CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
-                   xEvent** master, int count)
+                   EventListPtr master, int count)
 {
-    if (count > 1) {
-        *master = xcalloc(count, sizeof(xEvent));
-        if (!*master)
-            FatalError("[mi] No memory left for master event.\n");
-        while(count--)
-        {
-            memcpy(&(*master)[count], &original[count], sizeof(xEvent));
-            ChangeDeviceID(mdev, &(*master)[count]);
-        }
-    } else
-    {
-        int len = sizeof(xEvent);
-        if (original->u.u.type == GenericEvent)
-            len += GEV(original)->length * 4;
-        *master = xalloc(len);
-        if (!*master)
-            FatalError("[mi] No memory left for master event.\n");
-        memcpy(*master, original, len);
-        ChangeDeviceID(mdev, *master);
-    }
+    int len = count * sizeof(xEvent);
+
+    /* Assumption: GenericEvents always have count 1 */
+
+    if (GEV(original)->type == GenericEvent)
+        len += GEV(original)->length * 4;
+
+    if (master->evlen < len)
+        SetMinimumEventSize(master, 1, len);
+
+    memcpy(master->event, original, len);
+    while (count--)
+        ChangeDeviceID(mdev, &master->event[count]);
 }
 
 /* Call this from ProcessInputEvents(). */
@@ -303,8 +308,7 @@ mieqProcessInputEvents(void)
     int x = 0, y = 0;
     int type, nevents, evlen, i;
     ScreenPtr screen;
-    xEvent *event,
-           *master_event = NULL;
+    xEvent *event;
     DeviceIntPtr dev = NULL,
                  master = NULL;
 
@@ -353,10 +357,7 @@ mieqProcessInputEvents(void)
         }
         else {
             if (master)
-                CopyGetMasterEvent(master, event,
-                                   &master_event, nevents);
-            else
-                master_event = NULL;
+                CopyGetMasterEvent(master, event, masterEvents, nevents);
 
             /* If someone's registered a custom event handler, let them
              * steal it. */
@@ -365,19 +366,18 @@ mieqProcessInputEvents(void)
                 handler(DequeueScreen(dev)->myNum, event, dev, nevents);
                 if (master)
                     handler(DequeueScreen(master)->myNum,
-                            master_event, master, nevents);
+                            masterEvents->event, master, nevents);
             } else
             {
                 /* process slave first, then master */
                 dev->public.processInputProc(event, dev, nevents);
 
                 if (master)
-                    master->public.processInputProc(master_event, master,
+                    master->public.processInputProc(masterEvents->event, master,
                                                     nevents);
             }
 
             xfree(event);
-            xfree(master_event);
         }
 
         /* Update the sprite now. Next event may be from different device. */
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index b68a28b..585ad19 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -42,13 +42,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 extern	int	DeviceValuator;
 
+static EventListPtr masterEvents = NULL;
+
 void
 XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
 {
 int *			devVal;
 INT32 *			evVal;
-xEvent			events[2],
-			*m_events = NULL; /* master dev */
+xEvent			events[2];
 deviceKeyButtonPointer *btn;
 deviceValuator *	val;
 int			x,y;
@@ -107,18 +108,22 @@ DeviceIntPtr		master = NULL;
      * cases, unless dev is both a keyboard and a mouse.
      */
     if (!dev->isMaster && dev->u.master) {
+        if (!masterEvents)
+        {
+            masterEvents = InitEventList(1);
+            SetMinimumEventSize(masterEvents, 1, (1 + MAX_VALUATOR_EVENTS) * sizeof(xEvent));
+        }
         master = dev->u.master;
         if (!IsPointerDevice(master))
             master = GetPairedDevice(dev->u.master);
 
-        CopyGetMasterEvent(master, &events, &m_events, count);
+        CopyGetMasterEvent(master, &events, masterEvents, count);
     }
 
     (*dev->public.processInputProc)((xEventPtr)btn, dev, count);
 
     if (master) {
-        (*master->public.processInputProc)(m_events, master, count);
-        xfree(m_events);
+        (*master->public.processInputProc)(masterEvents->event, master, count);
     }
     return;
 }
commit 3519f83f509dd0363f574d3a68b21df98d5f2732
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Dec 10 11:35:09 2008 +1000

    dix: move MAX_VALUATOR_EVENTS into include/input.h
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 0b4fef6337d88ae8ef05b8b73941350a9007565c)

diff --git a/dix/getevents.c b/dix/getevents.c
index 9592d4c..707d1da 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -61,10 +61,6 @@
 #include "exglobals.h"
 #include "extnsionst.h"
 
-/* Maximum number of valuators, divided by six, rounded up, to get number
- * of events. */
-#define MAX_VALUATOR_EVENTS 6
-
 /* Number of motion history events to store. */
 #define MOTION_HISTORY_SIZE 256
 
diff --git a/include/input.h b/include/input.h
index c78f0b7..82ee236 100644
--- a/include/input.h
+++ b/include/input.h
@@ -69,7 +69,10 @@ SOFTWARE.
 #define PtrAccelLightweight     2
 #define PtrAccelDefault         PtrAccelPredictable
 
-#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
+#define MAX_VALUATORS 36
+/* Maximum number of valuators, divided by six, rounded up, to get number
+ * of events. */
+#define MAX_VALUATOR_EVENTS 6
 
 #define NO_AXIS_LIMITS -1
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 87cdfba..137be7b 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -93,7 +93,7 @@ mieqInit(void)
         miEventQueue.handlers[i] = NULL;
     for (i = 0; i < QUEUE_SIZE; i++)
     {
-        EventListPtr evlist = InitEventList(7); /* 1 + MAX_VALUATOR_EVENTS */
+        EventListPtr evlist = InitEventList(1 + MAX_VALUATOR_EVENTS);
         if (!evlist)
             FatalError("Could not allocate event queue.\n");
         miEventQueue.events[i].events = evlist;
commit 3ec3b502e3c6f0b74f8d96f7dda4f872156589a1
Author: Francis Giraldeau <francis.giraldeau at revolutionlinux.com>
Date:   Wed Dec 17 09:49:39 2008 +0200

    Don't log audit messages when -audit 0 specified
    
    make the auditTrailLevel check more general and don't log when not
    using DTRACE and -audit 0 is set.
    (cherry picked from commit d61e902aab92c262e6c8ee9cd70aec4493cf6cae)

diff --git a/os/connection.c b/os/connection.c
index ddb2d6c..8f1f73e 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -602,8 +602,8 @@ AuthAudit (ClientPtr client, Bool letin,
     
 #ifdef XSERVER_DTRACE
     XSERVER_CLIENT_AUTH(client->index, addr, client_pid, client_zid);
-    if (auditTrailLevel > 1) {
 #endif
+    if (auditTrailLevel > 1) {
       if (proto_n)
 	AuditF("client %d %s from %s%s\n  Auth name: %.*s ID: %d\n", 
 	       client->index, letin ? "connected" : "rejected", addr,
@@ -613,9 +613,7 @@ AuthAudit (ClientPtr client, Bool letin,
 	       client->index, letin ? "connected" : "rejected", addr,
 	       client_uid_string);
 
-#ifdef XSERVER_DTRACE
     }
-#endif	
 }
 
 XID
commit 053f32d92864870cd5714befb419810976729df3
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Tue Dec 16 17:44:27 2008 -0500

    Fix compilation with -Werror=format-security
    (cherry picked from commit 6d8ea5104cf97dbf64612f58fc06f94f869ed5ec)

diff --git a/os/log.c b/os/log.c
index 97b98f0..39bbd60 100644
--- a/os/log.c
+++ b/os/log.c
@@ -572,9 +572,10 @@ Error(char *str)
 	    return;
 	sprintf(err, "%s: ", str);
 	strcat(err, strerror(saveErrno));
-	LogWrite(-1, err);
+	LogWrite(-1, "%s", err);
+	free(err);
     } else
-	LogWrite(-1, strerror(saveErrno));
+	LogWrite(-1, "%s", strerror(saveErrno));
 }
 
 void
commit 8ed4ca2801ece271a4ad7c73a7c0e1329f69ade8
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 17 16:10:51 2008 -0400

    XAA: Disable offscreen pixmaps by default.
    
    Say Option "XaaOffscreenPixmaps" to turn them back on.
    
    Apropos of bugs #13795 and #15098.  But this still isn't correct.
    (cherry picked from commit 0c6987df3b9b3a37d201d740d8248c326449835e)

diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c
index 4087142..3b397dc 100644
--- a/hw/xfree86/xaa/xaaInitAccel.c
+++ b/hw/xfree86/xaa/xaaInitAccel.c
@@ -41,7 +41,8 @@ typedef enum {
     XAAOPT_WRITE_BITMAP,
     XAAOPT_WRITE_PIXMAP,
     XAAOPT_PIXMAP_CACHE,
-    XAAOPT_OFFSCREEN_PIXMAPS
+    XAAOPT_OFFSCREEN_PIXMAPS,
+    XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE
 } XAAOpts;
 
 static const OptionInfoRec XAAOptions[] = {
@@ -87,6 +88,8 @@ static const OptionInfoRec XAAOptions[] = {
 				OPTV_BOOLEAN,	{0}, FALSE },
     {XAAOPT_OFFSCREEN_PIXMAPS,		"XaaNoOffscreenPixmaps",
 				OPTV_BOOLEAN,	{0}, FALSE },
+    {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps",
+				OPTV_BOOLEAN,   {0}, FALSE },
     { -1,				NULL,
 				OPTV_NONE,	{0}, FALSE }
 };
@@ -525,8 +528,8 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 #define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
 
     if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
-		!xf86ReturnOptValBool(options, XAAOPT_OFFSCREEN_PIXMAPS,
-		                      FALSE)) {
+		xf86IsOptionSet(options, XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE))
+    {
 	XAAMSG("\tOffscreen Pixmaps\n");
     } else {
 	infoRec->Flags &= ~OFFSCREEN_PIXMAPS;


More information about the xorg-commit mailing list