xserver: Branch 'master' - 9 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Sep 12 15:26:23 PDT 2008


 hw/xquartz/X11Application.h               |    1 
 hw/xquartz/X11Application.m               |   42 +-
 hw/xquartz/X11Controller.m                |    4 
 hw/xquartz/darwin.c                       |  118 --------
 hw/xquartz/darwin.h                       |    1 
 hw/xquartz/darwinEvents.c                 |    2 
 hw/xquartz/mach-startup/bundle-main.c     |  141 ++++++---
 hw/xquartz/mach-startup/mach_startup.defs |    8 
 hw/xquartz/mach-startup/stub.c            |  105 ++-----
 hw/xquartz/quartzKeyboard.c               |  438 ------------------------------
 hw/xquartz/xpr/xprCursor.c                |   10 
 hw/xquartz/xpr/xprFrame.c                 |   14 
 miext/rootless/rootlessCommon.h           |    2 
 miext/rootless/rootlessWindow.c           |   34 --
 14 files changed, 171 insertions(+), 749 deletions(-)

New commits:
commit 999f3362d50a753c1801d565766219808efdb1a5
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 5 17:32:16 2008 -0700

    XQuartz: Dead code removal
    (cherry picked from commit 43184cd379c4fb7254391b8a362016cbf89b5529)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index eaeb369..3d06a45 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -82,7 +82,6 @@ extern int quartzHasRoot, quartzEnableRootless;
 #define PREFS_FAKEBUTTONS           "enable_fake_buttons"
 #define PREFS_SYSBEEP               "enable_system_beep"
 #define PREFS_KEYEQUIVS             "enable_key_equivalents"
-#define PREFS_KEYMAP_FILE           "keymap_file"
 #define PREFS_SYNC_KEYMAP           "sync_keymap"
 #define PREFS_DEPTH                 "depth"
 #define PREFS_NO_AUTH               "no_auth"
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index ef5f024..0ce4951 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -171,7 +171,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 		DarwinSendDDXEvent(kXquartzActivate, 0);
 
 		if (!_x_active) {
-			if (x11_document == 0 && darwinKeymapFile == NULL) {
+			if (x11_document == 0) {
 				OSType types[1];
 				types[0] = kUnicodeDocument;
 				NewTSMDocument (1, types, &x11_document, 0);
@@ -667,11 +667,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 	
     darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
                         default:darwinSyncKeymap];
-	
-    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-    if (tem != NULL) darwinKeymapFile = strdup (tem);
-    else             darwinKeymapFile = NULL;
-	
+		
     darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
                           default:darwinDesiredDepth];
 	
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index e067475..3c12ea7 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -648,7 +648,6 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
     [use_sysbeep setIntValue:quartzUseSysBeep];
     [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
     [sync_keymap setIntValue:darwinSyncKeymap];
-    [sync_keymap setEnabled:darwinKeymapFile == NULL];
     [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH default:NO]];
     [focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM default:NO]];
     [focus_on_new_window setIntValue:[NSApp prefs_get_boolean:@PREFS_FOCUS_ON_NEW_WINDOW default:YES]];
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 0a95035..0788d16 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -62,9 +62,7 @@
 #include <sys/utsname.h>
 
 #define NO_CFPLUGIN
-#include <IOKit/IOKitLib.h>
 #include <IOKit/hidsystem/IOHIDLib.h>
-#include <IOKit/hidsystem/ev_keymap.h>
 
 #ifdef MITSHM
 #define _XSHM_SERVER_
@@ -101,7 +99,6 @@ int                     darwinMainScreenY = 0;
 unsigned int            darwinDesiredWidth = 0, darwinDesiredHeight = 0;
 int                     darwinDesiredDepth = -1;
 int                     darwinDesiredRefresh = -1;
-char                    *darwinKeymapFile = "USA.keymapping";
 int                     darwinSyncKeymap = FALSE;
 
 // modifier masks for faking mouse buttons - ANY of these bits trigger it  (not all)
@@ -433,62 +430,6 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
 */
 
 /*
- * DarwinFindLibraryFile
- *  Search for a file in the standard Library paths, which are (in order):
- *
- *      ~/Library/              user specific
- *      /Library/               host specific
- *      /Network/Library/       LAN specific
- *      /System/Library/        OS specific
- *
- *  A sub-path can be specified to search in below the various Library
- *  directories. Returns a new character string (owned by the caller)
- *  containing the full path to the first file found.
- */
-static char * DarwinFindLibraryFile(
-    const char *file,
-    const char *pathext )
-{
-    // Library search paths
-    char *pathList[] = {
-        "",
-        "/Network",
-        "/System",
-        NULL
-    };
-    char *home;
-    char *fullPath;
-    int i = 0;
-
-    // Return the file name as is if it is already a fully qualified path.
-    if (!access(file, F_OK)) {
-        fullPath = xalloc(strlen(file)+1);
-        strcpy(fullPath, file);
-        return fullPath;
-    }
-
-    fullPath = xalloc(PATH_MAX);
-
-    home = getenv("HOME");
-    if (home) {
-        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", home, pathext, file);
-        if (!access(fullPath, F_OK))
-            return fullPath;
-    }
-
-    while (pathList[i]) {
-        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", pathList[i++],
-                 pathext, file);
-        if (!access(fullPath, F_OK))
-            return fullPath;
-    }
-
-    xfree(fullPath);
-    return NULL;
-}
-
-
-/*
  * DarwinParseModifierList
  *  Parse a list of modifier names and return a corresponding modifier mask
  */
@@ -681,18 +622,6 @@ void OsVendorInit(void)
 	}
 #endif
     }
