xserver: Branch 'xorg-server-1.5-apple' - 23 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Sep 26 12:31:43 PDT 2008


 Xext/panoramiX.c                 |   17 +
 Xext/xevie.c                     |   31 +++
 composite/compinit.c             |    3 
 configure.ac                     |    8 
 doc/Xserver.man.pre              |    2 
 exa/exa.c                        |   10 +
 glx/Makefile.am                  |    6 
 hw/xfree86/doc/man/Xorg.man.pre  |    2 
 hw/xfree86/xaa/xaaFillPoly.c     |    8 
 hw/xquartz/X11Application.h      |    1 
 hw/xquartz/X11Application.m      |   78 ++++++--
 hw/xquartz/darwinEvents.c        |   13 -
 hw/xquartz/pbproxy/main.m        |    6 
 hw/xquartz/pbproxy/pbproxy.h     |    3 
 hw/xquartz/pbproxy/x-input.m     |    9 
 hw/xquartz/pbproxy/x-selection.h |    4 
 hw/xquartz/pbproxy/x-selection.m |  376 +++++++++++++++++++++------------------
 hw/xquartz/quartzKeyboard.c      |   75 +++----
 hw/xquartz/quartzKeyboard.h      |    4 
 randr/rrcrtc.c                   |   11 +
 randr/rrproperty.c               |   58 +++++-
 randr/rrsdispatch.c              |  215 +++++++++++++++-------
 randr/rrxinerama.c               |   18 +
 23 files changed, 614 insertions(+), 344 deletions(-)

New commits:
commit 0e089bdbc1da9c6d2f770e1bae597a5081df043b
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Thu Sep 25 14:16:20 2008 -0600

    XQuartz: pbproxy: Fix another STRING bug.
    
    Fix the usage of the NSString cStringUsingEncoding: - it doesn't NUL
    terminate the string, which lead to a bus error.  So, we use
    lengthOfBytesUsingEncoding: to get the length in bytes instead of
    strlen().
    (cherry picked from commit 6333d619e747c3b6bd3ba7557e35c0e5f6daa40f)

diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 14f6967..b141db0 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -528,7 +528,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     pbtypes = [pb types];
     if (pbtypes)
     {
-	long list[6];
+	long list[6]; /* Don't forget to increase this if we handle more types! */
         long count = 0;
  	
 	if ([pbtypes containsObject:NSStringPboardType])
@@ -619,7 +619,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     {
 	DB ("Latin-1\n");
 	bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
-	length = strlen (bytes);
+	/*WARNING: bytes is not NUL-terminated. */
+	length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
     }
 
     DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
@@ -760,7 +761,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    [self send_reply:&reply];
 	    return;
 	}
-	/*FIXME Why is [bmimage retainCount] 2 here? */
 
 	DB ("bmimage retainCount after initWithData %u\n", [bmimage retainCount]);
 
commit 191d6656a00d334e1f63ab215cc55d377926ce74
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Thu Sep 25 12:29:57 2008 -0600

    XQuartz: pbproxy: Fix a bug that rxvt brought out in STRING copying.  Now I can copy and paste to/from rxvt correctly.
    (cherry picked from commit 82a4dc5f0f31a7911ee1cce5d1b162077befa811)

diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 9556032..14f6967 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -890,8 +890,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	return;
     }
 
-    DB ("e->selection %s\n", XGetAtomName (x_dpy, e->selection));
-    DB ("e->property %s\n", XGetAtomName (x_dpy, e->property));
+#if 0
+    printf ("e->selection %s\n", XGetAtomName (x_dpy, e->selection));
+    printf ("e->property %s\n", XGetAtomName (x_dpy, e->property));
+#endif
 
     if ([self is_incr_type:e]) 
     {
@@ -1114,11 +1116,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
 
-    if (nil != pbtypes)
+    if (nil == pbtypes)
     {
-	[pb declareTypes:pbtypes owner:nil];
-	[pb setString:string forType:NSStringPboardType];
+	[string autorelease];
+	return;
     }
+
+    [pb declareTypes:pbtypes owner:nil];
+    [pb setString:string forType:NSStringPboardType];
     [string autorelease];
 }
 
@@ -1138,7 +1143,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	free_propdata (pdata);
 	return;
     }
- 
+
+#if 0
+    if (None != request_atom)
+	printf ("request_atom %s\n", XGetAtomName (x_dpy, request_atom));
+	       
+    printf ("type %s\n", XGetAtomName (x_dpy, type));
+#endif
+
     if (request_atom == atoms->targets && type == atoms->atom)
     {
 	[self handle_targets:selection propdata:pdata];
@@ -1159,7 +1171,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     {
 	[self handle_string:pdata pasteboard:pb];
     } 
- 
+    
     free_propdata(pdata);
 
     [self copy_completed:selection];
@@ -1244,6 +1256,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     atoms->clipboard = XInternAtom (x_dpy, "CLIPBOARD", False);
     atoms->text = XInternAtom (x_dpy, "TEXT", False);
     atoms->utf8_string = XInternAtom (x_dpy, "UTF8_STRING", False);
+    atoms->string = XInternAtom (x_dpy, "STRING", False);
     atoms->targets = XInternAtom (x_dpy, "TARGETS", False);
     atoms->multiple = XInternAtom (x_dpy, "MULTIPLE", False);
     atoms->cstring = XInternAtom (x_dpy, "CSTRING", False);
commit cbc9389dd37d84899ee1dcec762b3c5e2bba2357
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 24 22:51:03 2008 -0700

    XQuartz: Fixed threading issue with TSM.
    (cherry picked from commit 93ab4e0071670bb80bfa1170dd97ed9d6d51c67a)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index ce3fa7b..0caaba8 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -56,7 +56,6 @@
 - (void) prefs_synchronize;
 
 - (OSX_BOOL) x_active;
-
 @end
 
 extern X11Application *X11App;
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 213d9ed..0436db8 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -39,6 +39,7 @@
 
 #include "darwin.h"
 #include "darwinEvents.h"
+#include "quartzKeyboard.h"
 #include "quartz.h"
 #define _APPLEWM_SERVER_
 #include "X11/extensions/applewm.h"
@@ -61,6 +62,8 @@
 int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
+static TISInputSourceRef last_key_layout;
+
 extern int darwinFakeButtons;
 extern Bool enable_stereo;
 
@@ -163,8 +166,7 @@ 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 (unless using the old
-	 keymapping files) */
+	 have it activated while X is active */
     static TSMDocumentID x11_document;
 	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
@@ -589,8 +591,8 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 
 - (void) prefs_set_boolean:(NSString *)key value:(int)value {
   CFPreferencesSetValue ((CFStringRef) key,
-			 (CFTypeRef) value ? kCFBooleanTrue
-			 : kCFBooleanFalse, CFSTR (APP_PREFS),
+			 (CFTypeRef) (value ? kCFBooleanTrue
+			 : kCFBooleanFalse), CFSTR (APP_PREFS),
 			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
   
 }
@@ -847,9 +849,21 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
     aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
     NSMaxY([[NSScreen mainScreen] visibleFrame]);
 
+    /* Set the key layout seed before we start the server */
+    last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
+    
+    if(!last_key_layout) {
+        fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
+    }
+
+    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+    if (!QuartzReadSystemKeymap(&keyInfo)) {
+        fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n");
+    }
+
     /* Tell the server thread that it can proceed */
     QuartzInitServer(argc, argv, envp);
-    
+           
     [NSApp run];
     /* not reached */
 }
@@ -880,12 +894,12 @@ static void send_nsevent(NSEvent *e) {
 	NSWindow *window;
 	int pointer_x, pointer_y, ev_button, ev_type;
 	float pressure, tilt_x, tilt_y;
-
+    
 	/* convert location to be relative to top-left of primary display */
 	location = [e locationInWindow];
 	window = [e window];
 	screen = [[[NSScreen screens] objectAtIndex:0] frame];
-
+    
     if (window != nil)	{
 		NSRect frame = [window frame];
 		pointer_x = location.x + frame.origin.x;
@@ -895,18 +909,18 @@ static void send_nsevent(NSEvent *e) {
 		pointer_x = location.x;
 		pointer_y = (screen.origin.y + screen.size.height) - location.y;
 	}
-
+    
 	pressure = 0;  // for tablets
 	tilt_x = 0;
 	tilt_y = 0;
-
+    
     /* 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]);
-
+    
 	switch ([e type]) {
 		case NSLeftMouseDown:     ev_button=1; ev_type=ButtonPress;   goto handle_mouse;
 		case NSOtherMouseDown:    ev_button=2; ev_type=ButtonPress;   goto handle_mouse;
@@ -919,7 +933,7 @@ static void send_nsevent(NSEvent *e) {
 		case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify;  goto handle_mouse;
 		case NSMouseMoved:        ev_button=0; ev_type=MotionNotify;  goto handle_mouse;
         case NSTabletPoint:       ev_button=0; ev_type=MotionNotify;  goto handle_mouse;
-
+            
         handle_mouse:
 			if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
                 pressure = [e pressure];
@@ -941,16 +955,16 @@ static void send_nsevent(NSEvent *e) {
                         darwinTabletCurrent=darwinTabletCursor;
                         break;
                 }
-
+                
                 DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                           pointer_x, pointer_y);
             }
-
+            
             DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
                                     pressure, tilt_x, tilt_y);
-
+            
             break;
-
+            
 		case NSTabletProximity:
             switch([e pointingDeviceType]) {
                 case NSEraserPointingDevice:
@@ -965,20 +979,44 @@ static void send_nsevent(NSEvent *e) {
                     darwinTabletCurrent=darwinTabletCursor;
                     break;
             }
-                    
+            
 			DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                       pointer_x, pointer_y);
             break;
-
+            
 		case NSScrollWheel:
 			DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
                                    pressure, tilt_x, tilt_y);
             break;
-
-		case NSKeyDown: case NSKeyUp:
+            
+        case NSKeyDown: case NSKeyUp:
+            if(darwinSyncKeymap) {
+                TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource();
+                TISInputSourceRef clear;
+                if (CFEqual(key_layout, last_key_layout)) {
+                    CFRelease(key_layout);
+                } else {
+                    /* Swap/free thread-safely */
+                    clear = last_key_layout;
+                    last_key_layout = key_layout;
+                    CFRelease(clear);
+
+                    /* Update keyInfo */
+                    pthread_mutex_lock(&keyInfo_mutex);
+                    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+                    if (!QuartzReadSystemKeymap(&keyInfo)) {
+                        fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n");
+                    }
+                    pthread_mutex_unlock(&keyInfo_mutex);
+                    
+                    /* Tell server thread to deal with new keyInfo */
+                    DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+                }
+            }
+            
             DarwinSendKeyboardEvents(([e type] == NSKeyDown) ? KeyPress : KeyRelease, [e keyCode]);
             break;
-
+            
         default: break; /* for gcc */
 	}	
 }
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b468ea0..b37248a 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -473,19 +473,6 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 		return;
 	}
 