-    //    DEBUG_LOG("Xquartz started at %s\n", ctime(time(NULL)));
-
-    // Find the full path to the keymapping file.
-    if ( darwinKeymapFile ) {
-        char *tempStr = DarwinFindLibraryFile(darwinKeymapFile, "Keyboards");
-        if ( !tempStr ) {
-            ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
-        } else {
-            ErrorF("Using keymapping provided in %s.\n", tempStr);
-        }
-        darwinKeymapFile = tempStr;
-    }
 }
 
 
@@ -757,19 +686,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
         return 2;
     }
 
-    if ( !strcmp( argv[i], "-keymap" ) ) {
-        if ( i == argc-1 ) {
-            FatalError( "-keymap must be followed by a filename\n" );
-        }
-        darwinKeymapFile = argv[i+1];
-        return 2;
-    }
-
-    if ( !strcmp( argv[i], "-nokeymap" ) ) {
-        darwinKeymapFile = NULL;
-        return 1;
-    }
-
     if ( !strcmp( argv[i], "+synckeymap" ) ) {
         darwinSyncKeymap = TRUE;
         return 1;
@@ -853,12 +769,8 @@ void ddxUseMsg( void )
     ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
     ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
     ErrorF("  ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
-    ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
     ErrorF("-version : show the server version.\n");
     ErrorF("\n");
-//    ErrorF("Quartz modes (Experimental / In Development):\n");
-//    ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
-//    ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
     ErrorF("\n");
     ErrorF("Options ignored in rootless mode:\n");
     ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 3fac203..da5ad74 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -84,7 +84,6 @@ extern int              darwinFakeMouse2Mask;
 extern int              darwinFakeMouse3Mask;
 extern int              darwinAppKitModMask;
 extern int              windowItemModMask;
-extern char            *darwinKeymapFile;
 extern int              darwinSyncKeymap;
 extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
 extern int              darwinDesiredDepth;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 135e419..1db61d9 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -473,7 +473,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 		return;
 	}
 
-	if (darwinSyncKeymap && darwinKeymapFile == NULL) {
+	if (darwinSyncKeymap) {
 		/* See if keymap has changed. */
 
 		static unsigned int last_seed;
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 264f6f8..cee582b 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -5,9 +5,6 @@
    Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
    Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
 
-   The code to parse the Darwin keymap is derived from dumpkeymap.c
-   by Eric Sunshine, which includes the following copyright:
-
    Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
    All rights reserved.
 
@@ -40,9 +37,6 @@
 #include <dix-config.h>
 #endif
 
-// Define this to get a diagnostic output to stderr which is helpful
-// in determining how the X server is interpreting the Darwin keymap.
-#define DUMP_DARWIN_KEYMAP
 //#define XQUARTZ_USE_XKB 
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
@@ -310,8 +304,6 @@ const static struct {
 };
 
 darwinKeyboardInfo keyInfo;
-static FILE *fref = NULL;
-static char *inBuffer = NULL;
 
 static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 {
@@ -320,411 +312,10 @@ static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 }
 
 //-----------------------------------------------------------------------------
-// Data Stream Object
-//      Can be configured to treat embedded "numbers" as being composed of
-//      either 1, 2, or 4 bytes, apiece.
-//-----------------------------------------------------------------------------
-typedef struct _DataStream {
-    unsigned char const *data;
-    unsigned char const *data_end;
-    short number_size;  // Size in bytes of a "number" in the stream.
-} DataStream;
-
-static DataStream* new_data_stream(unsigned char const* data, int size) {
-    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
-    if(s) {
-        s->data = data;
-        s->data_end = data + size;
-        s->number_size = 1; // Default to byte-sized numbers.
-    }
-    return s;
-}
-
-static void destroy_data_stream(DataStream* s) {
-    xfree(s);
-}
-
-static unsigned char get_byte(DataStream* s) {
-    assert(s->data + 1 <= s->data_end);
-    return *s->data++;
-}
-
-static short get_word(DataStream* s) {
-    short hi, lo;
-    assert(s->data + 2 <= s->data_end);
-    hi = *s->data++;
-    lo = *s->data++;
-    return ((hi << 8) | lo);
-}
-
-static int get_dword(DataStream* s) {
-    int b1, b2, b3, b4;
-    assert(s->data + 4 <= s->data_end);
-    b4 = *s->data++;
-    b3 = *s->data++;
-    b2 = *s->data++;
-    b1 = *s->data++;
-    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
-}
-
-static int get_number(DataStream* s) {
-    switch (s->number_size) {
-        case 4:  return get_dword(s);
-        case 2:  return get_word(s);
-        default: return get_byte(s);
-    }
-}
-
-//-----------------------------------------------------------------------------
 // Utility functions to help parse Darwin keymap
 //-----------------------------------------------------------------------------
 
 /*
- * bits_set
- *      Calculate number of bits set in the modifier mask.
- */
-static short bits_set(short mask) {
-    short n = 0;
-
-    for ( ; mask != 0; mask >>= 1)
-        if ((mask & 0x01) != 0)
-            n++;
-    return n;
-}
-
-/*
- * parse_next_char_code
- *      Read the next character code from the Darwin keymapping
- *      and write it to the X keymap.
- */
-static void parse_next_char_code(DataStream *s, KeySym *k) {
-    const short charSet = get_number(s);
-    const short charCode = get_number(s);
-
-    if (charSet == 0) {                 // ascii character
-        if (charCode >= 0 && charCode < 256)
-            *k = next_to_x[charCode];
-    } else if (charSet == 0x01) {       // symbol character
-        if (charCode >= MIN_SYMBOL &&
-            charCode <= MIN_SYMBOL + NUM_SYMBOL)
-            *k = symbol_to_x[charCode - MIN_SYMBOL];
-    } else if (charSet == 0xFE) {       // function key
-        if (charCode >= MIN_FUNCKEY &&
-            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
-            *k = funckey_to_x[charCode - MIN_FUNCKEY];
-    }
-}
-
-
-/*
- * DarwinReadKeymapFile
- *      Read the appropriate keymapping from a keymapping file.
- */
-static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
-    struct stat         st;
-    NXEventSystemDevice info[20];
-    int                 interface = 0, handler_id = 0;
-    int                 map_interface, map_handler_id, map_size = 0;
-    unsigned int        i, size;
-    int                 *bufferEnd;
-    union km_tag {
-        int             *intP;
-        char            *charP;
-    } km;
-
-    fref = fopen( darwinKeymapFile, "rb" );
-    if (fref == NULL) {
-        ErrorF("Unable to open keymapping file '%s': %s.\n",
-               darwinKeymapFile, strerror(errno));
-        return FALSE;
-    }
-    if (fstat(fileno(fref), &st) == -1) {
-        ErrorF("Could not stat keymapping file '%s': %s.\n",
-               darwinKeymapFile, strerror(errno));
-        return FALSE;
-    }
-
-    // check to make sure we don't crash later
-    if (st.st_size <= 16*sizeof(int)) {
-        ErrorF("Keymapping file '%s' is invalid (too small).\n",
-               darwinKeymapFile);
-        return FALSE;
-    }
-
-    inBuffer = (char*) xalloc( st.st_size );
-    bufferEnd = (int *) (inBuffer + st.st_size);
-    if (fread(inBuffer, st.st_size, 1, fref) != 1) {
-        ErrorF("Could not read %qd bytes from keymapping file '%s': %s.\n",
-               st.st_size, darwinKeymapFile, strerror(errno));
-        return FALSE;
-    }
-
-    if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
-        // Magic number OK.
-    } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
-        ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    } else {
-        ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    }
-
-    // find the keyboard interface and handler id
-    size = sizeof( info ) / sizeof( int );
-    if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
-                            (NXEventSystemInfoType) info, &size )) {
-        ErrorF("Error reading event status driver info.\n");
-        return FALSE;
-    }
-
-    size = size * sizeof( int ) / sizeof( info[0] );
-    for( i = 0; i < size; i++) {
-        if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
-            Bool hasInterface = FALSE;
-            Bool hasMatch = FALSE;
-
-            interface = info[i].interface;
-            handler_id = info[i].id;
-
-            // Find an appropriate keymapping:
-            // The first time we try to match both interface and handler_id.
-            // If we can't match both, we take the first match for interface.
-
-            do {
-                km.charP = inBuffer;
-                km.intP++;
-                while (km.intP+3 < bufferEnd) {
-                    map_interface = NXSwapBigIntToHost(*(km.intP++));
-                    map_handler_id = NXSwapBigIntToHost(*(km.intP++));
-                    map_size = NXSwapBigIntToHost(*(km.intP++));
-                    if (map_interface == interface) {
-                        if (map_handler_id == handler_id || hasInterface) {
-                            hasMatch = TRUE;
-                            break;
-                        } else {
-                            hasInterface = TRUE;
-                        }
-                    }
-                    km.charP += map_size;
-                }
-            } while (hasInterface && !hasMatch);
-
-            if (hasMatch) {
-                // fill in NXKeyMapping structure
-                keyMap->size = map_size;
-                keyMap->mapping = (char*) xalloc(map_size);
-                memcpy(keyMap->mapping, km.charP, map_size);
-                return TRUE;
-            }
-        } // if dev_id == keyboard device
-    } // foreach info struct
-
-    // The keymapping file didn't match any of the info structs
-    // returned by NXEventSystemInfo.
-    ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
-    return FALSE;
-}
-
-
-/*
- * DarwinParseNXKeyMapping
- */
-static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
-    KeySym              *k;
-    int                 i;
-    short               numMods, numKeys, numPadKeys = 0;
-    Bool                haveKeymap = FALSE;
-    NXKeyMapping        keyMap;
-    DataStream          *keyMapStream;
-    unsigned char const *numPadStart = 0;
-
-    if (darwinKeymapFile) {
-        haveKeymap = DarwinReadKeymapFile(&keyMap);
-        if (fref)
-            fclose(fref);
-        if (inBuffer)
-            xfree(inBuffer);
-        if (!haveKeymap) {
-            ErrorF("Reverting to kernel keymapping.\n");
-        }
-    }
-
-    if (!haveKeymap) {
-        // get the Darwin keyboard map
-        keyMap.size = NXKeyMappingLength( darwinParamConnect );
-        keyMap.mapping = (char*) xalloc( keyMap.size );
-        if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
-            return FALSE;
-        }
-    }
-
-    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
-                                    keyMap.size );
-
-    // check the type of map
-    if (get_word(keyMapStream)) {
-        keyMapStream->number_size = 2;
-        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
-    }
-
-    // Insert X modifier KeySyms into the keyboard map.
-    numMods = get_number(keyMapStream);
-    while (numMods-- > 0) {
-        int             left = 1;               // first keycode is left
-        short const     charCode = get_number(keyMapStream);
-        short           numKeyCodes = get_number(keyMapStream);
-
-        // This is just a marker, not a real modifier.
-        // Store numeric keypad keys for later.
-        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
-            numPadStart = keyMapStream->data;
-            numPadKeys = numKeyCodes;
-        }
-
-        while (numKeyCodes-- > 0) {
-            const short keyCode = get_number(keyMapStream);
-            if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
-                switch (charCode) {
-                    case NX_MODIFIERKEY_ALPHALOCK:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
-                        break;
-                    case NX_MODIFIERKEY_SHIFT:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Shift_L : XK_Shift_R);
-                        break;
-                    case NX_MODIFIERKEY_CONTROL:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_ALTERNATE:
-                        // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Alt_L : XK_Alt_R);
-                        break;
-                    case NX_MODIFIERKEY_COMMAND:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Meta_L : XK_Meta_R);
-                        break;
-                    case NX_MODIFIERKEY_SECONDARYFN:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_HELP:
-                        // Help is not an X11 modifier; treat as normal key
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
-                        break;
-                }
-            }
-            left = 0;
-        }
-    }
-
-    // Convert the Darwin keyboard mapping to an X keyboard map.
-    // A key can have a different character code for each combination of
-    // modifiers. We currently ignore all modifier combinations except
-    // those with Shift, AlphaLock, and Alt.
-    numKeys = get_number(keyMapStream);
-    for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
-        short const     charGenMask = get_number(keyMapStream);
-        if (charGenMask != 0xFF) {              // is key bound?
-            short       numKeyCodes = 1 << bits_set(charGenMask);
-
-            // Record unmodified case
-            parse_next_char_code( keyMapStream, k );
-            numKeyCodes--;
-
-            // If AlphaLock and Shift modifiers produce different codes,
-            // we record the Shift case since X handles AlphaLock.
-            if (charGenMask & 0x01) {       // AlphaLock
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-            }
-
-            if (charGenMask & 0x02) {       // Shift
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Shift-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-            }
-
-            // Skip the Control cases
-            if (charGenMask & 0x04) {       // Control
-                get_number(keyMapStream); get_number(keyMapStream);
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Control-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Control-Shift
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Shift-Control-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            // Process Alt cases
-            if (charGenMask & 0x08) {       // Alt
-                parse_next_char_code( keyMapStream, k+2 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Alt-AlphaLock
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Alt-Shift
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Alt-Shift-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            while (numKeyCodes-- > 0) {
-                get_number(keyMapStream); get_number(keyMapStream);
-            }
-
-            if (k[3] == k[2]) k[3] = NoSymbol;
-            if (k[2] == k[1]) k[2] = NoSymbol;
-            if (k[1] == k[0]) k[1] = NoSymbol;
-            if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-        }
-    }
-
-    // Now we have to go back through the list of keycodes that are on the
-    // numeric keypad and update the X keymap.
-    keyMapStream->data = numPadStart;
-    while(numPadKeys-- > 0) {
-        const short keyCode = get_number(keyMapStream);
-        k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
-        for (i = 0; i < NUM_KEYPAD; i++) {
-            if (*k == normal_to_keypad[i].normalSym) {
-                k[0] = normal_to_keypad[i].keypadSym;
-                break;
-            }
-        }
-    }
-
-    // free Darwin keyboard map
-    destroy_data_stream( keyMapStream );
-    xfree( keyMap.mapping );
-
-    return TRUE;
-}
-
-/*
  * DarwinBuildModifierMaps
  *      Use the keyMap field of keyboard info structure to populate
  *      the modMap and modifierKeycodes fields.
@@ -822,37 +413,12 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
 static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
-    /* TODO: Clean this up
-     * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
-     * DarwinParseNXKeyMapping is here
-     */
-    if (!DarwinParseNXKeyMapping(&keyInfo)) {
-        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
-        if (!QuartzReadSystemKeymap(&keyInfo)) {
-            FatalError("Could not build a valid keymap.");
-        }
+    if (!QuartzReadSystemKeymap(&keyInfo)) {
+        FatalError("Could not build a valid keymap.");
     }
 
     DarwinBuildModifierMaps(&keyInfo);
 
-#ifdef DUMP_DARWIN_KEYMAP
-    int i;
-    KeySym *k;
-    DEBUG_LOG("Darwin -> X converted keyboard map\n");
-    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
-         i++, k += GLYPHS_PER_KEY)
-    {
-        int j;
-        for (j = 0; j < GLYPHS_PER_KEY; j++) {
-            if (k[j] == NoSymbol) {
-                DEBUG_LOG("0x%02x:\tNoSym\n", i);
-            } else {
-                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
-            }
-        }
-    }
-#endif
-
     keySyms->map        = keyInfo.keyMap;
     keySyms->mapWidth   = GLYPHS_PER_KEY;
     keySyms->minKeyCode = MIN_KEYCODE;
commit 6548a55ebdf43231a3c48debf54aa5aa2f1aa956
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 5 17:05:03 2008 -0700

    XQuartz: 256 color support
    (cherry picked from commit 8dd6d5c825d457f26b41b79d02d57ed4a5ecf1f5)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 4ac977a..ef5f024 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -674,10 +674,6 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 	
     darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
                           default:darwinDesiredDepth];