-	if (darwinSyncKeymap) {
-		/* See if keymap has changed. */
-
-		static unsigned int last_seed;
-		unsigned int this_seed;
-
-		this_seed = QuartzSystemKeymapSeed();
-		if (this_seed != last_seed) {
-			last_seed = this_seed;
-			DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
-		}
-	}
-
     darwinEvents_lock(); {
         num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
         for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index cee582b..cd46fb2 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -52,6 +52,8 @@
 #include "quartzKeyboard.h"
 #include "quartzAudio.h"
 
+#include "threadSafety.h"
+
 #ifdef NDEBUG
 #undef NDEBUG
 #include <assert.h>
@@ -59,6 +61,7 @@
 #else
 #include <assert.h>
 #endif
+#include <pthread.h>
 
 #include "xkbsrv.h"
 #include "exevents.h"
@@ -304,6 +307,7 @@ const static struct {
 };
 
 darwinKeyboardInfo keyInfo;
+pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 {
@@ -411,18 +415,16 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
  *  it to an equivalent X keyboard map and modifier map.
  */
 static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
-    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
-
-    if (!QuartzReadSystemKeymap(&keyInfo)) {
-        FatalError("Could not build a valid keymap.");
-    }
-
+    pthread_mutex_lock(&keyInfo_mutex);
+    
     DarwinBuildModifierMaps(&keyInfo);
 
     keySyms->map        = keyInfo.keyMap;
     keySyms->mapWidth   = GLYPHS_PER_KEY;
     keySyms->minKeyCode = MIN_KEYCODE;
     keySyms->maxKeyCode = MAX_KEYCODE;
+
+    pthread_mutex_unlock(&keyInfo_mutex);
 }
 
 void QuartzXkbUpdate(DeviceIntPtr pDev) {
@@ -450,27 +452,27 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
     assert( darwinParamConnect = NXOpenEventStatus() );
 
     DarwinLoadKeyboardMapping(&keySyms);
-    /* Initialize the seed, so we don't reload the keymap unnecessarily
-       (and possibly overwrite xinitrc changes) */
-    QuartzSystemKeymapSeed();
-
 #ifdef XQUARTZ_USE_XKB
 	XkbComponentNamesRec names;
 	bzero(&names, sizeof(names));
     /* We need to really have rules... or something... */
     XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
+    pthread_mutex_lock(&keyInfo_mutex);
     assert(XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, keyInfo.modMap,
                                         QuartzBell, DarwinChangeKeyboardControl));
 	assert(SetKeySymsMap(&pDev->key->curKeySyms, &keySyms));
 	assert(keyInfo.modMap!=NULL);
 	assert(pDev->key->modifierMap!=NULL);
 	memcpy(pDev->key->modifierMap, keyInfo.modMap, sizeof(keyInfo.modMap));
+    pthread_mutex_unlock(&keyInfo_mutex);
 	
 	QuartzXkbUpdate(pDev);
 #else
+    pthread_mutex_lock(&keyInfo_mutex);
     assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
                                       keyInfo.modMap, QuartzBell,
                                       DarwinChangeKeyboardControl ));
+    pthread_mutex_unlock(&keyInfo_mutex);
     SwitchCoreKeyboard(pDev);
 #endif
 }
@@ -492,11 +494,14 @@ void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev,
         if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
         xfree(pDev->key);
     }
-    
+
+    pthread_mutex_lock(&keyInfo_mutex);
     if (!InitKeyClassDeviceStruct(pDev, &keySyms, keyInfo.modMap)) {
         DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
+        pthread_mutex_unlock(&keyInfo_mutex);
         return;
     }
+    pthread_mutex_unlock(&keyInfo_mutex);
 
     SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
     SendMappingNotify(MappingModifier, 0, 0, 0);
@@ -521,7 +526,12 @@ void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev,
  *      Returns 0 if key+side is not a known modifier.
  */
 int DarwinModifierNXKeyToNXKeycode(int key, int side) {
-    return keyInfo.modifierKeycodes[key][side];
+    int retval;
+    pthread_mutex_lock(&keyInfo_mutex);
+    retval = keyInfo.modifierKeycodes[key][side];
+    pthread_mutex_unlock(&keyInfo_mutex);
+
+    return retval;
 }
 
 /*
@@ -532,6 +542,7 @@ int DarwinModifierNXKeyToNXKeycode(int key, int side) {
 int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
     int key, side;
 
+    pthread_mutex_lock(&keyInfo_mutex);
     keycode += MIN_KEYCODE;
     // search modifierKeycodes for this keycode+side
     for (key = 0; key < NX_NUMMODIFIERS; key++) {
@@ -539,8 +550,13 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
             if (keyInfo.modifierKeycodes[key][side] == keycode) break;
         }
     }
-    if (key == NX_NUMMODIFIERS) return -1;
+    if (key == NX_NUMMODIFIERS) {
+        pthread_mutex_unlock(&keyInfo_mutex);
+        return -1;
+    }
     if (outSide) *outSide = side;
+
+    pthread_mutex_unlock(&keyInfo_mutex);
     return key;
 }
 
@@ -666,39 +682,6 @@ Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
     return 1;
 }
 
-/* TODO: Not thread safe */
-unsigned int QuartzSystemKeymapSeed(void) {
-    static unsigned int seed = 0;
-//#if defined(__x86_64__) || defined(__ppc64__)
-#if 1
-    static TISInputSourceRef last_key_layout = NULL;
-    TISInputSourceRef key_layout;
-
-    key_layout = TISCopyCurrentKeyboardLayoutInputSource();
-
-    if(last_key_layout) {
-        if (CFEqual(key_layout, last_key_layout)) {
-            CFRelease(key_layout);
-        } else {
-            seed++;
-            CFRelease(last_key_layout);
-            last_key_layout = key_layout;
-        }
-    } else {
-        last_key_layout = key_layout;
-    }
-#else
-    static KeyboardLayoutRef last_key_layout;
-    KeyboardLayoutRef key_layout;
-
-    KLGetCurrentKeyboardLayout (&key_layout);
-    if (key_layout != last_key_layout)
-        seed++;
-    last_key_layout = key_layout;
-#endif
-    return seed;
-}
-
 static inline UniChar macroman2ucs(unsigned char c) {
     /* Precalculated table mapping MacRoman-128 to Unicode. Generated
        by creating single element CFStringRefs then extracting the
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index d62a79d..eb79366 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -32,6 +32,8 @@
 #include "X11/keysym.h"
 #include "inputstr.h"
 
+#include <pthread.h>
+
 // Each key can generate 4 glyphs. They are, in order:
 // unshifted, shifted, modeswitch unshifted, modeswitch shifted
 #define GLYPHS_PER_KEY  4
@@ -47,10 +49,10 @@ typedef struct darwinKeyboardInfo_struct {
 
 /* These functions need to be implemented by Xquartz, XDarwin, etc. */
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
-unsigned int QuartzSystemKeymapSeed(void);
 
 /* Provided for darwinEvents.c */
 extern darwinKeyboardInfo keyInfo;
+extern pthread_mutex_t keyInfo_mutex;
 void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
 void DarwinKeyboardInit(DeviceIntPtr pDev);
 int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
commit d5db51954f9a00ece62188679aeac3d007914d72
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 24 18:57:36 2008 -0700

    XQuartz: pbproxy: Removed stray SPI include.
    (cherry picked from commit 2fb2bc77b804d7b63002c1423cb0bfc658eeee45)

diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 9bf19f0..32b325f 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -10,7 +10,6 @@
 #include <unistd.h> /*for getpid*/
 
 #include <X11/extensions/applewm.h>
-#include <HIServices/CoreDockServices.h>
 
 Display *x_dpy;
 int x_apple_wm_event_base, x_apple_wm_error_base;
commit 37f023c59f205ee42d444464e293e2c6a5661255
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 23 13:59:25 2008 -0600

    XQuartz: pbproxy: Fix 3 paths that could leak memory.
    
    2 of the paths leaked, when INCR transfers were done.  Now we
    are leak free according to the leaks program for all transfers
    I have tried so far.
    (cherry picked from commit aa98db576bc02f0765cb35d0282a894ba3778213)

diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 7e4bd7c..9556032 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -110,9 +110,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if(None == property)
 	return True;
     
-    do {
-	unsigned long newbuflen;
-	unsigned char *newbuf;
+    do 
+    {
+	unsigned long newbuflen = 0;
+	unsigned char *newbuf = NULL;
 	
 #ifdef TEST   
 	printf("bytesleft %lu\n", bytesleft);
@@ -122,8 +123,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 					   offset, length, delete, 
 					   AnyPropertyType,
 					   type, &format, &numitems, 
-					   &bytesleft, &chunk)) {
+					   &bytesleft, &chunk)) 
+	{
 	    DB ("Error while getting window property.\n");
+	    *pdata = null_propdata;
 	    free (buf);
 	    return True;
 	}
@@ -141,10 +144,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 #ifdef TEST
 	printf("chunkbytesize %zu\n", chunkbytesize);
 #endif
-	
 	newbuflen = buflen + chunkbytesize;
 	newbuf = realloc (buf, newbuflen);
-	if (NULL == newbuf) {
+
+	if (NULL == newbuf)
+	{
 	    XFree (chunk);
 	    free (buf);
 	    return True;
@@ -837,7 +841,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
     else if (e->target == atoms->multiple)
     {
-	/* This isn't finished, and may never be, unless I can find a good app. */
+	/*
+	 * This isn't finished, and may never be, unless I can find 
+	 * a good test app.
+	 */
 	[self send_multiple:e];
     } 
     else if (e->target == atoms->utf8_string)
@@ -954,14 +961,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	{
 	    /* We completed the transfer. */
 	    [self handle_selection:pending.selection type:type propdata:&pending.propdata];
+	    free_propdata(&pdata);
 	    pending.propdata = null_propdata;
 	    pending.requestor = None;
 	    pending.selection = None;
-	} 
+	}
 	else 
 	{
 	    [self append_to_pending:&pdata requestor:e->window];
-	}       
+	    free_propdata (&pdata);
+	}
     }
 }
 
@@ -1084,7 +1093,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     [pb declareTypes:pbtypes owner:nil];
     
     if (YES != [pb setString:string forType:NSStringPboardType]) {
-	DB ("_pasteboard setString:forType: failed!\n");
+	DB ("pasteboard setString:forType: failed!\n");
     }
     [string autorelease];
     DB ("done handling utf8 string\n");
@@ -1126,6 +1135,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if (nil == pb) 
     {
 	[self copy_completed:selection];
+	free_propdata (pdata);
 	return;
     }
  
commit d1b39134cdf843c00b1d64df37729d1fdc544383
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 23 12:39:32 2008 -0600

    XQuartz: pbproxy: Fix NSObject memory leaks by properly using the
    NSAutoreleasePool.   Now the usage is consistent.  In x_input_run()
    we create a pool, and release it after processing the XEvents.
    
    Add some getpid() output to main for debugging.  It needs a bit more
    testing before the next release.
    
    Don't retain the NSPasteboard as the old code did.  That may have
    contributed to the leak, and it made it so that we needed the
    NSAutoreleasePool created in main().
    
    Remove the _known_types, and _pasteboard instance variables from
    the x_selection class.  They aren't needed anymore.
    
    The leaks program now indicates 0 leaks after some usage.  I want
    to test further, but this seems much better, and my memory usage
    graph indicates it's not growing.
    (cherry picked from commit b245d84a72ee3929546cd11a6eba3c60fb4a4d95)

diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 6d49070..9bf19f0 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -7,6 +7,7 @@
 #import "x-selection.h"
 
 #include <pthread.h>
+#include <unistd.h> /*for getpid*/
 
 #include <X11/extensions/applewm.h>
 #include <HIServices/CoreDockServices.h>
@@ -130,9 +131,7 @@ static void signal_handler (int sig) {
 }
 
 int main (int argc, const char *argv[]) {
-    NSAutoreleasePool *pool;
-
-    pool = [[NSAutoreleasePool alloc] init];
+    printf("pid: %u\n", getpid());
     
     x_init ();
     
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index 5261212..fd59881 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -49,6 +49,13 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
 }
 
 void x_input_run (void) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    