-    
-    // TODO: Add 256 color support
-    if(darwinDesiredDepth == 8)
-        darwinDesiredDepth = -1;
 	
 //    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
 //                     default:false];
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index e1a2856..e067475 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -657,9 +657,6 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
     [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
 
     [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
-    // TODO: Add 256 color support
-    if([depth indexOfItemWithTag:8] != -1)
-        [depth removeItemAtIndex:[depth indexOfItemWithTag:8]];
 	
     [enable_fullscreen setIntValue:!quartzEnableRootless];
     // TODO: Add fullscreen support
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index b261106..0a95035 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -218,6 +218,13 @@ static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv)
                                  dfb->greenMask, dfb->blueMask)) {
         return FALSE;
     }
+    
+    if(dfb->depth > 8)
+        miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
+    if(dfb->depth > 15)
+        miSetVisualTypesAndMasks(15, LARGE_VISUALS, 5, TrueColor, 0x7c00, 0x03e0, 0x001f);
+    if(dfb->depth > 24)
+        miSetVisualTypesAndMasks(24, LARGE_VISUALS, 8, TrueColor, 0x00ff0000, 0x0000ff00, 0x000000ff);
 
     miSetPixmapDepths();
 
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index c8cbc22..7c143b8 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -119,11 +119,9 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
     if (pWin->drawable.depth == 8)
     {
         wc.depth = XP_DEPTH_INDEX8;
-#if 0
-        wc.colormap = xprColormapCallback;
+        wc.colormap = RootlessColormapCallback;
         wc.colormap_data = pScreen;
         mask |= XP_COLORMAP;
-#endif
     }
     else if (pWin->drawable.depth == 15)
         wc.depth = XP_DEPTH_RGB555;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 56f81f5..3d33891 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -273,6 +273,8 @@ Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
 void RootlessFlushWindowColormap (WindowPtr pWin);
 void RootlessFlushScreenColormaps (ScreenPtr pScreen);
 
+RootlessColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors);
+
 // Move a window to its proper location on the screen.
 void RootlessRepositionWindow(WindowPtr pWin);
 
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index ff773ef..c0554f4 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -448,7 +448,7 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
 Bool
 RootlessColormapCallback (void *data, int first_color, int n_colors, uint32_t *colors)
 {
-  return RootlessResolveColormap (data, first_color, n_colors, colors);
+    return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch);
 }
 
 /*
commit bad7cd14c2021b14971b3f707f927803a053003e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 5 10:46:36 2008 -0700

    XQuartz: Dead code removal
    (cherry picked from commit bf10fb0b1f776e72db7c76db11f764e26f9d62c4)

diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 9fa9424..c8cbc22 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -64,19 +64,13 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
 static x_hash_table *window_hash;
 static pthread_mutex_t window_hash_mutex;
 
-static Bool no_configure_window;
-
-
 static inline xp_error
 xprConfigureWindow(xp_window_id id, unsigned int mask,
                    const xp_window_changes *values)
 {
     TA_SERVER();
 
-    if (!no_configure_window)
-        return xp_configure_window(id, mask, values);
-    else
-        return XP_Success;
+    return xp_configure_window(id, mask, values);
 }
 
 
@@ -438,8 +432,6 @@ xprInit(ScreenPtr pScreen)
     rootless_CompositePixels_threshold = xp_composite_area_threshold;
     rootless_CopyWindow_threshold = xp_scroll_area_threshold;
 
-    no_configure_window = FALSE;
-
     return TRUE;
 }
 
commit 1119fe136f8731f26fc6f50b92f5ddf78f3f83be
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 5 10:46:20 2008 -0700

    XQuartz: Changed around fd handoff model to be more robust
    (cherry picked from commit 4fe605c2bc62d50e0b5764d9edda245af227630b)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 1d47251..576a370 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -136,7 +136,7 @@ static mach_port_t checkin_or_register(char *bname) {
 }
 
 /*** $DISPLAY handoff ***/