+    if (nil == pool) 
+    {
+	fprintf(stderr, "unable to allocate/init auto release pool!\n");
+	return;
+    }
 
     while (XPending (x_dpy) != 0) {
         XEvent e;       
@@ -82,6 +89,8 @@ void x_input_run (void) {
 
 	XFlush(x_dpy);
     }
+
+    [pool release];
 }
 
 static int add_input_socket (int sock, CFOptionFlags callback_types,
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index 06910b4..1bb1f10 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -54,10 +54,6 @@ struct atom_list {
     /* The unmapped window we use for fetching selections. */
     Window _selection_window;
 
-    /* Cached general pasteboard and array of types we can handle. */
-    NSPasteboard *_pasteboard;
-    NSArray *_known_types;
-
     /* Last time we declared anything on the pasteboard. */
     int _my_last_change;
 
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 5e40613..7e4bd7c 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -302,10 +302,18 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 {
     static NSInteger changeCount;
     NSInteger countNow;
+    NSPasteboard *pb;
 
     TRACE ();
 
-    countNow = [_pasteboard changeCount];
+    pb = [NSPasteboard generalPasteboard];
+
+    if (nil == pb)
+    {
+	return;
+    }
+
+    countNow = [pb changeCount];
 
     if (countNow != changeCount)
     {
@@ -317,8 +325,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
 
 #if 0
-    if ([_pasteboard changeCount] != _my_last_change)
-    {
 	/*gstaplin: we should perhaps investigate something like this branch above...*/
 	if ([_pasteboard availableTypeFromArray: _known_types] != nil)
 	{
@@ -330,7 +336,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    XSetSelectionOwner (x_dpy, XA_PRIMARY,
 				_selection_window, timestamp);
 	}
-    }
 #endif
 }
 
@@ -379,7 +384,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 }
 
 /*
- *
+ * Set pbproxy as owner of the SELECTION_MANAGER selection.
+ * This prevents tools like xclipboard from causing havoc.
  */
 - (void) set_clipboard_manager
 {
@@ -508,19 +514,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
  * (in Latin-1 encoding).  The requestor can then make the choice based on
  * the list.
  */
-- (void) send_targets:(XSelectionRequestEvent *)e
+- (void) send_targets:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
 {
     XEvent reply;
     NSArray *pbtypes;
 
     [self init_reply:&reply request:e];
 
-    pbtypes = [_pasteboard types];
+    pbtypes = [pb types];
     if (pbtypes)
     {
 	long list[6];
         long count = 0;
-	
+ 	
 	if ([pbtypes containsObject:NSStringPboardType])
 	{
 	    /* We have a string type that we can convert to UTF8, or Latin-1... */
@@ -561,7 +567,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 }
 
 
-- (void) send_string:(XSelectionRequestEvent *)e utf8:(BOOL)utf8
+- (void) send_string:(XSelectionRequestEvent *)e utf8:(BOOL)utf8 pasteboard:(NSPasteboard *)pb
 {
     XEvent reply;
     NSArray *pbtypes;
@@ -573,7 +579,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     [self init_reply:&reply request:e];
 
-    pbtypes = [_pasteboard types];
+    pbtypes = [pb types];
  
     if (![pbtypes containsObject:NSStringPboardType])
     {
@@ -583,7 +589,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
 
-    data = [_pasteboard stringForType:NSStringPboardType];
+    data = [pb stringForType:NSStringPboardType];
 
     if (nil == data)
     {
@@ -591,7 +597,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	return;
     }
 
-
     if (utf8) 
     {
 	bytes = [data UTF8String];
@@ -620,12 +625,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     
     reply.xselection.property = e->property;
 
-    DB ("data retainCount before release %u\n", [data retainCount]);
-    [data release];
     [self send_reply:&reply];
 }
 
-- (void) send_compound_text:(XSelectionRequestEvent *)e
+- (void) send_compound_text:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
 {
     XEvent reply;
     NSArray *pbtypes;
@@ -634,11 +637,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     
     [self init_reply:&reply request:e];
      
-    pbtypes = [_pasteboard types];
+    pbtypes = [pb types];
 
     if ([pbtypes containsObject: NSStringPboardType])
     {
-	NSString *data = [_pasteboard stringForType:NSStringPboardType];
+	NSString *data = [pb stringForType:NSStringPboardType];
 	if (nil != data)
 	{
 	    /*
@@ -671,7 +674,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    if (textprop.value)
  		XFree (textprop.value);
 
-	    [data release];
 	}
     }
     
@@ -696,7 +698,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 }
 
 
-- (void) send_image:(XSelectionRequestEvent *)e
+- (void) send_image:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
 {
     XEvent reply;
     NSArray *pbtypes;
@@ -708,7 +710,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     [self init_reply:&reply request:e];
 
-    pbtypes = [_pasteboard types];
+    pbtypes = [pb types];
 
     if (pbtypes) 
     {
@@ -734,7 +736,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	return;
     }
 
-    data = [_pasteboard dataForType:type];
+    data = [pb dataForType:type];
 
     if (nil == data)
     {
@@ -751,7 +753,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 	if (nil == bmimage)
 	{
-	    [data release];
 	    [self send_reply:&reply];
 	    return;
 	}
@@ -775,20 +776,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    
 	    DB ("changed property for %s\n", XGetAtomName (x_dpy, e->target));
 	    DB ("encdata retainCount %u\n", [encdata retainCount]);
-	    [encdata release];
-	    [bmimage release];
 	}
 	DB ("dict retainCount before release %u\n", [dict retainCount]);
-	
-	[dict release];
+	[dict autorelease];
 
-	
 	DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
-	/*FIXME Why on earth is retainCount 3? */
-	[bmimage release];
-	[bmimage release];
+	
+	[bmimage autorelease];
     }
-    [data release];
+
     [self send_reply:&reply];
 }
 
@@ -806,6 +802,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 /* Another client requested the data or targets of data available from the clipboard. */
 - (void)request_event:(XSelectionRequestEvent *)e
 {
+    NSPasteboard *pb;
+
     TRACE ();
 
     /* TODO We should also keep track of the time of the selection, and 
@@ -820,29 +818,39 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     /*TODO we need a COMPOUND_TEXT test app*/
     /*TODO we need a MULTIPLE test app*/
+
+    pb = [NSPasteboard generalPasteboard];
+    if (nil == pb) 
+    {
+	[self send_none:e];
+	return;
+    }
+    
+
     if (None != e->target)
 	DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
 
     if (e->target == atoms->targets) 
     {
 	/* The paste requestor wants to know what TARGETS we support. */
-	[self send_targets:e];
+	[self send_targets:e pasteboard:pb];
     }
     else if (e->target == atoms->multiple)
     {
+	/* This isn't finished, and may never be, unless I can find a good app. */
 	[self send_multiple:e];
     } 
     else if (e->target == atoms->utf8_string)
     {
-	[self send_string:e utf8:YES];
+	[self send_string:e utf8:YES pasteboard:pb];
     } 
     else if (e->target == atoms->string)
     {
-	[self send_string:e utf8:NO];
+	[self send_string:e utf8:NO pasteboard:pb];
     }
     else if (e->target == atoms->compound_text)
     {
-	[self send_compound_text:e];
+	[self send_compound_text:e pasteboard:pb];
     }
     else if (e->target == atoms->multiple)
     {
@@ -850,9 +858,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
     else if (e->target == atoms->image_png || e->target == atoms->image_jpeg)
     {
-	[self send_image:e];
+	[self send_image:e pasteboard:pb];
     }
-    else 
+    else
     {
 	[self send_none:e];
     }
@@ -983,7 +991,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 /* This handles the image type of selection (typically in CLIPBOARD). */
 /* We convert to a TIFF, so that other applications can paste more easily. */
-- (void) handle_image: (struct propdata *)pdata
+- (void) handle_image: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
 {
     NSArray *pbtypes;
     NSUInteger length;
@@ -1008,7 +1016,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (nil == bmimage)
     {
-	[data release];
+	[data autorelease];
 	DB ("unable to create NSBitmapImageRep!\n");
 	return;
     }
@@ -1024,10 +1032,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     @catch (NSException *e) 
     {
 	DB ("NSTIFFException!\n");
-	[data release];
-	[bmimage release];
-	/*WHY 2?*/
-	[bmimage release];
+	[data autorelease];
+	[bmimage autorelease];
 	return;
     }
     
@@ -1037,40 +1043,29 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (nil == pbtypes)
     {
-	[tiff release];
-	[data release];
-	[bmimage release];
-	/* WHY is the object with a retainCount of 2 after initWithData? */
-	[bmimage release];
+	[data autorelease];
+	[bmimage autorelease];
 	return;
     }
 
- 
-    [_pasteboard declareTypes:pbtypes owner:self];
-    if (YES != [_pasteboard setData:tiff forType:NSTIFFPboardType])
+    [pb declareTypes:pbtypes owner:nil];
+    if (YES != [pb setData:tiff forType:NSTIFFPboardType])
     {
 	DB ("writing pasteboard data failed!\n");
     }
 
-    [pbtypes release];
-    [data release];
-
-    DB ("tiff retainCount before release %u\n", [tiff retainCount]);
-    [tiff release];
+    [data autorelease];
 
     DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
-    /*WHY 3?*/
-    [bmimage release];
-    [bmimage release];
-    [bmimage release];
+    [bmimage autorelease];
 }
 
 /* This handles the UTF8_STRING type of selection. */
-- (void) handle_utf8_string: (struct propdata *)pdata
+- (void) handle_utf8_string:(struct propdata *)pdata pasteboard:(NSPasteboard *)pb
 {
     NSString *string;
     NSArray *pbtypes;
-
+ 
     TRACE ();
 
     string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSUTF8StringEncoding];
@@ -1078,26 +1073,25 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if (nil == string)
 	return;
 
-    DB ("string retainCount is %u\n", [string retainCount]);
-
     pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
 
-    if (nil != pbtypes)
+    if (nil == pbtypes)
     {
-	[_pasteboard declareTypes:pbtypes owner:self];
-
-	if (YES != [_pasteboard setString:string forType:NSStringPboardType]) {
-	    DB ("_pasteboard setString:forType: failed!\n");
-	}
-	[pbtypes release];
+	[string autorelease];
+	return;	
     }
-    [string release];
 
+    [pb declareTypes:pbtypes owner:nil];
+    
+    if (YES != [pb setString:string forType:NSStringPboardType]) {
+	DB ("_pasteboard setString:forType: failed!\n");
+    }
+    [string autorelease];
     DB ("done handling utf8 string\n");
 }
 
 /* This handles the STRING type, which should be in Latin-1. */
-- (void) handle_string: (struct propdata *)pdata
+- (void) handle_string: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
 {
     NSString *string; 
     NSArray *pbtypes;
@@ -1113,47 +1107,55 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (nil != pbtypes)
     {
-	[_pasteboard declareTypes:pbtypes owner:self];
-	[_pasteboard setString:string forType:NSStringPboardType];
-
-	DB ("pbtypes retainCount %u\n", [pbtypes retainCount]);
-	[pbtypes release];
+	[pb declareTypes:pbtypes owner:nil];
+	[pb setString:string forType:NSStringPboardType];
     }
-    [string release];
+    [string autorelease];
 }
 
 /* This is called when the selection is completely retrieved from another client. */
 /* Warning: this frees the propdata. */
 - (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata
 {
+    NSPasteboard *pb;
+
     TRACE ();
 
+    pb = [NSPasteboard generalPasteboard];
+
+    if (nil == pb) 
+    {
+	[self copy_completed:selection];
+	return;
+    }
+ 
     if (request_atom == atoms->targets && type == atoms->atom)
     {
 	[self handle_targets:selection propdata:pdata];
     } 
     else if (type == atoms->image_png)
     {
-	[self handle_image:pdata];
+	[self handle_image:pdata pasteboard:pb];
     } 
     else if (type == atoms->image_jpeg)
     {
-	[self handle_image:pdata];
+	[self handle_image:pdata pasteboard:pb];
     }
     else if (type == atoms->utf8_string) 
     {
-	[self handle_utf8_string:pdata];
+	[self handle_utf8_string:pdata pasteboard:pb];
     } 
     else if (type == atoms->string)
     {
-	[self handle_string:pdata];
+	[self handle_string:pdata pasteboard:pb];
     } 
  
     free_propdata(pdata);
-    
+
     [self copy_completed:selection];
 }
 
+
 - (void) copy_completed:(Atom)selection
 {
     TRACE ();
@@ -1243,11 +1245,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     atoms->compound_text = XInternAtom (x_dpy, "COMPOUND_TEXT", False);
     atoms->atom_pair = XInternAtom (x_dpy, "ATOM_PAIR", False);
 
-    _pasteboard = [[NSPasteboard generalPasteboard] retain];
-
-    //_known_types = [[NSArray arrayWithObject:NSStringPboardType] retain];
-    _known_types = nil;
-
     pixel = BlackPixel (x_dpy, DefaultScreen (x_dpy));
     _selection_window = XCreateSimpleWindow (x_dpy, DefaultRootWindow (x_dpy),
 					     0, 0, 1, 1, 0, pixel, pixel);
@@ -1269,14 +1266,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 - (void) dealloc
 {
-
-    [_pasteboard releaseGlobally];
-    [_pasteboard release];
-    _pasteboard = nil;
-
-    //[_known_types release];
-    _known_types = nil;
-
     if (None != _selection_window)
     {
 	XDestroyWindow (x_dpy, _selection_window);
commit 5d7506c52a24a993417e2a174dd41d1966179f94
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Mon Sep 22 17:36:21 2008 -0600

    XQuartz: pbproxy: Add a comment to pbproxy.h about how the DB()
    macro causes a leak (according to the leaks program).
    
    Attempt to fix several other leaks with release method calls.
    For some reason the process still grows more than it should...
    
    I will need to use some better methods than leaks, and malloc_history
    I suspect.  Whatever is leaking, it's hard to find.  I need to isolate
    the cases more.
    
    Add a missing image/jpeg branch.
    
    Remove read_prop_32 - it's not used.
    (cherry picked from commit 63a680354dcb545fef935ac97596dd35ceaed960)

diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index 56111f9..b8fbccb 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -12,7 +12,7 @@
 #include <X11/extensions/shape.h>
 #undef   Cursor
 
-#define DEBUG 1
+#define DEBUG 0
 
 /* from main.m */
 extern void x_set_is_active (BOOL state);
@@ -30,6 +30,7 @@ extern void x_input_run (void);
 #if DEBUG == 0
 # define DB(msg, args...) do {} while (0)
 #else
+/* BEWARE: this can cause a string memory leak, according to the leaks program. */
 # define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
 #endif
 
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 350b347..5e40613 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -1,7 +1,7 @@
 /* x-selection.m -- proxies between NSPasteboard and X11 selections
    $Id: x-selection.m,v 1.9 2006-07-07 18:24:28 jharper Exp $
 
-   Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+   Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
 
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation files
@@ -114,11 +114,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	unsigned long newbuflen;
 	unsigned char *newbuf;
 	
+#ifdef TEST   
+	printf("bytesleft %lu\n", bytesleft);
+#endif
+
 	if (Success != XGetWindowProperty (x_dpy, win, property,
 					   offset, length, delete, 
 					   AnyPropertyType,
 					   type, &format, &numitems, 
 					   &bytesleft, &chunk)) {
+	    DB ("Error while getting window property.\n");
 	    free (buf);
 	    return True;
 	}
@@ -127,7 +132,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	printf("format %d numitems %lu bytesleft %lu\n",
 	       format, numitems, bytesleft);
 	
-	printf("type %s\n", XGetAtomName(dis, *type));
+	printf("type %s\n", XGetAtomName (x_dpy, *type));
 #endif
 	
 	/* Format is the number of bits. */
@@ -151,6 +156,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	buflen = newbuflen;
 	/* offset is a multiple of 32 bits*/
 	offset += chunkbytesize / 4;
+
+#ifdef TEST
+	printf("bytesleft %lu\n", bytesleft);
+#endif
     } while (bytesleft > 0);
     
     pdata->data = buf;
@@ -160,40 +169,6 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 }
 
 
-static unsigned long *
-read_prop_32 (Window id, Atom prop, int *nitems_ret)
-{
-    int r, format;
-    Atom type;
-    unsigned long nitems, bytes_after;
-    unsigned char *data;
-
-    r = XGetWindowProperty (x_dpy, id, prop, 0, 0,
-			    False, AnyPropertyType, &type, &format,
-			    &nitems, &bytes_after, &data);
-
-    if (r == Success && bytes_after != 0)
-    {
-	XFree (data);
-	r = XGetWindowProperty (x_dpy, id, prop, 0,
-				(bytes_after / 4) + 1, False,
-				AnyPropertyType, &type, &format,
-				&nitems, &bytes_after, &data);
-    }
-
-    if (r != Success)
-	return NULL;
-
-    if (format != 32)
-    {
-	XFree (data);
-	return NULL;
-    }
-
-    *nitems_ret = nitems;
-    return (unsigned long *) data;
-}
-
 /* Implementation methods */
 
 /* This finds the preferred type from a TARGETS list.*/
@@ -201,7 +176,7 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 {
     Atom a = None;
     size_t i;
-    Bool png = False, utf8 = False, string = False;
+    Bool png = False, jpeg = False, utf8 = False, string = False;
 
     TRACE ();
 
@@ -219,6 +194,10 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	{
 	    png = True;
 	} 
+	else if (a == atoms->image_jpeg)
+	{
+	    jpeg = True;
+	}
 	else if (a == atoms->utf8_string)
 	{
 	    utf8 = True;
@@ -233,6 +212,9 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     if (png)
 	return atoms->image_png;
 
+    if (jpeg)
+	return atoms->image_jpeg;
+
     if (utf8)
 	return atoms->utf8_string;
 
@@ -309,7 +291,7 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     memcpy(newdata + pending.propdata.length, pdata->data, pdata->length);
     pending.propdata.data = newdata;
     pending.propdata.length = newlength;
-	
+    
     return False;
 }
 
@@ -583,51 +565,63 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 {
     XEvent reply;
     NSArray *pbtypes;
-    
+    NSString *data;
+    const char *bytes;
+    NSUInteger length;
+
     TRACE ();
 
     [self init_reply:&reply request:e];
 
     pbtypes = [_pasteboard types];
-
-    if ([pbtypes containsObject: NSStringPboardType])
+ 
+    if (![pbtypes containsObject:NSStringPboardType])
     {
-	NSString *data = [_pasteboard stringForType:NSStringPboardType];
-	if (nil != data)
-	{
-	    const char *bytes;
-	    NSUInteger length;
+	[self send_reply:&reply];
+	return;
+    }
 
-	    if (utf8) 
-	    {
-		bytes = [data UTF8String];
-		/*
-		 * We don't want the UTF-8 string length here.  
-		 * We want the length in bytes.
-		 */
-		length = strlen (bytes);
-
-		if (length < 50) {
-		    DB ("UTF-8: %s\n", bytes);
-		    DB ("UTF-8 length: %u\n", length); 
-		}
-	    } 
-	    else 
-	    {
-		DB ("Latin-1\n");
-		bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
-		length = strlen (bytes);
-	    }
+    DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
 
-	    DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
+    data = [_pasteboard stringForType:NSStringPboardType];
 
-	    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
-			     8, PropModeReplace, (unsigned char *) bytes, length);
-	    
-	    reply.xselection.property = e->property;
- 	}
+    if (nil == data)
+    {
+	[self send_reply:&reply];
+	return;
+    }
+
+
+    if (utf8) 
+    {
+	bytes = [data UTF8String];
+	/*
+	 * We don't want the UTF-8 string length here.  
+	 * We want the length in bytes.
+	 */
+	length = strlen (bytes);
+	
+	if (length < 50) {
+	    DB ("UTF-8: %s\n", bytes);
+	    DB ("UTF-8 length: %u\n", length); 
+	}
+    } 
+    else 
+    {
+	DB ("Latin-1\n");
+	bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
+	length = strlen (bytes);
     }
 
+    DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
+    
+    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+		     8, PropModeReplace, (unsigned char *) bytes, length);
+    
+    reply.xselection.property = e->property;
+
+    DB ("data retainCount before release %u\n", [data retainCount]);
+    [data release];
     [self send_reply:&reply];
 }
 
@@ -676,6 +670,8 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 
 	    if (textprop.value)
  		XFree (textprop.value);
+
+	    [data release];
 	}
     }
     
@@ -730,8 +726,8 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	imagetype = NSPNGFileType;
     else if (e->target == atoms->image_jpeg)
 	imagetype = NSJPEGFileType;
-        
-
+    
+    
     if (nil == type) 
     {
 	[self send_reply:&reply];
@@ -748,18 +744,21 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	 
     if (NSTIFFPboardType == type)
     {
-	NSBitmapImageRep *bmimage = [[NSBitmapImageRep alloc] initWithData:data];
+  	NSBitmapImageRep *bmimage = [[NSBitmapImageRep alloc] initWithData:data];
 	NSDictionary *dict;
 	NSData *encdata;
+	
 
-	if (nil == bmimage) 
+	if (nil == bmimage)
 	{
+	    [data release];
 	    [self send_reply:&reply];
 	    return;
 	}
+	/*FIXME Why is [bmimage retainCount] 2 here? */
+
+	DB ("bmimage retainCount after initWithData %u\n", [bmimage retainCount]);
 
-	DB ("have valid bmimage\n");
-	
 	dict = [[NSDictionary alloc] init];
 	encdata = [bmimage representationUsingType:imagetype properties:dict];
 	if (encdata)
@@ -769,18 +768,27 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	    
 	    length = [encdata length];
 	    bytes = [encdata bytes];
-		
-	    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
-				 8, PropModeReplace, bytes, length);
 	    
+	    XChangeProperty (x_dpy, e->requestor, e->property, e->target,
+			     8, PropModeReplace, bytes, length);
 	    reply.xselection.property = e->property;
 	    
 	    DB ("changed property for %s\n", XGetAtomName (x_dpy, e->target));
+	    DB ("encdata retainCount %u\n", [encdata retainCount]);
+	    [encdata release];
+	    [bmimage release];
 	}
+	DB ("dict retainCount before release %u\n", [dict retainCount]);
+	
 	[dict release];
-	[bmimage release];
-    } 
 
+	
+	DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
+	/*FIXME Why on earth is retainCount 3? */
+	[bmimage release];
+	[bmimage release];
+    }
+    [data release];
     [self send_reply:&reply];
 }
 
@@ -812,8 +820,8 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 
     /*TODO we need a COMPOUND_TEXT test app*/
     /*TODO we need a MULTIPLE test app*/
-
-    DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
+    if (None != e->target)
+	DB ("e->target %s\n", XGetAtomName (x_dpy, e->target));
 
     if (e->target == atoms->targets) 
     {
@@ -890,7 +898,7 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 
 	free_propdata (&pdata);
 
-	pending.requestor = e->requestor;
+      	pending.requestor = e->requestor;
 	pending.selection = e->selection;
 
 	DB ("set pending.requestor to 0x%lx\n", pending.requestor);
@@ -993,14 +1001,21 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	return;
     }
 
+    DB ("data retainCount before NSBitmapImageRep initWithData: %u\n",
+	[data retainCount]);
+
     bmimage = [[NSBitmapImageRep alloc] initWithData:data];
 
     if (nil == bmimage)
     {
+	[data release];
 	DB ("unable to create NSBitmapImageRep!\n");
 	return;
     }
 
+    DB ("data retainCount after NSBitmapImageRep initWithData: %u\n", 
+	[data retainCount]);
+
     @try 
     {
 	tiff = [bmimage TIFFRepresentation];
@@ -1011,9 +1026,13 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	DB ("NSTIFFException!\n");
 	[data release];
 	[bmimage release];
+	/*WHY 2?*/
+	[bmimage release];
 	return;
     }
     
+    DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
+
     pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
 
     if (nil == pbtypes)
@@ -1021,17 +1040,28 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 	[tiff release];
 	[data release];
 	[bmimage release];
+	/* WHY is the object with a retainCount of 2 after initWithData? */
+	[bmimage release];
+	return;
     }
 
+ 
     [_pasteboard declareTypes:pbtypes owner:self];
-    if (YES != [_pasteboard setData:data forType:NSTIFFPboardType])
+    if (YES != [_pasteboard setData:tiff forType:NSTIFFPboardType])
     {
 	DB ("writing pasteboard data failed!\n");
     }
 
     [pbtypes release];
     [data release];
+
+    DB ("tiff retainCount before release %u\n", [tiff retainCount]);
     [tiff release];
+
+    DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
+    /*WHY 3?*/
+    [bmimage release];
+    [bmimage release];
     [bmimage release];
 }
 
@@ -1048,6 +1078,8 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     if (nil == string)
 	return;
 
+    DB ("string retainCount is %u\n", [string retainCount]);
+
     pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
 
     if (nil != pbtypes)
@@ -1083,9 +1115,10 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     {
 	[_pasteboard declareTypes:pbtypes owner:self];
 	[_pasteboard setString:string forType:NSStringPboardType];
+
+	DB ("pbtypes retainCount %u\n", [pbtypes retainCount]);
 	[pbtypes release];
     }
-
     [string release];
 }
 
@@ -1212,7 +1245,8 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
 
     _pasteboard = [[NSPasteboard generalPasteboard] retain];
 
-    _known_types = [[NSArray arrayWithObject:NSStringPboardType] retain];
+    //_known_types = [[NSArray arrayWithObject:NSStringPboardType] retain];
+    _known_types = nil;
 
     pixel = BlackPixel (x_dpy, DefaultScreen (x_dpy));
     _selection_window = XCreateSimpleWindow (x_dpy, DefaultRootWindow (x_dpy),
@@ -1240,7 +1274,7 @@ read_prop_32 (Window id, Atom prop, int *nitems_ret)
     [_pasteboard release];
     _pasteboard = nil;
 
-    [_known_types release];
+    //[_known_types release];
     _known_types = nil;
 
     if (None != _selection_window)
commit 86fa42ed82fe2fd6246caa01a511792a2a2b93ae
Merge: 0a55ed3... af8cef4...
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Sep 26 12:29:44 2008 -0700

    Merge branch 'server-1.5-branch' into xorg-server-1.5-apple

diff --cc configure.ac
index 7faf7f3,ef276cc..1626ed1
--- a/configure.ac
+++ b/configure.ac
@@@ -528,8 -526,8 +528,8 @@@ AC_ARG_ENABLE(registry,       AS_HELP_S
  AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
  AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
  AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
- AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
 -AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--enable-xtrap], [Build XTrap extension (default: no)]), [XTRAP=$enableval], [XTRAP=no])
 -AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
++AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--enable-xtrap], [Build XTrap extension (default: disabled)]), [XTRAP=$enableval], [XTRAP=no])
 +AC_ARG_ENABLE(record,         AS_HELP_STRING([--enable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
  AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
  AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
  AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
commit af8cef461c4d107f7a03645568a635d0458da9b8
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Wed Sep 24 14:24:36 2008 +0100

    only build dri2 when DRI2 is enabled

diff --git a/glx/Makefile.am b/glx/Makefile.am
index 39b96d7..0214295 100644
--- a/glx/Makefile.am
+++ b/glx/Makefile.am
@@ -45,9 +45,13 @@ glapi_sources =					\
 	glthread.h				\
 	glprocs.h
 
+if DRI2
+GLXDRI_SOURCE = glxdri2.c
+endif
+
 libglxdri_la_SOURCES = \
         glxdri.c \
-        glxdri2.c \
+	$(GLXDRI2_SOURCE) \
 	glxdricommon.h \
         extension_string.c \
         extension_string.h
commit 97f688f2b4b8ebfba77be00db68c4e6a555a5d62
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 23 14:51:33 2008 -0400

    xserver 1.5.1

diff --git a/configure.ac b/configure.ac
index 51d8b14..ef276cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.5.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="3 September 2008"
+AC_INIT([xorg-server], 1.5.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="23 September 2008"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 68c575cb73fd6ff6c9c0ce29a3d8105da44abfcc
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 23 11:05:44 2008 -0400

    Move RELEASE_DATE below AC_INIT.
    
    Doing it the other way around clobbers the setting, which means you get
    a null release date string in the log.  Thanks autoconf!

diff --git a/configure.ac b/configure.ac
index 0262274..51d8b14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-RELEASE_DATE="3 September 2008"
 AC_INIT([xorg-server], 1.5.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="3 September 2008"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit dba26368e5dbdd35df97d38ed517d1248503ab51
Author: Peter Harris <peter.harris at hummingbird.com>
Date:   Thu Dec 20 15:58:01 2007 -0500

    Fix panoramiX request and reply swapping
    
     Fix panoramiX request and reply swapping
     Set window and screen values in panoramix replies
     Prevent buffer overrun in ProcPanoramiXGetScreenSize
    (cherry picked from commit 2b266eda6e23d16116f8a8e258192df353970279)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 2792dc7..8bc5c42 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -936,10 +936,11 @@ ProcPanoramiXGetState(ClientPtr client)
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
 	rep.state = !noPanoramiXExtension;
+	rep.window = stuff->window;
     	if (client->swapped) {
 	    swaps (&rep.sequenceNumber, n);
 	    swapl (&rep.length, n);
-	    swaps (&rep.state, n);
+	    swapl (&rep.window, n);
 	}	
 	WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
 	return client->noClientException;
@@ -963,10 +964,11 @@ ProcPanoramiXGetScreenCount(ClientPtr client)
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
 	rep.ScreenCount = PanoramiXNumScreens;
+	rep.window = stuff->window;
     	if (client->swapped) {
 	    swaps (&rep.sequenceNumber, n);
 	    swapl (&rep.length, n);
-	    swaps (&rep.ScreenCount, n);
+	    swapl (&rep.window, n);
 	}	
 	WriteToClient (client, sizeof (xPanoramiXGetScreenCountReply), (char *) &rep);
 	return client->noClientException;
@@ -980,6 +982,9 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
 	xPanoramiXGetScreenSizeReply	rep;
 	register int			n, rc;
 	
+	if (stuff->screen >= PanoramiXNumScreens)
+	    return BadMatch;
+
 	REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
 	rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
 	if (rc != Success)
@@ -991,11 +996,15 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
 		/* screen dimensions */
 	rep.width  = panoramiXdataPtr[stuff->screen].width; 
 	rep.height = panoramiXdataPtr[stuff->screen].height; 
+	rep.window = stuff->window;
+	rep.screen = stuff->screen;
     	if (client->swapped) {
 	    swaps (&rep.sequenceNumber, n);
 	    swapl (&rep.length, n);
-	    swaps (&rep.width, n);
-	    swaps (&rep.height, n);
+	    swapl (&rep.width, n);
+	    swapl (&rep.height, n);
+	    swapl (&rep.window, n);
+	    swapl (&rep.screen, n);
 	}	
 	WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep);
 	return client->noClientException;
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 240fca2..e6acd5e 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -138,10 +138,11 @@ ProcRRXineramaGetState(ClientPtr client)
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
     rep.state = active;
+    rep.window = stuff->window;
     if(client->swapped) {
        swaps (&rep.sequenceNumber, n);
        swapl (&rep.length, n);
-       swaps (&rep.state, n);
+       swapl (&rep.window, n);
     }
     WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
     return client->noClientException;
@@ -192,10 +193,11 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
     rep.ScreenCount = RRXineramaScreenCount (pWin->drawable.pScreen);
+    rep.window = stuff->window;
     if(client->swapped) {
        swaps(&rep.sequenceNumber, n);
        swapl(&rep.length, n);
-       swaps(&rep.ScreenCount, n);
+       swapl(&rep.window, n);
     }
     WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
     return client->noClientException;
@@ -223,11 +225,15 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
     rep.sequenceNumber = client->sequence;
     rep.width  = pRoot->drawable.width;
     rep.height = pRoot->drawable.height;
+    rep.window = stuff->window;
+    rep.screen = stuff->screen;
     if(client->swapped) {
        swaps(&rep.sequenceNumber, n);
        swapl(&rep.length, n);
-       swaps(&rep.width, n);
-       swaps(&rep.height, n);
+       swapl(&rep.width, n);
+       swapl(&rep.height, n);
+       swapl(&rep.window, n);
+       swapl(&rep.screen, n);
     }
     WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
     return client->noClientException;
@@ -351,6 +357,7 @@ SProcRRXineramaGetState(ClientPtr client)
     register int n;
     swaps (&stuff->length, n);
     REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+    swapl (&stuff->window, n);
     return ProcRRXineramaGetState(client);
 }
 
@@ -361,6 +368,7 @@ SProcRRXineramaGetScreenCount(ClientPtr client)
     register int n;
     swaps (&stuff->length, n);
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+    swapl (&stuff->window, n);
     return ProcRRXineramaGetScreenCount(client);
 }
 
@@ -371,6 +379,8 @@ SProcRRXineramaGetScreenSize(ClientPtr client)
     register int n;
     swaps (&stuff->length, n);
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+    swapl (&stuff->window, n);
+    swapl (&stuff->screen, n);
     return ProcRRXineramaGetScreenSize(client);
 }
 
commit ce6424853c2df2486ad99c0369974afc91a92993
Author: Julien Cristau <jcristau at debian.org>
Date:   Tue Sep 16 17:13:42 2008 +0200

    exa: disable shared pixmaps
    
    They got re-enabled in ee7c684f21d220d5e046bab31ae617a7d64d60f6
    ("Reimplement ShmPutImage.")
    (cherry picked from commit b4762c0245ed2966606171cf27f40aa745fdc76e)

diff --git a/exa/exa.c b/exa/exa.c
index ccf148a..72539c0 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -43,6 +43,10 @@
 DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKey;
 DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKey;
 
+#ifdef MITSHM
+static ShmFuncs exaShmFuncs = { NULL, NULL };
+#endif
+
 static _X_INLINE void*
 ExaGetPixmapAddress(PixmapPtr p)
 {
@@ -924,6 +928,12 @@ exaDriverInit (ScreenPtr		pScreen,
     }
 #endif
 
+#ifdef MITSHM
+    /*
+     * Don't allow shared pixmaps.
+     */
+    ShmRegisterFuncs(pScreen, &exaShmFuncs);
+#endif
     /*
      * Hookup offscreen pixmaps
      */
commit 37876602957924c7cff759a800eddd574ee2385a
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Sep 17 15:48:56 2008 -0700

    Conditionalize Composite-based backing store on pScreen->backingStoreSupport.

diff --git a/composite/compinit.c b/composite/compinit.c
index 49b2044..3bf77e0 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -119,7 +119,8 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
     pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
     ret = pScreen->ChangeWindowAttributes(pWin, mask);
 
-    if (ret && (mask & CWBackingStore)) {
+    if (ret && (mask & CWBackingStore) &&
+	    pScreen->backingStoreSupport != NotUseful) {
 	if (pWin->backingStore != NotUseful) {
 	    compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
 	    pWin->backStorage = TRUE;
commit 05fb2f9e1249d0b91bf4318cec4fb309217adff4
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Sep 3 19:14:22 2008 -0400

    xserver 1.5.0
    
    Drinkin' island is inside each of us, my son.

diff --git a/configure.ac b/configure.ac
index 6a0876b..0262274 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-RELEASE_DATE="23 July 2008"
-AC_INIT([xorg-server], 1.4.99.906, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="3 September 2008"
+AC_INIT([xorg-server], 1.5.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit f385303cd0242e3a7fded15f8b5c3d610c13ee41
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 2 15:43:15 2008 -0400

    Fix strict-aliasing silliness in XAA.
    (cherry picked from commit 613ce0955032fb032de0a3940752828d314f057a)

diff --git a/hw/xfree86/xaa/xaaFillPoly.c b/hw/xfree86/xaa/xaaFillPoly.c
index 23c2781..6f11e35 100644
--- a/hw/xfree86/xaa/xaaFillPoly.c
+++ b/hw/xfree86/xaa/xaaFillPoly.c
@@ -131,8 +131,8 @@ XAAIsEasyPolygon(
     *bottomY = 0;
 
     origin -= (origin & 0x8000) << 1;
-    vertex1 = *((int *) &extents->x1) - origin;
-    vertex2 = *((int *) &extents->x2) - origin /* - 0x00010001 */;
+    vertex1 = extents->x1 - origin;
+    vertex2 = extents->x2 - origin /* - 0x00010001 */;
                      /* I think this was an error in cfb ^ */
 
     if (shape == Convex) {
@@ -714,7 +714,7 @@ XAAFillPolygonStippled(
 	return;
     }
 
-    origin = *((int *)&pDraw->x);
+    origin = pDraw->x;
 
     switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
 		 origin, &topPoint, &y, &maxy, shape) ) {
@@ -867,7 +867,7 @@ XAAFillPolygonTiled(
 	return;
     }
 
-    origin = *((int *)&pDraw->x);
+    origin = pDraw->x;
 
     switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
 		 origin, &topPoint, &y, &maxy, shape) ) {
commit 6cb7f595b97e9442a79660bc639b2fc91842e19a
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Sep 3 14:59:24 2008 -0400

    Disable DRI2 by default.

diff --git a/configure.ac b/configure.ac
index d324bd5..6a0876b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -536,7 +536,7 @@ AC_ARG_ENABLE(xdmcp,          AS_HELP_STRING([--disable-xdmcp], [Build XDMCP ext
 AC_ARG_ENABLE(xdm-auth-1,     AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
 AC_ARG_ENABLE(glx,            AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
 AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
-AC_ARG_ENABLE(dri2,           AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval])
+AC_ARG_ENABLE(dri2,           AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: no)]), [DRI2=$enableval], [DRI2=no])
 AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
 AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
 AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
commit ed2248f673ed8993e678818c388203346a3614e0
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Sep 3 14:58:43 2008 -0400

    Disable XTrap build by default.

diff --git a/configure.ac b/configure.ac
index efef454..d324bd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -526,7 +526,7 @@ AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
-AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
+AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--enable-xtrap], [Build XTrap extension (default: no)]), [XTRAP=$enableval], [XTRAP=no])
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
 AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
commit 9bb4990c917cc512d39b5889e7bcecb5cfcbeb56
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Sep 1 19:45:30 2008 +0200

    Xevie: swap replies as necessary
    (cherry picked from commit b5cdcfa55c399e83d51242e93d4f25d8bc4fec1f)

diff --git a/Xext/xevie.c b/Xext/xevie.c
index 3fbe04d..1d51fd8 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -156,6 +156,7 @@ static
 int ProcXevieQueryVersion (register ClientPtr client)
 {
     xXevieQueryVersionReply rep;
+    int n;
 
     REQUEST_SIZE_MATCH (xXevieQueryVersionReq);
     rep.type = X_Reply;
@@ -163,6 +164,12 @@ int ProcXevieQueryVersion (register ClientPtr client)
     rep.sequence_number = client->sequence;
     rep.server_major_version = XEVIE_MAJOR_VERSION;
     rep.server_minor_version = XEVIE_MINOR_VERSION;
+    if (client->swapped) {
+	swaps(&rep.sequence_number, n);
+	swapl(&rep.length, n);
+	swaps(&rep.server_major_version, n);
+	swaps(&rep.server_minor_version, n);
+    }
     WriteToClient (client, sizeof (xXevieQueryVersionReply), (char *)&rep);
     return client->noClientException;
 }
@@ -171,6 +178,7 @@ static
 int ProcXevieStart (register ClientPtr client)
 {
     xXevieStartReply rep;
+    int n;
 
     REQUEST_SIZE_MATCH (xXevieStartReq);
     rep.pad1 = 0;
@@ -205,6 +213,10 @@ int ProcXevieStart (register ClientPtr client)
     rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
+    if (client->swapped) {
+	swaps(&rep.sequence_number, n);
+	swapl(&rep.length, n);
+    }
     WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
     return client->noClientException;
 }
@@ -213,6 +225,7 @@ static
 int ProcXevieEnd (register ClientPtr client)
 {
     xXevieEndReply rep;
+    int n;
 
     REQUEST_SIZE_MATCH (xXevieEndReq);
     
@@ -227,6 +240,10 @@ int ProcXevieEnd (register ClientPtr client)
     rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
+    if (client->swapped) {
+	swaps(&rep.sequence_number, n);
+	swapl(&rep.length, n);
+    }
     WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
     return client->noClientException;
 }
@@ -238,6 +255,7 @@ int ProcXevieSend (register ClientPtr client)
     xXevieSendReply rep;
     xEvent *xE;
     static unsigned char lastDetail = 0, lastType = 0;
+    int n;
 
     REQUEST_SIZE_MATCH (xXevieSendReq);
     
@@ -248,6 +266,10 @@ int ProcXevieSend (register ClientPtr client)
     rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
+    if (client->swapped) {
+	swaps(&rep.sequence_number, n);
+	swapl(&rep.length, n);
+    }
     WriteToClient (client, sizeof (xXevieSendReply), (char *)&rep);
 
     switch(xE->u.u.type) {
@@ -285,6 +307,7 @@ int ProcXevieSelectInput (register ClientPtr client)
 {
     REQUEST (xXevieSelectInputReq);
     xXevieSelectInputReply rep;
+    int n;
 
     REQUEST_SIZE_MATCH (xXevieSelectInputReq);
 
@@ -295,6 +318,10 @@ int ProcXevieSelectInput (register ClientPtr client)
     rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
+    if (client->swapped) {
+	swaps(&rep.sequence_number, n);
+	swapl(&rep.length, n);
+    }
     WriteToClient (client, sizeof (xXevieSelectInputReply), (char *)&rep);
     return client->noClientException;
 }
commit bcea1095da2d29f5812bd1adabac334cfca60355
Author: Thorvald Natvig <slicer at users.sourceforge.net>
Date:   Mon Sep 1 19:36:56 2008 +0200

    Xevie: always initialize rep.length (bug#17394)
    
    The XEvIE extension doesn't clear the rep.length field for any reply but
    the version check. Hence, if there is junk data in it and that is sent
    to the client, it hangs.
    
    X.Org bug#17394 (http://bugs.freedesktop.org/show_bug.cgi?id=17394)
    (cherry picked from commit d3ae193f4ac87530f2745f8cb5e7b70dd516881e)

diff --git a/Xext/xevie.c b/Xext/xevie.c
index 5e20bd9..3fbe04d 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -202,6 +202,7 @@ int ProcXevieStart (register ClientPtr client)
     
     xevieModifiersOn = FALSE;
 
+    rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
     WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
@@ -223,6 +224,7 @@ int ProcXevieEnd (register ClientPtr client)
         XevieEnd(xevieClientIndex);
     }
 
+    rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
     WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
@@ -243,6 +245,7 @@ int ProcXevieSend (register ClientPtr client)
         return BadAccess;
 
     xE = (xEvent *)&stuff->event;
+    rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
     WriteToClient (client, sizeof (xXevieSendReply), (char *)&rep);
@@ -289,6 +292,7 @@ int ProcXevieSelectInput (register ClientPtr client)
         return BadAccess;
 
     xevieMask = stuff->event_mask;
+    rep.length = 0;
     rep.type = X_Reply;
     rep.sequence_number = client->sequence;
     WriteToClient (client, sizeof (xXevieSelectInputReply), (char *)&rep);
commit 67ed1f23fe29affe14587fbb809d0e95197db78b
Author: Julien Cristau <jcristau at debian.org>
Date:   Thu Aug 21 01:32:03 2008 +0200

    Add swapped dispatch for randr 1.2 requests
    (cherry picked from commit 01264f17925005969c3b71ca945fc1014bcd8c8e)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 7c22437..ec65a04 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -894,6 +894,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
     RRCrtcPtr			crtc;
     int				n;
     unsigned long		len;
+    char			*extra;
     
     REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
     crtc = LookupCrtc (client, stuff->crtc, DixReadAccess);
@@ -902,6 +903,12 @@ ProcRRGetCrtcGamma (ClientPtr client)
     
     len = crtc->gammaSize * 3 * 2;
     
+    if (crtc->gammaSize) {
+	extra = xalloc(len);
+	if (!extra)
+	    return BadAlloc;
+    }
+
     reply.type = X_Reply;
     reply.sequenceNumber = client->sequence;
     reply.length = (len + 3) >> 2;
@@ -914,8 +921,10 @@ ProcRRGetCrtcGamma (ClientPtr client)
     WriteToClient (client, sizeof (xRRGetCrtcGammaReply), (char *) &reply);
     if (crtc->gammaSize)
     {
+	memcpy(extra, crtc->gammaRed, len);
 	client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write;
-	WriteSwappedDataToClient (client, len, (char *) crtc->gammaRed);
+	WriteSwappedDataToClient (client, len, extra);
+	xfree(extra);
     }
     return client->noClientException;
 }
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 4617064..429246c 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -398,12 +398,13 @@ ProcRRListOutputProperties (ClientPtr client)
 	int n;
 	swaps (&rep.sequenceNumber, n);
 	swapl (&rep.length, n);
+	swaps (&rep.nAtoms, n);
     }
     temppAtoms = pAtoms;
     for (prop = output->properties; prop; prop = prop->next)
 	*temppAtoms++ = prop->propertyName;
 
-    WriteReplyToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
+    WriteToClient(client, sizeof(xRRListOutputPropertiesReply), (char*)&rep);
     if (numProps)
     {
         client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
@@ -420,6 +421,7 @@ ProcRRQueryOutputProperty (ClientPtr client)
     xRRQueryOutputPropertyReply	    rep;
     RROutputPtr			    output;
     RRPropertyPtr		    prop;
+    char *extra;
     
     REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
 
@@ -432,6 +434,11 @@ ProcRRQueryOutputProperty (ClientPtr client)
     if (!prop)
 	return BadName;
     
+    if (prop->num_valid) {
+	extra = xalloc(prop->num_valid * sizeof(INT32));
+	if (!extra)
+	    return BadAlloc;
+    }
     rep.type = X_Reply;
     rep.length = prop->num_valid;
     rep.sequenceNumber = client->sequence;
@@ -444,12 +451,14 @@ ProcRRQueryOutputProperty (ClientPtr client)
 	swaps (&rep.sequenceNumber, n);
 	swapl (&rep.length, n);
     }
-    WriteReplyToClient (client, sizeof (xRRQueryOutputPropertyReply), &rep);
+    WriteToClient (client, sizeof (xRRQueryOutputPropertyReply), (char*)&rep);
     if (prop->num_valid)
     {
+        memcpy(extra, prop->valid_values, prop->num_valid * sizeof(INT32));
         client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
         WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32),
-				 prop->valid_values);
+				 extra);
+        xfree(extra);
     }
     return(client->noClientException);
 }
@@ -564,6 +573,7 @@ ProcRRGetOutputProperty (ClientPtr client)
     unsigned long		n, len, ind;
     RROutputPtr			output;
     xRRGetOutputPropertyReply	reply;
+    char			*extra;
 
     REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
     if (stuff->delete)
@@ -603,7 +613,16 @@ ProcRRGetOutputProperty (ClientPtr client)
 	reply.bytesAfter = 0;
 	reply.propertyType = None;
 	reply.format = 0;
-	WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
+	if (client->swapped) {
+	    int n;
+
+	    swaps(&reply.sequenceNumber, n);
+	    swapl(&reply.length, n);
+	    swapl(&reply.propertyType, n);
+	    swapl(&reply.bytesAfter, n);
+	    swapl(&reply.nItems, n);
+	}
+	WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
 	return(client->noClientException);
     }
 
@@ -627,7 +646,16 @@ ProcRRGetOutputProperty (ClientPtr client)
 	reply.length = 0;
 	reply.nItems = 0;
 	reply.propertyType = prop_value->type;
-	WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
+	if (client->swapped) {
+	    int n;
+
+	    swaps(&reply.sequenceNumber, n);
+	    swapl(&reply.length, n);
+	    swapl(&reply.propertyType, n);
+	    swapl(&reply.bytesAfter, n);
+	    swapl(&reply.nItems, n);
+	}
+	WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
 	return(client->noClientException);
     }
 