-static void accept_fd_handoff(int connected_fd) {
+static int accept_fd_handoff(int connected_fd) {
     int launchd_fd;
     
     char databuf[] = "display";
@@ -170,16 +170,49 @@ static void accept_fd_handoff(int connected_fd) {
     
     if(recvmsg(connected_fd, &msg, 0) < 0) {
         fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor.  recvmsg() error: %s\n", strerror(errno));
-        return;
+        return -1;
     }
     
     launchd_fd = *((int*)CMSG_DATA(cmsg));
     
-    if(launchd_fd == -1) {
-        fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? %d\n", launchd_fd);
-        return;
+    return launchd_fd;
+}
+
+typedef struct {
+    int fd;
+    string_t filename;
+} socket_handoff_t;
+
+/* This thread accepts an incoming connection and hands off the file
+ * descriptor for the new connection to accept_fd_handoff()
+ */
+static void socket_handoff_thread(void *arg) {
+    socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
+    int launchd_fd = -1;
+    int connected_fd;
+
+    /* Now actually get the passed file descriptor from this connection
+     * If we encounter an error, keep listening.
+     */
+    while(launchd_fd == -1) {
+        connected_fd = accept(handoff_data->fd, NULL, NULL);
+        if(connected_fd == -1) {
+            fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
+            sleep(2);
+            continue;
+        }
+
+        launchd_fd = accept_fd_handoff(connected_fd);
+        if(launchd_fd == -1)
+            fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received?  Waiting for another connection.\n");
+
+        close(connected_fd);
     }
 
+    close(handoff_data->fd);
+    unlink(handoff_data->filename);
+    free(handoff_data);
+    
 #ifndef XQUARTZ_EXPORTS_LAUNCHD_FD
     /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch:
      *
@@ -189,72 +222,84 @@ static void accept_fd_handoff(int connected_fd) {
      * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook
      * into it.
      */
-
+    
     unsigned remain = 3000000;
-    fprintf(stderr, "X11.app: Received new DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd);
+    fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd);
     while((remain = usleep(remain)) > 0);
 #endif
-
+    
     fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
     DarwinListenOnOpenFD(launchd_fd);
 }
 
-/* This thread accepts an incoming connection and hands off the file
- * descriptor for the new connection to accept_fd_handoff()
- */
-static void socket_handoff_thread(void *arg) {
-    int handoff_fd = *(int *)arg;
-
-    /* Now actually get the passed file descriptor from this connection */
-    accept_fd_handoff(handoff_fd);
-
-    close(handoff_fd);
-}
-
-kern_return_t do_prep_fd_handoff(mach_port_t port, string_t filename) {
+static int create_socket(char *filename_out) {
     struct sockaddr_un servaddr_un;
     struct sockaddr *servaddr;
     socklen_t servaddr_len;
-    int handoff_fd;
-
+    int ret_fd;
+    size_t try, try_max;
+    
+    for(try=0, try_max=5; try < try_max; try++) {
+        tmpnam(filename_out);
+        
+        /* Setup servaddr_un */
+        memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+        servaddr_un.sun_family = AF_UNIX;
+        strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path));
+        
+        servaddr = (struct sockaddr *) &servaddr_un;
+        servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out);
+        
+        ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+        if(ret_fd == -1) {
+            fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
+            continue;
+        }
+        
+        if(bind(ret_fd, servaddr, servaddr_len) != 0) {
+            fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
+            close(ret_fd);
+            return 0;
+        }
+        
+        if(listen(ret_fd, 10) != 0) {
+            fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
+            close(ret_fd);
+            return 0;
+        }
+        
 #ifdef DEBUG
-    fprintf(stderr, "X11.app: Prepping for fd handoff.\n");
+        fprintf(stderr, "X11.app: Listening on socket for fd handoff:  (%d) %s\n", ret_fd, filename_out);
 #endif
+        
+        return ret_fd;
+    }
     
-    /* Initialize our data */
+    return 0;
+}
 
-    /* Setup servaddr_un */
-    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
-    servaddr_un.sun_family  = AF_UNIX;
-    strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
-    
-    servaddr = (struct sockaddr *) &servaddr_un;
-    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
+kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
+    socket_handoff_t *handoff_data;
 
-    /* Get a fd for the handoff */
-    handoff_fd = socket(AF_UNIX, SOCK_STREAM, 0);
-    if(handoff_fd == -1) {
-        fprintf(stderr, "X11.app: Failed to create socket: %d - %s\n", errno, strerror(errno));
+    handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
+    if(!handoff_data) {
+        fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n");
         return KERN_FAILURE;
     }
-#ifdef DEBUG
-    fprintf(stderr, "X11.app: socket created for fd handoff: fd=%d\n", handoff_fd);
-#endif
 
-    if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
-        fprintf(stderr, "X11.app: Failed to connect to socket: %s - %d - %s\n", filename, errno, strerror(errno));
+    handoff_data->fd = create_socket(handoff_data->filename);
+    if(!handoff_data->fd) {
         return KERN_FAILURE;
     }
-#ifdef DEBUG
-    fprintf(stderr, "X11.app: Connection established for fd handoff: fd=%d\n", handoff_fd);
-#endif
+
+    strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
+    
+    create_thread(socket_handoff_thread, handoff_data);
     
-    create_thread(socket_handoff_thread, &handoff_fd);
-   
 #ifdef DEBUG
-    fprintf(stderr, "X11.app: Thread created for handoff.  Returning success to tell caller to accept our connection and push the fd.\n");
+    fprintf(stderr, "X11.app: Thread created for handoff.  Returning success to tell caller to connect and push the fd.\n");
 #endif
-    
+
     return KERN_SUCCESS;
 }
 
diff --git a/hw/xquartz/mach-startup/mach_startup.defs b/hw/xquartz/mach-startup/mach_startup.defs
index 19c105c..76c8edf 100644
--- a/hw/xquartz/mach-startup/mach_startup.defs
+++ b/hw/xquartz/mach-startup/mach_startup.defs
@@ -37,10 +37,10 @@ type string_t = c_string[1024];
 type string_array_t = array[] of string_t;
 
 routine start_x11_server(
-	port  : mach_port_t;
+    port  : mach_port_t;
     argv  : string_array_t;
     envp  : string_array_t);
 
-routine prep_fd_handoff(
-	port  : mach_port_t;
-    socket_filename  : string_t);
+routine request_fd_handoff_socket (
+        port             : mach_port_t;
+    out socket_filename  : string_t);
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 4288753..192a432 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -116,56 +116,38 @@ static void set_x11_path() {
 }
 
 #ifdef MACHO_STARTUP
-static int create_socket(char *filename_out) {
+static int connect_to_socket(const char *filename) {
     struct sockaddr_un servaddr_un;
     struct sockaddr *servaddr;
     socklen_t servaddr_len;
     int ret_fd;
-    size_t try, try_max;
-
-    for(try=0, try_max=5; try < try_max; try++) {
-        tmpnam(filename_out);
-
-        /* Setup servaddr_un */
-        memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
-        servaddr_un.sun_family = AF_UNIX;
-        strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path));
-        
-        servaddr = (struct sockaddr *) &servaddr_un;
-        servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out);
-        
-        ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
-        if(ret_fd == -1) {
-            fprintf(stderr, "Xquartz: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
-            continue;
-        }
-        
-        if(bind(ret_fd, servaddr, servaddr_len) != 0) {
-            fprintf(stderr, "Xquartz: Failed to bind socket: %d - %s\n", errno, strerror(errno));
-            close(ret_fd);
-            return 0;
-        }
-
-        if(listen(ret_fd, 10) != 0) {
-            fprintf(stderr, "Xquartz: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
-            close(ret_fd);
-            return 0;
-        }
 
-#ifdef DEBUG
-        fprintf(stderr, "Xquartz: Listening on socket for fd handoff:  %s\n", filename_out);
-#endif
+    /* Setup servaddr_un */
+    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+    servaddr_un.sun_family = AF_UNIX;
+    strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
+    
+    servaddr = (struct sockaddr *) &servaddr_un;
+    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
+    
+    ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+    if(ret_fd == -1) {
+        fprintf(stderr, "Xquartz: Failed to create socket: %s - %s\n", filename, strerror(errno));
+        return -1;
+    }
 
-        return ret_fd;
+    if(connect(ret_fd, servaddr, servaddr_len) < 0) {
+        fprintf(stderr, "Xquartz: Failed to connect to socket: %s - %d - %s\n", filename, errno, strerror(errno));
+        close(ret_fd);
+        return -1;
     }
     
-    return 0;
+    return ret_fd;
 }
 
-static void send_fd_handoff(int handoff_fd, int launchd_fd) {
+static void send_fd_handoff(int connected_fd, int launchd_fd) {
     char databuf[] = "display";
     struct iovec iov[1];
-    int connected_fd;
     
     iov[0].iov_base = databuf;
     iov[0].iov_len  = sizeof(databuf);
@@ -194,15 +176,6 @@ static void send_fd_handoff(int handoff_fd, int launchd_fd) {
     *((int*)CMSG_DATA(cmsg)) = launchd_fd;
     
 #ifdef DEBUG
-    fprintf(stderr, "Xquartz: Waiting for fd handoff connection.\n");
-#endif
-    connected_fd = accept(handoff_fd, NULL, NULL);
-    if(connected_fd == -1) {
-        fprintf(stderr, "Xquartz: Failed to accept incoming connection on socket: %s\n", strerror(errno));
-        return;
-    }
-    
-#ifdef DEBUG
     fprintf(stderr, "Xquartz: Handoff connection established.  Sending message.\n");
 #endif
     if(sendmsg(connected_fd, &msg, 0) < 0) {
@@ -214,9 +187,6 @@ static void send_fd_handoff(int handoff_fd, int launchd_fd) {
     fprintf(stderr, "Xquartz: Message sent.  Closing.\n");
 #endif
     close(connected_fd);
-#ifdef DEBUG
-    fprintf(stderr, "Xquartz: end of send debug: %d %d %d %s\n", handoff_fd, launchd_fd, errno, strerror(errno));
-#endif
 }
 
 #endif
@@ -261,7 +231,7 @@ int main(int argc, char **argv, char **envp) {
         /* This forking is ugly and will be cleaned up later */
         pid_t child = fork();
         if(child == -1) {
-            fprintf(stderr, "XQuartz: Could not fork: %s\n", strerror(errno));
+            fprintf(stderr, "Xquartz: Could not fork: %s\n", strerror(errno));
             return EXIT_FAILURE;
         }
 
@@ -270,7 +240,7 @@ int main(int argc, char **argv, char **envp) {
             _argv[0] = x11_path;
             _argv[1] = "--listenonly";
             _argv[2] = NULL;
-            fprintf(stderr, "XQuartz: Starting X server: %s --listenonly\n", x11_path);
+            fprintf(stderr, "Xquartz: Starting X server: %s --listenonly\n", x11_path);
             return execvp(x11_path, _argv);
         }
 
@@ -283,24 +253,31 @@ int main(int argc, char **argv, char **envp) {
         }
 
         if(kr != KERN_SUCCESS) {
-            fprintf(stderr, "XQuartz: bootstrap_look_up(): Timed out: %s\n", bootstrap_strerror(kr));
+            fprintf(stderr, "Xquartz: bootstrap_look_up(): Timed out: %s\n", bootstrap_strerror(kr));
             return EXIT_FAILURE;
         }
     }
     
     /* Handoff the $DISPLAY FD */
     if(launchd_fd != -1) {
-        int handoff_fd = create_socket(handoff_socket_filename);
-        
-        if((handoff_fd != 0) &&
-           (prep_fd_handoff(mp, handoff_socket_filename) == KERN_SUCCESS)) {
-            send_fd_handoff(handoff_fd, launchd_fd);
+        size_t try, try_max;
+        int handoff_fd = -1;
+
+        for(try=0, try_max=5; try < try_max; try++) {
+            if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
+                fprintf(stderr, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)\n", (int)try+1, (int)try_max);
+                continue;
+            }
             
-            // Cleanup
+            handoff_fd = connect_to_socket(handoff_socket_filename);
+            if(handoff_fd == -1) {
+                fprintf(stderr, "Xquartz: Failed to connect to socket (try %d of %d)\n", (int)try+1, (int)try_max);
+                continue;
+            }
+
+            send_fd_handoff(handoff_fd, launchd_fd);            
             close(handoff_fd);
-            unlink(handoff_socket_filename);
-        } else {
-            fprintf(stderr, "XQuartz: Unable to hand of $DISPLAY file descriptor\n");
+            break;
         }
     }
 
@@ -314,7 +291,7 @@ int main(int argc, char **argv, char **envp) {
     newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
     
     if(!newargv || !newenvp) {
-        fprintf(stderr, "XQuartz: Memory allocation failure\n");
+        fprintf(stderr, "Xquartz: Memory allocation failure\n");
         exit(EXIT_FAILURE);
     }
     
@@ -327,7 +304,7 @@ int main(int argc, char **argv, char **envp) {
 
     kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
     if (kr != KERN_SUCCESS) {
-        fprintf(stderr, "XQuartz: start_x11_server: %s\n", mach_error_string(kr));
+        fprintf(stderr, "Xquartz: start_x11_server: %s\n", mach_error_string(kr));
         return EXIT_FAILURE;
     }
     return EXIT_SUCCESS;
commit 183233b27beb441742a53e440c3389b4ea125b8a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 12 15:25:44 2008 -0700

    XQuartz: Don't warp the pointer on server start for XQuartz
    (cherry picked from commit c0da576d4921c246a9ac747921b48ab9e718347f)

diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index c1890a2..9c131fb 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -294,16 +294,6 @@ QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
 static void
 QuartzWarpCursor(ScreenPtr pScreen, int x, int y)
 {
-    static Bool neverMoved = TRUE;
-
-    if (neverMoved)
-    {
-        /* Don't move the cursor the first time. This is the
-           jump-to-center initialization, and it's annoying. */
-        neverMoved = FALSE;
-        return;
-    }
-
     if (quartzServerVisible)
     {
         int sx, sy;
commit 7a46dd30d332bc1d42f82b0391e806d3b067ebbd
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Sep 4 09:18:40 2008 -0700

    XQuartz: Dead code removal
    (cherry picked from commit 2e45344870f5d17181df6407da3448991036d783)

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 19fe323..b261106 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -318,29 +318,6 @@ static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv)
  =============================================================================
 */
 
-#if 0
-/*
- * DarwinChangePointerControl
- *  Set mouse acceleration and thresholding
- *  FIXME: We currently ignore the threshold in ctrl->threshold.
- */
-static void DarwinChangePointerControl(
-    DeviceIntPtr    device,
-    PtrCtrl         *ctrl )
-{
-    kern_return_t   kr;
-    double          acceleration;
-
-    if (!darwinMouseAccelChange)
-        return;
-
-    acceleration = ctrl->num / ctrl->den;
-    kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
-    if (kr != KERN_SUCCESS)
-        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
-}
-#endif
-
 /*
  * DarwinMouseProc: Handle the initialization, etc. of a mouse
  */
commit 1c70e53f2560cb877c8b149034f296232de67a4e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Sep 4 08:55:22 2008 -0700

    XQuartz: Fixed proximity logic errors for tablets.
    (cherry picked from commit d942849f248c368b92ca73e145e8a5bc339112d7)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 3bc4899..4ac977a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -924,7 +924,7 @@ static void send_nsevent(NSEvent *e) {
                 tilt_y   = [e tilt].y; 
             }
             
-            if([e subtype] != NSTabletProximityEventSubtype) {
+            if([e subtype] == NSTabletProximityEventSubtype) {
                 switch([e pointingDeviceType]) {
                     case NSEraserPointingDevice:
                         darwinTabletCurrent=darwinTabletEraser;
@@ -949,21 +949,19 @@ static void send_nsevent(NSEvent *e) {
             break;
 
 		case NSTabletProximity:
-                if([e subtype] != NSTabletProximityEventSubtype) {
-                    switch([e pointingDeviceType]) {
-                        case NSEraserPointingDevice:
-                            darwinTabletCurrent=darwinTabletEraser;
-                            break;
-                        case NSPenPointingDevice:
-                            darwinTabletCurrent=darwinTabletStylus;
-                            break;
-                        case NSCursorPointingDevice:
-                        case NSUnknownPointingDevice:
-                        default:
-                            darwinTabletCurrent=darwinTabletCursor;
-                            break;
-                    }
-                }
+            switch([e pointingDeviceType]) {
+                case NSEraserPointingDevice:
+                    darwinTabletCurrent=darwinTabletEraser;
+                    break;
+                case NSPenPointingDevice:
+                    darwinTabletCurrent=darwinTabletStylus;
+                    break;
+                case NSCursorPointingDevice:
+                case NSUnknownPointingDevice:
+                default:
+                    darwinTabletCurrent=darwinTabletCursor;
+                    break;
+            }
                     
 			DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                       pointer_x, pointer_y);
commit c661c6ae7a9cd981f914484aa4c3007922280def
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Sep 4 08:07:32 2008 -0700

    XQuartz: Remove decls of crashtracer strings that we don't use anymore in here
    (cherry picked from commit 4a653c6bfd270f2960a8c7e726e7628cfc3c9051)

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 35bcba0..ff773ef 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -131,13 +131,6 @@ RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state)
   pWin->rootlessUnhittable = winRec->is_offscreen;
 }
 
-#ifdef XQUARTZ
-#include <string.h>
-extern char *__crashreporter_info__;
-extern const char *__crashreporter_info__base;
-extern int __crashreporter_info__len;
-#endif
-
 void RootlessNativeWindowMoved (WindowPtr pWin) {
     xp_box bounds;
     int sx, sy, err;
commit 54162aca404a7de2e560cc2aea01445e14742efe
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Sep 4 05:18:31 2008 -0700

    XQuartz: Fixed a crash in RootlessNativeWindowMoved
    (cherry picked from commit a16048cec08e173ce42a78a77704f5fdfcb4480f)

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index f9ae0ea..35bcba0 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -143,38 +143,17 @@ void RootlessNativeWindowMoved (WindowPtr pWin) {
     int sx, sy, err;
     XID vlist[2];
     Mask mask;
-    ClientPtr client, pClient;
+    ClientPtr pClient;
     RootlessWindowRec *winRec;
-
-#ifdef XQUARTZ
-    /* We're seeing a crash here, but I'm not sure what's causing it... so putting in some debugging */
-    snprintf(__crashreporter_info__, __crashreporter_info__len,
-             "%s\n\RootlessNativeWindowMoved debug data\npWin=%p\n",
-             __crashreporter_info__base, pWin);
-    ErrorF("RootlessNativeWindowMoved debug data\npWin=%p\n", pWin);
-#endif
     
     winRec = WINREC(pWin);
-
-#ifdef XQUARTZ
-    /* We're seeing a crash here, but I'm not sure what's causing it... so putting in some debugging */
-    snprintf(__crashreporter_info__, __crashreporter_info__len, "%swinRec=%p\nwinRec->wid=%d\n", __crashreporter_info__, winRec, winRec ? (int)winRec->wid : 0);
-    ErrorF("winRec=%p\nwinRec->wid=%d\n", winRec, winRec ? (int)winRec->wid : 0);
-#endif
     
     if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return;
     
-#ifdef XQUARTZ
-    /* We're seeing a crash here, but I'm not sure what's causing it... so putting in some debugging */
-    snprintf(__crashreporter_info__, __crashreporter_info__len, "%spWin->drawable.pScreen=%p\npWin->drawable.pScreen->myNum=%d\n", __crashreporter_info__, pWin->drawable.pScreen, pWin->drawable.pScreen ? pWin->drawable.pScreen->myNum : 0);
-    ErrorF("pWin->drawable.pScreen=%p\npWin->drawable.pScreen->myNum=%d\n", pWin->drawable.pScreen, pWin->drawable.pScreen ? pWin->drawable.pScreen->myNum : 0);
-#endif
-    
     sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
     sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
     
     /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
-    
     vlist[0] = (INT16) bounds.x1 - sx;
     vlist[1] = (INT16) bounds.y1 - sy;
     mask = CWX | CWY;
@@ -190,7 +169,7 @@ void RootlessNativeWindowMoved (WindowPtr pWin) {
      notification-response feedback loops) */
     
     no_configure_window = TRUE;
-    ConfigureWindow (pWin, mask, vlist, client);
+    ConfigureWindow (pWin, mask, vlist, pClient);
     no_configure_window = FALSE;
 }
 


More information about the xorg-commit mailing list