@@ -648,6 +676,11 @@ ProcRRGetOutputProperty (ClientPtr client)
 
     len = min(n - ind, 4 * stuff->longLength);
 
+    if (len) {
+	extra = xalloc(len);
+	if (!extra)
+	    return BadAlloc;
+    }
     reply.bytesAfter = n - (ind + len);
     reply.format = prop_value->format;
     reply.length = (len + 3) >> 2;
@@ -670,16 +703,27 @@ ProcRRGetOutputProperty (ClientPtr client)
 	RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
     }
 
-    WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+    if (client->swapped) {
+	int n;
+
+	swaps(&reply.sequenceNumber, n);
+	swapl(&reply.length, n);
+	swapl(&reply.propertyType, n);
+	swapl(&reply.bytesAfter, n);
+	swapl(&reply.nItems, n);
+    }
+    WriteToClient(client, sizeof(xGenericReply), &reply);
     if (len)
     {
+	memcpy(extra, (char *)prop_value->data + ind, len);
 	switch (reply.format) {
 	case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break;
 	case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break;
 	default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
 	}
 	WriteSwappedDataToClient(client, len,
-				 (char *)prop_value->data + ind);
+				 extra);
+	xfree(extra);
     }
 
     if (stuff->delete && (reply.bytesAfter == 0))
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 4a6a6e4..80d16b7 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -84,191 +84,284 @@ SProcRRSelectInput (ClientPtr client)
 static int
 SProcRRGetScreenSizeRange (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetScreenSizeRangeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRSetScreenSize (ClientPtr client)
 {
+    int n;
     REQUEST(xRRSetScreenSizeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+    swaps(&stuff->width, n);
+    swaps(&stuff->height, n);
+    swapl(&stuff->widthInMillimeters, n);
+    swapl(&stuff->heightInMillimeters, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetScreenResources (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetScreenResourcesReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetOutputInfo (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetOutputInfoReq);;
-    
+
     REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->configTimestamp, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRListOutputProperties (ClientPtr client)
 {
+    int n;
     REQUEST(xRRListOutputPropertiesReq);
-    
+
     REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRQueryOutputProperty (ClientPtr client)
 {
+    int n;
     REQUEST(xRRQueryOutputPropertyReq);
-    
+
     REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->property, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRConfigureOutputProperty (ClientPtr client)
 {
+    int n;
     REQUEST(xRRConfigureOutputPropertyReq);
-    
-    REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq);
-    (void) stuff;
-    return BadImplementation; 
+
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->property, n);
+    SwapRestL(stuff);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRChangeOutputProperty (ClientPtr client)
 {
+    int n;
     REQUEST(xRRChangeOutputPropertyReq);
-    
-    REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq);
-    (void) stuff;
-    return BadImplementation; 
+
+    REQUEST_AT_LEAST_SIZE (xRRChangeOutputPropertyReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->property, n);
+    swapl(&stuff->type, n);
+    swapl(&stuff->nUnits, n);
+    switch(stuff->format) {
+	case 8:
+	    break;
+	case 16:
+	    SwapRestS(stuff);
+	    break;
+	case 32:
+	    SwapRestL(stuff);
+	    break;
+	default:
+	    client->errorValue = stuff->format;
+	    return BadValue;
+    }
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRDeleteOutputProperty (ClientPtr client)
 {
+    int n;
     REQUEST(xRRDeleteOutputPropertyReq);
     
     REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->property, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetOutputProperty (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetOutputPropertyReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->property, n);
+    swapl(&stuff->type, n);
+    swapl(&stuff->longOffset, n);
+    swapl(&stuff->longLength, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRCreateMode (ClientPtr client)
 {
+    int n;
+    xRRModeInfo *modeinfo;
     REQUEST(xRRCreateModeReq);
-    
-    REQUEST_SIZE_MATCH(xRRCreateModeReq);
-    (void) stuff;
-    return BadImplementation; 
+
+    REQUEST_AT_LEAST_SIZE(xRRCreateModeReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->window, n);
+
+    modeinfo = &stuff->modeInfo;
+    swapl(&modeinfo->id, n);
+    swaps(&modeinfo->width, n);
+    swaps(&modeinfo->height, n);
+    swapl(&modeinfo->dotClock, n);
+    swaps(&modeinfo->hSyncStart, n);
+    swaps(&modeinfo->hSyncEnd, n);
+    swaps(&modeinfo->hTotal, n);
+    swaps(&modeinfo->vSyncStart, n);
+    swaps(&modeinfo->vSyncEnd, n);
+    swaps(&modeinfo->vTotal, n);
+    swaps(&modeinfo->nameLength, n);
+    swapl(&modeinfo->modeFlags, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRDestroyMode (ClientPtr client)
 {
+    int n;
     REQUEST(xRRDestroyModeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRDestroyModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->mode, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRAddOutputMode (ClientPtr client)
 {
+    int n;
     REQUEST(xRRAddOutputModeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->mode, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRDeleteOutputMode (ClientPtr client)
 {
+    int n;
     REQUEST(xRRDeleteOutputModeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->output, n);
+    swapl(&stuff->mode, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetCrtcInfo (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetCrtcInfoReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->crtc, n);
+    swapl(&stuff->configTimestamp, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRSetCrtcConfig (ClientPtr client)
 {
+    int n;
     REQUEST(xRRSetCrtcConfigReq);
-    
-    REQUEST_SIZE_MATCH(xRRSetCrtcConfigReq);
-    (void) stuff;
-    return BadImplementation; 
+
+    REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->crtc, n);
+    swapl(&stuff->timestamp, n);
+    swapl(&stuff->configTimestamp, n);
+    swaps(&stuff->x, n);
+    swaps(&stuff->y, n);
+    swapl(&stuff->mode, n);
+    swaps(&stuff->rotation, n);
+    SwapRestL(stuff);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetCrtcGammaSize (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetCrtcGammaSizeReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->crtc, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRGetCrtcGamma (ClientPtr client)
 {
+    int n;
     REQUEST(xRRGetCrtcGammaReq);
-    
+
     REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
-    (void) stuff;
-    return BadImplementation; 
+    swaps(&stuff->length, n);
+    swapl(&stuff->crtc, n);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 static int
 SProcRRSetCrtcGamma (ClientPtr client)
 {
+    int n;
     REQUEST(xRRSetCrtcGammaReq);
-    
-    REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq);
-    (void) stuff;
-    return BadImplementation; 
+
+    REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->crtc, n);
+    swaps(&stuff->size, n);
+    SwapRestS(stuff);
+    return (*ProcRandrVector[stuff->randrReqType]) (client);
 }
 
 int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
commit 62524d9d7648cfd9e2d7d6a3312ff20722d7f6a5
Author: Thomas Bodzar <Thomas.Bodzar at quest.com>
Date:   Sat Aug 30 15:34:29 2008 +0200

    Xorg.man: typo (the the).
    (cherry picked from commit 229e60db8f95232afc8cdcb7cd0572d117c84b90)

diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre
index 405efda..8b48951 100644
--- a/hw/xfree86/doc/man/Xorg.man.pre
+++ b/hw/xfree86/doc/man/Xorg.man.pre
@@ -202,7 +202,7 @@ to the
 __xconfigfile__(__filemansuffix__) file option.
 .TP 8
 .B \-disableVidMode
-Disable the the parts of the VidMode extension (used by the xvidtune
+Disable the parts of the VidMode extension (used by the xvidtune
 client) that can be used to change the video modes.  This is equivalent
 to the
 .B DisableVidModeExtension
commit 57fa9fd4a59be14f4c77c3dac501ef40ff656752
Author: Matthieu Herrb <matthieu.herrb at laas.fr>
Date:   Sat Aug 30 15:35:32 2008 +0200

    Xserver.man: Typo (the the).
    (cherry picked from commit d01c5ca7935a8340a3cd68c325da6dfec005c952)

diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre
index c47a396..8fe3b76 100644
--- a/doc/Xserver.man.pre
+++ b/doc/Xserver.man.pre
@@ -507,7 +507,7 @@ by the \fIfont path\fP.
 The default font path is
 __default_font_path__ .
 .LP
-A special kind of directory can be specified using the the \fBcatalogue\fP:
+A special kind of directory can be specified using the \fBcatalogue\fP:
 prefix. Directories specified this way can contain symlinks pointing to the
 real font directories. See the FONTPATH.D section for details.
 .LP


More information about the xorg-commit mailing list