xserver: Branch 'master' - 12 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Oct 3 11:14:54 PDT 2008


 configure.ac                                                  |    8 
 fb/fbwindow.c                                                 |  250 ----------
 hw/xquartz/X11Application.m                                   |   41 +
 hw/xquartz/X11Controller.m                                    |   59 +-
 hw/xquartz/bundle/Resources/English.lproj/Localizable.strings |binary
 hw/xquartz/darwin.c                                           |   39 +
 hw/xquartz/darwin.h                                           |    6 
 hw/xquartz/darwinEvents.c                                     |   61 +-
 hw/xquartz/darwinEvents.h                                     |   10 
 hw/xquartz/mach-startup/Makefile.am                           |    6 
 hw/xquartz/pbproxy/Makefile.am                                |   16 
 hw/xquartz/pbproxy/app-main.m                                 |   30 +
 hw/xquartz/pbproxy/main.m                                     |  104 ----
 hw/xquartz/pbproxy/pbproxy.h                                  |    1 
 hw/xquartz/pbproxy/x-input.m                                  |   20 
 hw/xquartz/pbproxy/x-selection.h                              |    8 
 hw/xquartz/pbproxy/x-selection.m                              |   32 +
 include/dix-config.h.in                                       |    3 
 18 files changed, 233 insertions(+), 461 deletions(-)

New commits:
commit 7bb73a9513710feaebc127998950e9f472bfcc0d
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 30 23:53:12 2008 -0600

    XQuartz: pbproxy: Possibly fix a memory leak by using an [NSApp run] loop,
    instead of calling CFRunLoopRun() directly.  The leak wasn't reproducible on
    this machine, but someone was able to produce a leak trace with Instruments
    that indicates it was leaking in the CFRunLoopRun() path.
    
    x-input.m: dequeue and ignore events when pbproxy_active is false.
    
    x-selection.h: add an is_active method that is used by x-input.m to ignore
    events.
    
    x-selection.m: Handle nearly every preference, except for primary_on_grab,
    which I don't really understand yet.
    (cherry picked from commit 4d51ad851e64da83cbdfb0a4a22428418a7bcf75)

diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 0f2eaf0..7611eef 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -8,6 +8,7 @@
 
 #include <pthread.h>
 #include <unistd.h> /*for getpid*/
+#include <Cocoa/Cocoa.h>
 
 static void signal_handler (int sig) {
     _exit(0);
@@ -21,16 +22,9 @@ int main (int argc, const char *argv[]) {
     signal (SIGINT, signal_handler);
     signal (SIGTERM, signal_handler);
     signal (SIGPIPE, SIG_IGN);
-    
-    while (1) {
-        NS_DURING
-        CFRunLoopRun ();
-        NS_HANDLER
-        NSString *s = [NSString stringWithFormat:@"%@ - %@",
-                       [localException name], [localException reason]];
-        fprintf(stderr, "quartz-wm: caught exception: %s\n", [s UTF8String]);
-        NS_ENDHANDLER
-    }		
+
+    [NSApplication sharedApplication];
+    [NSApp run];
     
     return 0;
 }
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index c5e2b63..c11ffb3 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -62,7 +62,11 @@ void x_input_run (void) {
         XEvent e;       
 
         XNextEvent (x_dpy, &e);
-        
+
+	/* If pbproxy isn't active (in the preferences), then don't do anything. */
+	if (![x_selection_object() is_active])
+	    continue;
+
         switch (e.type) {                
             case SelectionClear:
 	        [x_selection_object () clear_event:&e.xselectionclear];
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index e653504..9c408b4 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -1,7 +1,7 @@
 /* x-selection.h -- proxies between NSPasteboard and X11 selections
    $Id: x-selection.h,v 1.2 2002-12-13 00:21:00 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
@@ -102,6 +102,7 @@ struct atom_list {
 - (void) copy_completed:(Atom)selection;
 
 - (void) reload_preferences;
+- (BOOL) is_active;
 @end
 
 /* main.m */
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 37b80f8..0997b3a 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -324,8 +324,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	DB ("changed pasteboard!\n");
 	changeCount = countNow;
 
-	XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
-	[self own_clipboard];
+	if (pbproxy_pasteboard_to_primary)
+	{
+	    
+	    XSetSelectionOwner (x_dpy, atoms->primary, _selection_window, CurrentTime);
+	}
+
+	if (pbproxy_pasteboard_to_clipboard)
+	{
+	    [self own_clipboard];
+	}
     }
 
 #if 0
@@ -449,7 +457,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     
     TRACE ();
 
-    if (NO == pbproxy_clipboard_to_pasteboard)
+    if (!pbproxy_clipboard_to_pasteboard)
 	return;
     
     owner = XGetSelectionOwner (x_dpy, atoms->clipboard);
@@ -462,6 +470,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	DB ("No clipboard owner.\n");
 	[self copy_completed:atoms->clipboard];
 	return;
+    } 
+    else if (owner == _selection_window) 
+    {
+	[self copy_completed:atoms->clipboard];
+	return;
     }
     
     DB ("requesting targets\n");
@@ -1223,9 +1236,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 - (void) reload_preferences
 {
-    
+    if (pbproxy_clipboard_to_pasteboard)
+    {
+	[self claim_clipboard];
+    }
 }
 
+- (BOOL) is_active 
+{
+    return pbproxy_active;
+}
 
 
 /* NSPasteboard-required methods */
commit 2a5ce41f0371ad5df52586b8d4072578b6206321
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Sep 30 13:54:08 2008 -0700

    XQuartz: Use "pointer" and "pen" for device names to please GDK.
    (cherry picked from commit 00ca0f4d839abf47e9573a1552473e039cf787e6)

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 25faa7f..d728e98 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -470,15 +470,29 @@ void InitInput( int argc, char **argv )
 {
     darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
     RegisterKeyboardDevice( darwinKeyboard );
-    darwinKeyboard->name = strdup("Quartz Keyboard");
+    darwinKeyboard->name = strdup("keyboard");
+
+    /* here's the snippet from the current gdk sources:
+    if (!strcmp (tmp_name, "pointer"))
+        gdkdev->info.source = GDK_SOURCE_MOUSE;
+    else if (!strcmp (tmp_name, "wacom") ||
+             !strcmp (tmp_name, "pen"))
+        gdkdev->info.source = GDK_SOURCE_PEN;
+    else if (!strcmp (tmp_name, "eraser"))
+        gdkdev->info.source = GDK_SOURCE_ERASER;
+    else if (!strcmp (tmp_name, "cursor"))
+        gdkdev->info.source = GDK_SOURCE_CURSOR;
+    else
+        gdkdev->info.source = GDK_SOURCE_PEN;
+    */
 
     darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
     RegisterPointerDevice( darwinPointer );
-    darwinPointer->name = strdup("Quartz Pointing Device");
+    darwinPointer->name = strdup("pointer");
 
     darwinTabletStylus = AddInputDevice(DarwinTabletProc, TRUE);
     RegisterPointerDevice( darwinTabletStylus );
-    darwinTabletStylus->name = strdup("stylus");
+    darwinTabletStylus->name = strdup("pen");
 
     darwinTabletCursor = AddInputDevice(DarwinTabletProc, TRUE);
     RegisterPointerDevice( darwinTabletCursor );
commit d3f597a986dcbc7e4164f350300dbd2e438949d8
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Sep 30 11:10:58 2008 -0700

    XQuartz: Workaround for initial pressure/tilt being sent as 0 with motion during the proximity event
    (cherry picked from commit 9a91d770a6411dd876187e64a8bda1f0745169ae)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 061af6c..cb12cb9 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -936,14 +936,7 @@ static void send_nsevent(NSEvent *e) {
             
         handle_mouse:
             pDev = darwinPointer;
-			if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
-                pressure = [e pressure];
-                tilt_x   = [e tilt].x;
-                tilt_y   = [e tilt].y;
-                
-                pDev = darwinTabletCurrent;
-            }
-            
+
             if([e subtype] == NSTabletProximityEventSubtype) {
                 switch([e pointingDeviceType]) {
                     case NSEraserPointingDevice:
@@ -959,8 +952,25 @@ static void send_nsevent(NSEvent *e) {
                         break;
                 }
                 
+                /* NSTabletProximityEventSubtype doesn't encode pressure ant tilt
+                 * So we just pretend the motion was caused by the mouse.  Hopefully
+                 * we'll have a better solution for this in the future (like maybe
+                 * NSTabletProximityEventSubtype will come from NSTabletPoint
+                 * rather than NSMouseMoved.
+                pressure = [e pressure];
+                tilt_x   = [e tilt].x;
+                tilt_y   = [e tilt].y;
+                pDev = darwinTabletCurrent;                
+                 */
+
                 DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                           pointer_x, pointer_y);
+            }
+
+			if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
+                pressure = [e pressure];
+                tilt_x   = [e tilt].x;
+                tilt_y   = [e tilt].y;
                 
                 pDev = darwinTabletCurrent;
             }
commit 1657dfb843c0127ea31bfd0a8ef81d0c394cbc7b
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Sep 30 08:46:08 2008 -0700

    XQuartz: Using absolute ranges for pointer location to increase resolution and better support tablets.
    (cherry picked from commit d79ccb45f68b65d65718b5b77efe2fae6eeda762)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index a23e175..061af6c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -890,8 +890,8 @@ static void send_nsevent(NSEvent *e) {
 	NSRect screen;
 	NSPoint location;
 	NSWindow *window;
-	int pointer_x, pointer_y, ev_button, ev_type;
-	float pressure, tilt_x, tilt_y;
+	int ev_button, ev_type;
+	float pointer_x, pointer_y, pressure, tilt_x, tilt_y;
     DeviceIntPtr pDev;
     
 	/* convert location to be relative to top-left of primary display */
@@ -909,7 +909,8 @@ static void send_nsevent(NSEvent *e) {
 		pointer_y = (screen.origin.y + screen.size.height) - location.y;
 	}
     
-	pressure = 0;  // for tablets
+    /* Setup our valuators.  These will range from 0 to 1 */
+	pressure = 0;
 	tilt_x = 0;
 	tilt_y = 0;
     
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index d342276..25faa7f 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -341,6 +341,8 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
                                     GetMotionHistorySize(), 2);
 			InitAbsoluteClassDeviceStruct(pPointer);
             pPointer->valuator->mode = Absolute; // Relative
+            InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitValuatorAxisStruct(pPointer, 1, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
             break;
         case DEVICE_ON:
             pPointer->public.on = TRUE;
@@ -372,17 +374,12 @@ static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
             InitProximityClassDeviceStruct(pPointer);
 			InitAbsoluteClassDeviceStruct(pPointer);
 
-//            InitValuatorAxisStruct(pPointer, 0, 0, 1440, 1, 0, 1);
-//            InitValuatorAxisStruct(pPointer, 1, 0, 900, 1, 0, 1);
-            InitValuatorAxisStruct(pPointer, 2, 0, 1023, 1, 0, 1);
-            InitValuatorAxisStruct(pPointer, 3, -64, 64, 1, 0, 1);
-            InitValuatorAxisStruct(pPointer, 4, -64, 64, 1, 0, 1);
-//            InitValuatorAxisStruct(pPointer, 2, 0, 240, 49999, 49999, 49999);
-//            InitValuatorAxisStruct(pPointer, 3, -64, 63, 128, 128, 128);
-//            InitValuatorAxisStruct(pPointer, 4, -64, 63, 128, 128, 128);
-//            InitValuatorAxisStruct(pPointer, 5, 0, 1023, 128, 128, 128);
-            
-//            pPointer->use = IsXExtensionDevice;
+            InitValuatorAxisStruct(pPointer, 0, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitValuatorAxisStruct(pPointer, 1, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitValuatorAxisStruct(pPointer, 2, 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitValuatorAxisStruct(pPointer, 3, -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+            InitValuatorAxisStruct(pPointer, 4, -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1);
+//          pPointer->use = IsXExtensionDevice;
             break;
         case DEVICE_ON:
             pPointer->public.on = TRUE;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index d5d17ed..c31dffd 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -68,10 +68,6 @@ in this Software without prior written authorization from The Open Group.
 #define SCROLLWHEELLEFTFAKE  6
 #define SCROLLWHEELRIGHTFAKE 7
 
-/* These values were chosen to match the output of xinput under Linux */
-#define SCALEFACTOR_TILT        64.0
-#define SCALEFACTOR_PRESSURE    1023.0
-
 #define _APPLEWM_SERVER_
 #include "applewmExt.h"
 #include <X11/extensions/applewm.h>
@@ -390,31 +386,31 @@ static void DarwinPokeEQ(void) {
  *       display.
  */
 static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
-                                   int pointer_x, int pointer_y, 
+                                   float pointer_x, float pointer_y, 
                                    float pressure, float tilt_x, float tilt_y) {
     /* Fix offset between darwin and X screens */
     pointer_x -= darwinMainScreenX + dixScreenOrigins[screen->myNum].x;
     pointer_y -= darwinMainScreenY + dixScreenOrigins[screen->myNum].y;
     
     /* Setup our array of values */
-    valuators[0] = pointer_x;
-    valuators[1] = pointer_y;
-    valuators[2] = pressure * SCALEFACTOR_PRESSURE;
-    valuators[3] = tilt_x * SCALEFACTOR_TILT;
-    valuators[4] = tilt_y * SCALEFACTOR_TILT;
+    valuators[0] = pointer_x * XQUARTZ_VALUATOR_LIMIT / (float)screenInfo.screens[0]->width;
+    valuators[1] = pointer_y * XQUARTZ_VALUATOR_LIMIT / (float)screenInfo.screens[0]->height;
+    valuators[2] = pressure * XQUARTZ_VALUATOR_LIMIT;
+    valuators[3] = tilt_x * XQUARTZ_VALUATOR_LIMIT;
+    valuators[4] = tilt_y * XQUARTZ_VALUATOR_LIMIT;
     
-//    DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", 
-//              valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
+    DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", 
+              valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
 }
 
-void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, int pointer_x, int pointer_y, 
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y, 
 			     float pressure, float tilt_x, float tilt_y) {
 	static int darwinFakeMouseButtonDown = 0;
 	int i, num_events;
     ScreenPtr screen;
     int valuators[5];
 	
-//    DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+    DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
     
 	if(!darwinEvents) {
 		DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
@@ -483,13 +479,13 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
     } darwinEvents_unlock();
 }
 
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
+void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) {
 	int i, num_events;
     ScreenPtr screen;
     DeviceIntPtr dev = darwinTabletCurrent;
     int valuators[5];
 
-	DEBUG_LOG("DarwinSendProximityEvents(%d, %d, %d)\n", ev_type, pointer_x, pointer_y);
+	DEBUG_LOG("DarwinSendProximityEvents(%d, %f, %f)\n", ev_type, pointer_x, pointer_y);
 
 	if(!darwinEvents) {
 		DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
@@ -514,7 +510,7 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
 
 /* Send the appropriate number of button clicks to emulate scroll wheel */
 void DarwinSendScrollEvents(float count_x, float count_y, 
-							int pointer_x, int pointer_y, 
+							float pointer_x, float pointer_y, 
 			    			float pressure, float tilt_x, float tilt_y) {
 	if(!darwinEvents) {
 		DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 003f5fa..2f1d9ff 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -28,15 +28,18 @@
 #ifndef _DARWIN_EVENTS_H
 #define _DARWIN_EVENTS_H
 
+/* For extra precision of our cursor and other valuators */
+#define XQUARTZ_VALUATOR_LIMIT (1 << 16)
+
 Bool DarwinEQInit(void);
 void DarwinEQEnqueue(const xEventPtr e);
 void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, int pointer_x, int pointer_y,
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
 			     float pressure, float tilt_x, float tilt_y);
-void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y);
+void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
+void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y,
 			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
 void DarwinListenOnOpenFD(int fd);
commit 88bb8c6f485a7aaf40f684d484a33cfedfa74a70
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Sep 29 22:33:02 2008 -0700

    XQuartz: Removed resolved comment about localization.
    (cherry picked from commit 8ed5faf058ac7b0782a9cc13a2c58b80168358d2)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 6ca6975..a23e175 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -795,8 +795,6 @@ static void check_xinitrc (void) {
     if (access (buf, F_OK) != 0)
 		goto done;
 	
-    /* FIXME: put localized strings into Resources/English.lproj */
-	
     msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
 Windows displayed by X11 applications may not have titlebars, or may look \
 different to windows displayed by native applications.\n\n\
commit b1d0b196617643619d24ed520b0a1161e26b66c6
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 30 13:04:35 2008 -0600

    XQuartz: pbproxy: Make the signal handler safer by using _exit, and only exit.
    
    Remove some unnecesssary headers.
    
    Remove some dead code that was never called or used in pbproxy.
    
    Make use of an NSAutoreleasePool in x_init.  It could potentially cause a leak
    on a startup without this.
    
    Start adding reload_preferences to the x_selection class, as well as event
    handling for that.
    (cherry picked from commit 602e8ba8f7ee196696bc9e3cea6ecdf3200dcf5c)

diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index b717851..0f2eaf0 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -1,7 +1,7 @@
-/* main.m
+/* app-main.m
  $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
@@ -9,24 +9,8 @@
 #include <pthread.h>
 #include <unistd.h> /*for getpid*/
 
-#include <X11/extensions/applewm.h>
-
-/* X11 code */
-static void x_shutdown (void) {
-    /*gstaplin: signal_handler() calls this, and I don't think these are async-signal safe. */
-    /*TODO use a socketpair() to trigger a cleanup.  This is totally unsafe according to Jordan.  It's a segfault waiting to happen on a signal*/
-
-    [_selection_object release];
-    _selection_object = nil;
-
-    XCloseDisplay (x_dpy);
-    x_dpy = NULL;
-    exit(0); 
-}
-
-/* Startup */
 static void signal_handler (int sig) {
-    x_shutdown ();
+    _exit(0);
 }
 
 int main (int argc, const char *argv[]) {
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 64b1b32..e2156a7 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -1,53 +1,25 @@
 /* main.m
  $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
 
 #include <pthread.h>
-#include <unistd.h> /*for getpid*/
-
 #include <X11/extensions/applewm.h>
 
 Display *x_dpy;
 int x_apple_wm_event_base, x_apple_wm_error_base;
 
-static int x_grab_count;
-static Bool x_grab_synced;
-
-static BOOL _is_active = YES;		/* FIXME: should query server */ 
-/*gstaplin: why? Is there a race?*/
-
 x_selection *_selection_object;
 
-/* X11 code */
-void x_grab_server (Bool sync) {
-    if (x_grab_count++ == 0) {
-        XGrabServer (x_dpy);
-    }
-    
-    if (sync && !x_grab_synced) {
-        XSync (x_dpy, False);
-        x_grab_synced = True;
-    }
-}
-
-void x_ungrab_server (void) {
-    if (--x_grab_count == 0) {
-        XUngrabServer (x_dpy);
-        XFlush (x_dpy);
-        x_grab_synced = False;
-    }
-}
-
 static int x_io_error_handler (Display *dpy) {
     /* We lost our connection to the server. */
     
     TRACE ();
 
-    /* TODO: tirgger the thread to restart? */
+    /* TODO: trigger the thread to restart? */
 #ifndef INTEGRATED_XPBPROXY
     exit(1);
 #endif
@@ -60,6 +32,8 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
 }
 
 void x_init (void) {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
     x_dpy = XOpenDisplay (NULL);
     if (x_dpy == NULL) {
         fprintf (stderr, "can't open default display\n");
@@ -81,10 +55,13 @@ void x_init (void) {
     _selection_object = [[x_selection alloc] init];
     
     x_input_register ();
-    x_input_run ();
-
+   
     [_selection_object set_clipboard_manager];
     [_selection_object claim_clipboard];
+
+    x_input_run ();
+
+    [pool release];
 }
 
 id x_selection_object (void) {
@@ -96,19 +73,6 @@ Time x_current_timestamp (void) {
     return CurrentTime;
 }
 
-
-/* Finding things */
-BOOL x_get_is_active (void) {
-    return _is_active;
-}
-
-void x_set_is_active (BOOL state) {    
-    if (_is_active == state)
-        return;
-
-    _is_active = state;
-}
-
 void debug_printf (const char *fmt, ...) {
     static int spew = -1;
     
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index fd59881..c5e2b63 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -1,7 +1,7 @@
 /* x-input.m -- event handling
  $Id: x-input.m,v 1.26 2007-04-07 20:39:03 jharper Exp $
  
- Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+ Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. */
 
 #include "pbproxy.h"
 #import "x-selection.h"
@@ -15,8 +15,7 @@
 
 #include <unistd.h>
 
-/* FIXME: .. */
-CFRunLoopSourceRef x_dpy_source;
+static CFRunLoopSourceRef x_dpy_source;
 
 /* Timestamp when the X server last told us it's active */
 static Time last_activation_time;
@@ -28,20 +27,22 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
             switch (e->kind) {
                 case AppleWMIsActive:
                     last_activation_time = e->time;
-                    x_set_is_active (YES);
                     [x_selection_object () x_active:e->time];
                     break;
                     
                 case AppleWMIsInactive:
-                    x_set_is_active (NO);
                     [x_selection_object () x_inactive:e->time];
                     break;
+
+  	        case AppleWMReloadPreferences:
+		    [x_selection_object () reload_preferences];
+		    break;
             }
             break;
             
         case AppleWMPasteboardNotify:
             switch (e->kind) {
-                case AppleWMCopyToPasteboard:
+	        case AppleWMCopyToPasteboard:
                     [x_selection_object () x_copy:e->time];
             }
             break;
@@ -128,4 +129,3 @@ void x_input_register(void) {
         exit (1);
     }
 }
-
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index f96d6d4..e653504 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -100,6 +100,8 @@ struct atom_list {
 - (void) set_clipboard_manager;
 - (void) own_clipboard;
 - (void) copy_completed:(Atom)selection;
+
+- (void) reload_preferences;
 @end
 
 /* main.m */
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index b141db0..37b80f8 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -1221,6 +1221,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
 }
 
+- (void) reload_preferences
+{
+    
+}
+
+
 
 /* NSPasteboard-required methods */
 
commit ecd260143cf9f012f033ba029ad04cb49567c89a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Sep 29 22:32:24 2008 -0700

    XQuartz: Added some localizable strings that were missing.
    (cherry picked from commit 2c8205ea8b709c5859412b466e83aec7a94acdcf)

diff --git a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings
index 439bb6b..dc19fc9 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings and b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings differ
commit aae878b89081ffba16386e8d4987469313049bea
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon Sep 29 22:26:20 2008 -0700

    XQuartz: Actually send the pointer event from the pen even if it happes to actually have 0 pressure and 0 tilt.
    (cherry picked from commit f41583761955cb9c92c43239bfaa8ae0e5d95e33)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 0436db8..6ca6975 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -894,6 +894,7 @@ static void send_nsevent(NSEvent *e) {
 	NSWindow *window;
 	int pointer_x, pointer_y, ev_button, ev_type;
 	float pressure, tilt_x, tilt_y;
+    DeviceIntPtr pDev;
     
 	/* convert location to be relative to top-left of primary display */
 	location = [e locationInWindow];
@@ -935,10 +936,13 @@ static void send_nsevent(NSEvent *e) {
         case NSTabletPoint:       ev_button=0; ev_type=MotionNotify;  goto handle_mouse;
             
         handle_mouse:
+            pDev = darwinPointer;
 			if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
                 pressure = [e pressure];
                 tilt_x   = [e tilt].x;
-                tilt_y   = [e tilt].y; 
+                tilt_y   = [e tilt].y;
+                
+                pDev = darwinTabletCurrent;
             }
             
             if([e subtype] == NSTabletProximityEventSubtype) {
@@ -958,9 +962,11 @@ static void send_nsevent(NSEvent *e) {
                 
                 DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                           pointer_x, pointer_y);
+                
+                pDev = darwinTabletCurrent;
             }
-            
-            DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
+
+            DarwinSendPointerEvents(pDev, ev_type, ev_button, pointer_x, pointer_y,
                                     pressure, tilt_x, tilt_y);
             
             break;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 92179d3..d5d17ed 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -407,11 +407,10 @@ static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
 //              valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
 }
 
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y, 
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, int pointer_x, int pointer_y, 
 			     float pressure, float tilt_x, float tilt_y) {
 	static int darwinFakeMouseButtonDown = 0;
 	int i, num_events;
-	DeviceIntPtr dev;
     ScreenPtr screen;
     int valuators[5];
 	
@@ -422,12 +421,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 		return;
 	}
 
-	if (pressure == 0 && tilt_x == 0 && tilt_y == 0)
-        dev = darwinPointer;
-	else
-        dev = darwinTabletCurrent;
-
-    screen = miPointerGetScreen(dev);
+    screen = miPointerGetScreen(pDev);
     if(!screen) {
         DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
         return;
@@ -437,7 +431,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 	if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
         if(darwinFakeMouseButtonDown != 0) {
             /* We're currently "down" with another button, so release it first */
-            DarwinSendPointerEvents(ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+            DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
             darwinFakeMouseButtonDown=0;
         }
 		if (darwin_modifier_flags & darwinFakeMouse2Mask) {
@@ -467,9 +461,9 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 
     DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
     darwinEvents_lock(); {
-        num_events = GetPointerEvents(darwinEvents, dev, ev_type, ev_button, 
-                                      POINTER_ABSOLUTE, 0, dev==darwinTabletCurrent?5:2, valuators);
-        for(i=0; i<num_events; i++) mieqEnqueue (dev, &darwinEvents[i]);
+        num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, 
+                                      POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators);
+        for(i=0; i<num_events; i++) mieqEnqueue (pDev, &darwinEvents[i]);
         DarwinPokeEQ();
     } darwinEvents_unlock();
 }
@@ -534,13 +528,13 @@ void DarwinSendScrollEvents(float count_x, float count_y,
 	
 	while ((count_x > 0.0f) || (count_y > 0.0f)) {
 		if (count_x > 0.0f) {
-			DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-			DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
 			count_x = count_x - 1.0f;
 		}
 		if (count_y > 0.0f) {
-			DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-			DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
 			count_y = count_y - 1.0f;
 		}
 	}
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 61efa75..003f5fa 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -32,7 +32,7 @@ Bool DarwinEQInit(void);
 void DarwinEQEnqueue(const xEventPtr e);
 void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, int pointer_x, int pointer_y,
 			     float pressure, float tilt_x, float tilt_y);
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
commit b7ad86ff8a9115147c0cf02af9e80ec464129392
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat Sep 27 15:30:10 2008 -0700

    Xquartz: xpbproxy: Split out app-specific stuff to app-main.m in prep for making this into a thread.
    (cherry picked from commit c2012138a520560f8a2160518ea73fced410c3b7)

diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index b316b87..43f7386 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -3,6 +3,7 @@ AM_LDFLAGS=-L/usr/X11/lib -lX11 -lAppleWM -framework AppKit -framework Foundatio
 
 SOURCE_FILES = \
 	trick_autotools.c \
+	main.m \
 	x-input.m \
 	x-selection.m
 
@@ -12,7 +13,7 @@ libxpbproxy_la_SOURCES = $(SOURCE_FILES)
 if !INTEGRATED_XPBPROXY
 
 bin_PROGRAMS = xpbproxy
-xpbproxy_SOURCES = main.m
+xpbproxy_SOURCES = app-main.m
 xpbproxy_LDADD = $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la
 
 endif
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
new file mode 100644
index 0000000..b717851
--- /dev/null
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -0,0 +1,52 @@
+/* main.m
+ $Id: main.m,v 1.29 2007-04-07 20:39:03 jharper Exp $
+ 
+ Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h> /*for getpid*/
+
+#include <X11/extensions/applewm.h>
+
+/* X11 code */
+static void x_shutdown (void) {
+    /*gstaplin: signal_handler() calls this, and I don't think these are async-signal safe. */
+    /*TODO use a socketpair() to trigger a cleanup.  This is totally unsafe according to Jordan.  It's a segfault waiting to happen on a signal*/
+
+    [_selection_object release];
+    _selection_object = nil;
+
+    XCloseDisplay (x_dpy);
+    x_dpy = NULL;
+    exit(0); 
+}
+
+/* Startup */
+static void signal_handler (int sig) {
+    x_shutdown ();
+}
+
+int main (int argc, const char *argv[]) {
+    printf("pid: %u\n", getpid());
+    
+    x_init ();
+    
+    signal (SIGINT, signal_handler);
+    signal (SIGTERM, signal_handler);
+    signal (SIGPIPE, SIG_IGN);
+    
+    while (1) {
+        NS_DURING
+        CFRunLoopRun ();
+        NS_HANDLER
+        NSString *s = [NSString stringWithFormat:@"%@ - %@",
+                       [localException name], [localException reason]];
+        fprintf(stderr, "quartz-wm: caught exception: %s\n", [s UTF8String]);
+        NS_ENDHANDLER
+    }		
+    
+    return 0;
+}
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 32b325f..64b1b32 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -20,11 +20,9 @@ static Bool x_grab_synced;
 static BOOL _is_active = YES;		/* FIXME: should query server */ 
 /*gstaplin: why? Is there a race?*/
 
-static x_selection *_selection_object;
+x_selection *_selection_object;
 
 /* X11 code */
-static void x_error_shutdown(void);
-
 void x_grab_server (Bool sync) {
     if (x_grab_count++ == 0) {
         XGrabServer (x_dpy);
@@ -48,8 +46,11 @@ static int x_io_error_handler (Display *dpy) {
     /* We lost our connection to the server. */
     
     TRACE ();
-    
-	x_error_shutdown ();
+
+    /* TODO: tirgger the thread to restart? */
+#ifndef INTEGRATED_XPBPROXY
+    exit(1);
+#endif
     
     return 0;
 }
@@ -58,7 +59,7 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
     return 0;
 }
 
-static void x_init (void) {
+void x_init (void) {
     x_dpy = XOpenDisplay (NULL);
     if (x_dpy == NULL) {
         fprintf (stderr, "can't open default display\n");
@@ -86,22 +87,6 @@ static void x_init (void) {
     [_selection_object claim_clipboard];
 }
 
-static void x_shutdown (void) {
-    /*gstaplin: signal_handler() calls this, and I don't think these are async-signal safe. */
-    /*TODO use a socketpair() to trigger a cleanup.  This is totally unsafe according to Jordan.  It's a segfault waiting to happen on a signal*/
-
-    [_selection_object release];
-    _selection_object = nil;
-
-    XCloseDisplay (x_dpy);
-    x_dpy = NULL;
-    exit(0); 
-}
-
-static void x_error_shutdown (void) {
-    exit(1);
-}
-
 id x_selection_object (void) {
     return _selection_object;
 }
@@ -124,33 +109,6 @@ void x_set_is_active (BOOL state) {
     _is_active = state;
 }
 
-/* Startup */
-static void signal_handler (int sig) {
-    x_shutdown ();
-}
-
-int main (int argc, const char *argv[]) {
-    printf("pid: %u\n", getpid());
-    
-    x_init ();
-    
-    signal (SIGINT, signal_handler);
-    signal (SIGTERM, signal_handler);
-    signal (SIGPIPE, SIG_IGN);
-    
-    while (1) {
-        NS_DURING
-        CFRunLoopRun ();
-        NS_HANDLER
-        NSString *s = [NSString stringWithFormat:@"%@ - %@",
-                       [localException name], [localException reason]];
-        fprintf(stderr, "quartz-wm: caught exception: %s\n", [s UTF8String]);
-        NS_ENDHANDLER
-    }		
-    
-    return 0;
-}
-
 void debug_printf (const char *fmt, ...) {
     static int spew = -1;
     
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index b8fbccb..bd5f65b 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -19,6 +19,7 @@ extern void x_set_is_active (BOOL state);
 extern BOOL x_get_is_active (void);
 extern id x_selection_object (void);
 extern Time x_current_timestamp (void);
+extern void x_init (void);
 
 extern Display *x_dpy;
 extern int x_apple_wm_event_base, x_apple_wm_error_base;
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index 1bb1f10..f96d6d4 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -102,4 +102,7 @@ struct atom_list {
 - (void) copy_completed:(Atom)selection;
 @end
 
+/* main.m */
+extern x_selection *_selection_object;
+
 #endif /* X_SELECTION_H */
commit 5446adebfb085dd05471729bf5c55bf820b1cbe3
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 3 11:12:49 2008 -0700

    XQuartz: Send AppleWMReloadPreferences where appropriate.
    (cherry picked from commit 490cbe9888e2c1080495b003c429fdb1659444e1)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index bbc5fd1..2482c05 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -54,13 +54,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-// This will live in pbproxy/x-selection.m when we integrage that into a server thread... for now, living here for testing the UI.
-int pbproxy_active = YES;
-int pbproxy_primary_on_grab = NO; // This is provided as an option for people who want it and has issues that won't ever be addressed to make it *always* work
-int pbproxy_clipboard_to_pasteboard = YES;
-int pbproxy_pasteboard_to_primary = YES;
-int pbproxy_pasteboard_to_clipboard = YES;
-
 @implementation X11Controller
 
 - (void) awakeFromNib
@@ -630,21 +623,6 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
     X11EnableKeyEquivalents = [enable_keyequivs intValue];
     darwinSyncKeymap = [sync_keymap intValue];
 
-    pbproxy_active = [sync_pasteboard intValue];
-    pbproxy_pasteboard_to_clipboard = [sync_pasteboard_to_clipboard intValue];
-    pbproxy_pasteboard_to_primary = [sync_pasteboard_to_primary intValue];
-    pbproxy_clipboard_to_pasteboard = [sync_clipboard_to_pasteboard intValue];
-    pbproxy_primary_on_grab = [sync_primary_immediately intValue];
-
-    [sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
-    [sync_pasteboard_to_primary setEnabled:pbproxy_active];
-    [sync_clipboard_to_pasteboard setEnabled:pbproxy_active];
-    [sync_primary_immediately setEnabled:pbproxy_active];
-
-    // setEnabled doesn't do this...
-    [sync_text1 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
-    [sync_text2 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
-    
     /* after adding prefs here, also add to [X11Application read_defaults]
      and prefs_show */
 	
@@ -659,19 +637,32 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
     [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
     [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
 
-    [NSApp prefs_set_integer:@PREFS_SYNC_PB value:pbproxy_active];
-    [NSApp prefs_set_integer:@PREFS_SYNC_PB_TO_CLIPBOARD value:pbproxy_pasteboard_to_clipboard];
-    [NSApp prefs_set_integer:@PREFS_SYNC_PB_TO_PRIMARY value:pbproxy_pasteboard_to_primary];
-    [NSApp prefs_set_integer:@PREFS_SYNC_CLIPBOARD_TO_PB value:pbproxy_clipboard_to_pasteboard];
-    [NSApp prefs_set_integer:@PREFS_SYNC_PRIMARY_ON_SELECT value:pbproxy_primary_on_grab];
+    BOOL pbproxy_active = [sync_pasteboard intValue];
+    
+    [NSApp prefs_set_boolean:@PREFS_SYNC_PB value:pbproxy_active];
+    [NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD value:[sync_pasteboard_to_clipboard intValue]];
+    [NSApp prefs_set_boolean:@PREFS_SYNC_PB_TO_PRIMARY value:[sync_pasteboard_to_primary intValue]];
+    [NSApp prefs_set_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB value:[sync_clipboard_to_pasteboard intValue]];
+    [NSApp prefs_set_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT value:[sync_primary_immediately intValue]];
     
-    system("killall -HUP quartz-wm");
-	
     [NSApp prefs_synchronize];
+
+    [sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
+    [sync_pasteboard_to_primary setEnabled:pbproxy_active];
+    [sync_clipboard_to_pasteboard setEnabled:pbproxy_active];
+    [sync_primary_immediately setEnabled:pbproxy_active];
+    
+    // setEnabled doesn't do this...
+    [sync_text1 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
+    [sync_text2 setTextColor:pbproxy_active ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
+    
+	DarwinSendDDXEvent(kXquartzReloadPreferences, 0);
 }
 
 - (IBAction) prefs_show:sender
 {
+    BOOL pbproxy_active = [NSApp prefs_get_boolean:@PREFS_SYNC_PB default:YES];
+    
     [fake_buttons setIntValue:darwinFakeButtons];
     [use_sysbeep setIntValue:quartzUseSysBeep];
     [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
@@ -684,12 +675,12 @@ 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]]];
-    
+
     [sync_pasteboard setIntValue:pbproxy_active];
-    [sync_pasteboard_to_clipboard setIntValue:pbproxy_pasteboard_to_clipboard];
-    [sync_pasteboard_to_primary setIntValue:pbproxy_pasteboard_to_primary];
-    [sync_clipboard_to_pasteboard setIntValue:pbproxy_clipboard_to_pasteboard];
-    [sync_primary_immediately setIntValue:pbproxy_primary_on_grab];
+    [sync_pasteboard_to_clipboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_CLIPBOARD default:YES]];
+    [sync_pasteboard_to_primary setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PB_TO_PRIMARY default:YES]];
+    [sync_clipboard_to_pasteboard setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_CLIPBOARD_TO_PB default:YES]];
+    [sync_primary_immediately setIntValue:[NSApp prefs_get_boolean:@PREFS_SYNC_PRIMARY_ON_SELECT default:NO]];
 
     [sync_pasteboard_to_clipboard setEnabled:pbproxy_active];
     [sync_pasteboard_to_primary setEnabled:pbproxy_active];
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index e45ab19..da5ad74 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -89,12 +89,6 @@ extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
 extern int              darwinDesiredDepth;
 extern int              darwinDesiredRefresh;
 
-extern int              pbproxy_active;
-extern int              pbproxy_primary_on_grab;
-extern int              pbproxy_clipboard_to_pasteboard;
-extern int              pbproxy_pasteboard_to_primary;
-extern int              pbproxy_pasteboard_to_clipboard;
-
 // location of X11's (0,0) point in global screen coordinates
 extern int              darwinMainScreenX;
 extern int              darwinMainScreenY;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 729cc9a..92179d3 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -107,7 +107,8 @@ static pthread_t create_thread(void *func, void *arg) {
     return tid;
 }
 
-static inline void darwinEvents_lock(void) {
+void darwinEvents_lock(void);
+void darwinEvents_lock(void) {
     int err;
     if((err = pthread_mutex_lock(&mieq_lock))) {
         ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
@@ -225,6 +226,13 @@ static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, in
                 QuartzHide();
                 break;
 
+            case kXquartzReloadPreferences:
+                DEBUG_LOG("kXquartzReloadPreferences\n");
+                AppleWMSendEvent(AppleWMActivationNotify,
+                                 AppleWMActivationNotifyMask,
+                                 AppleWMReloadPreferences, 0);
+                break;
+                
             case kXquartzToggleFullscreen:
                 DEBUG_LOG("kXquartzToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
@@ -315,6 +323,7 @@ Bool DarwinEQInit(void) {
     mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
     mieqSetHandler(kXquartzActivate, DarwinEventHandler);
     mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
+    mieqSetHandler(kXquartzReloadPreferences, DarwinEventHandler);
     mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
     mieqSetHandler(kXquartzQuit, DarwinEventHandler);
     mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
@@ -394,8 +403,8 @@ static void DarwinPrepareValuators(int *valuators, ScreenPtr screen,
     valuators[3] = tilt_x * SCALEFACTOR_TILT;
     valuators[4] = tilt_y * SCALEFACTOR_TILT;
     
-    DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", 
-              valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
+//    DEBUG_LOG("Valuators: {%d,%d,%d,%d,%d}\n", 
+//              valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
 }
 
 void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y, 
@@ -406,7 +415,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
     ScreenPtr screen;
     int valuators[5];
 	
-    DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+//    DEBUG_LOG("x=%d, y=%d, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
     
 	if(!darwinEvents) {
 		DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 7a1e8ca..61efa75 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -63,6 +63,7 @@ enum {
      */
     kXquartzControllerNotify, // send an AppleWMControllerNotify event
     kXquartzPasteboardNotify, // notify the WM to copy or paste
+    kXquartzReloadPreferences, // send AppleWMReloadPreferences
     /*
      * Xplugin notification events
      */
commit 6020c3fbfe06530cb2b90178d17a7d63beae028a
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 3 11:09:26 2008 -0700

    XQuartz: Added a --enable-integrated-xpbproxy configure option for building xpbproxy as an app or as a thread.
    (cherry picked from commit 8edc5fb38c922f28659d2f823148339a8907c4d9)
    (cherry picked from commit 88033a66a5549870fd053795b019d4c22950425b)

diff --git a/configure.ac b/configure.ac
index f3abe7d..38ab813 100644
--- a/configure.ac
+++ b/configure.ac
@@ -547,6 +547,7 @@ AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (d
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
 AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
+AC_ARG_ENABLE(integrated-xpbproxy, AS_HELP_STRING([--enable-integrated-xpbproxy], [Build xpbproxy into Xquartz as a separate thread (default: no)]), [INTEGRATED_XPBPROXY=$enableval], [INTEGRATED_XPBPROXY=no])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 dnl kdrive and its subsystems
 AC_ARG_ENABLE(kdrive,         AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
@@ -1536,6 +1537,10 @@ if test "x$XQUARTZ" = xyes; then
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
 
 	PKG_CHECK_MODULES(APPLEWM, [applewmproto >= 1.1.0])
+
+	if test "x$INTEGRATED_XPBPROXY" = xyes ; then
+		AC_DEFINE(INTEGRATED_XPBPROXY,1,[Build xpbproxy into the server rather than as a standalone app])
+	fi
 fi
 
 # Support for objc in autotools is minimal and not documented.
@@ -1552,6 +1557,7 @@ _AM_DEPENDENCIES([OBJC])
 AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
 AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
 AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
+AM_CONDITIONAL(INTEGRATED_XPBPROXY, [test "x$INTEGRATED_XPBPROXY" = xyes])
 
 dnl DMX DDX
 
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index c5df790..97539e1 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -21,8 +21,9 @@ X11_LDADD = \
 	$(top_builddir)/miext/rootless/librootless.la \
 	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin -lX11
 
-#	$(top_builddir)/hw/xquartz/GL/libCGLCore.la \
-#	$(top_builddir)/glx/libglx.la
+if INTEGRATED_XPBPROXY
+X11_LDADD += $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la
+endif
 
 X11_LDFLAGS =  \
 	-XCClinker -Objc \
@@ -62,4 +63,3 @@ EXTRA_DIST = \
 	launchd_fd.h \
 	mach_startup.defs \
 	mach_startup_types.h
-
diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
index f3fcba0..b316b87 100644
--- a/hw/xquartz/pbproxy/Makefile.am
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -1,15 +1,22 @@
 AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
 AM_LDFLAGS=-L/usr/X11/lib -lX11 -lAppleWM -framework AppKit -framework Foundation -framework ApplicationServices
 
-noinst_PROGRAMS = pbproxy
-
-pbproxy_SOURCES = \
+SOURCE_FILES = \
 	trick_autotools.c \
-	main.m \
 	x-input.m \
 	x-selection.m
 
+noinst_LTLIBRARIES = libxpbproxy.la
+libxpbproxy_la_SOURCES = $(SOURCE_FILES)
+
+if !INTEGRATED_XPBPROXY
+
+bin_PROGRAMS = xpbproxy
+xpbproxy_SOURCES = main.m
+xpbproxy_LDADD = $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la
+
+endif
+
 EXTRA_DIST = \
 	pbproxy.h \
 	x-selection.h
-
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 06138c5..26f4b6a 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -118,6 +118,9 @@
 /* Have Quartz */
 #undef XQUARTZ
 
+/* Build xpbproxy into Xquartz rather than a separate app */
+#undef INTEGRATED_XPBPROXY
+
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
commit 505c216d030a8eb6e9fa757ecebed9597a850c88
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 3 11:11:37 2008 -0700

    Added dep on applewmproto 1.1.0
    (cherry picked from commit b350b066740a2e72585153e35478538cf1bca9ef)

diff --git a/configure.ac b/configure.ac
index d768546..f3abe7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1534,6 +1534,8 @@ if test "x$XQUARTZ" = xyes; then
 	AC_CHECK_LIB([Xplugin],[xp_init],[:])
 
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
+
+	PKG_CHECK_MODULES(APPLEWM, [applewmproto >= 1.1.0])
 fi
 
 # Support for objc in autotools is minimal and not documented.
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
deleted file mode 100644
index 70e75a9..0000000
--- a/fb/fbwindow.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "fb.h"
-
-Bool
-fbCreateWindow(WindowPtr pWin)
-{
-    dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
-		  fbGetScreenPixmap(pWin->drawable.pScreen));
-#ifdef FB_SCREEN_PRIVATE
-    if (pWin->drawable.bitsPerPixel == 32)
-	pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-#endif
-    return TRUE;
-}
-
-Bool
-fbDestroyWindow(WindowPtr pWin)
-{
-    return TRUE;
-}
-
-Bool
-fbMapWindow(WindowPtr pWindow)
-{
-    return TRUE;
-}
-
-Bool
-fbPositionWindow(WindowPtr pWin, int x, int y)
-{
-    return TRUE;
-}
-
-Bool
-fbUnmapWindow(WindowPtr pWindow)
-{
-    return TRUE;
-}
-
-void
-fbCopyWindowProc (DrawablePtr	pSrcDrawable,
-		  DrawablePtr	pDstDrawable,
-		  GCPtr		pGC,
-		  BoxPtr	pbox,
-		  int		nbox,
-		  int		dx,
-		  int		dy,
-		  Bool		reverse,
-		  Bool		upsidedown,
-		  Pixel		bitplane,
-		  void		*closure)
-{
-    FbBits	*src;
-    FbStride	srcStride;
-    int		srcBpp;
-    int		srcXoff, srcYoff;
-    FbBits	*dst;
-    FbStride	dstStride;
-    int		dstBpp;
-    int		dstXoff, dstYoff;
-    
-    fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
-    fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-    
-    while (nbox--)
-    {
-	fbBlt (src + (pbox->y1 + dy + srcYoff) * srcStride,
-	       srcStride,
-	       (pbox->x1 + dx + srcXoff) * srcBpp,
-    
-	       dst + (pbox->y1 + dstYoff) * dstStride,
-	       dstStride,
-	       (pbox->x1 + dstXoff) * dstBpp,
-    
-	       (pbox->x2 - pbox->x1) * dstBpp,
-	       (pbox->y2 - pbox->y1),
-    
-	       GXcopy,
-	       FB_ALLONES,
-	       dstBpp,
-    
-	       reverse,
-	       upsidedown);
-	pbox++;
-    }
-
-    fbFinishAccess (pDstDrawable);
-    fbFinishAccess (pSrcDrawable);
-}
-
-void 
-fbCopyWindow(WindowPtr	    pWin, 
-	     DDXPointRec    ptOldOrg, 
-	     RegionPtr	    prgnSrc)
-{
-    RegionRec	rgnDst;
-    int		dx, dy;
-
-    PixmapPtr	pPixmap = fbGetWindowPixmap (pWin);
-    DrawablePtr	pDrawable = &pPixmap->drawable;
-
-    dx = ptOldOrg.x - pWin->drawable.x;
-    dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
-
-    REGION_NULL (pWin->drawable.pScreen, &rgnDst);
-    
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
-
-#ifdef COMPOSITE
-    if (pPixmap->screen_x || pPixmap->screen_y)
-	REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, 
-			  -pPixmap->screen_x, -pPixmap->screen_y);
-#endif
-
-    fbCopyRegion (pDrawable, pDrawable,
-		  0,
-		  &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
-    
-    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
-    fbValidateDrawable (&pWin->drawable);
-}
-
-Bool
-fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
-{
-    PixmapPtr	pPixmap;
-    
-    if (mask & CWBackPixmap)
-    {
-	if (pWin->backgroundState == BackgroundPixmap)
-	{
-	    pPixmap = pWin->background.pixmap;
-#ifdef FB_24_32BIT
-	    if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
-	    {
-		pPixmap = fb24_32ReformatTile (pPixmap,
-					       pWin->drawable.bitsPerPixel);
-		if (pPixmap)
-		{
-		    (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
-		    pWin->background.pixmap = pPixmap;
-		}
-	    }
-#endif
-	    if (FbEvenTile (pPixmap->drawable.width *
-			    pPixmap->drawable.bitsPerPixel))
-		fbPadPixmap (pPixmap);
-	}
-    }
-    if (mask & CWBorderPixmap)
-    {
-	if (pWin->borderIsPixel == FALSE)
-	{
-	    pPixmap = pWin->border.pixmap;
-#ifdef FB_24_32BIT
-	    if (pPixmap->drawable.bitsPerPixel !=
-		pWin->drawable.bitsPerPixel)
-	    {
-		pPixmap = fb24_32ReformatTile (pPixmap,
-					       pWin->drawable.bitsPerPixel);
-		if (pPixmap)
-		{
-		    (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
-		    pWin->border.pixmap = pPixmap;
-		}
-	    }
-#endif
-	    if (FbEvenTile (pPixmap->drawable.width *
-			    pPixmap->drawable.bitsPerPixel))
-		fbPadPixmap (pPixmap);
-	}
-    }
-    return TRUE;
-}
-
-void
-fbFillRegionSolid (DrawablePtr	pDrawable,
-		   RegionPtr	pRegion,
-		   FbBits	and,
-		   FbBits	xor)
-{
-    FbBits	*dst;
-    FbStride	dstStride;
-    int		dstBpp;
-    int		dstXoff, dstYoff;
-    int		n = REGION_NUM_RECTS(pRegion);
-    BoxPtr	pbox = REGION_RECTS(pRegion);
-
-#ifndef FB_ACCESS_WRAPPER
-    int try_mmx = 0;
-    if (!and)
-        try_mmx = 1;
-#endif
-
-    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-    
-    while (n--)
-    {
-#ifndef FB_ACCESS_WRAPPER
-	if (!try_mmx || !pixman_fill ((uint32_t *)dst, dstStride, dstBpp,
-				      pbox->x1 + dstXoff, pbox->y1 + dstYoff,
-				      (pbox->x2 - pbox->x1),
-				      (pbox->y2 - pbox->y1),
-				      xor))
-	{
-#endif
-	    fbSolid (dst + (pbox->y1 + dstYoff) * dstStride,
-		     dstStride,
-		     (pbox->x1 + dstXoff) * dstBpp,
-		     dstBpp,
-		     (pbox->x2 - pbox->x1) * dstBpp,
-		     pbox->y2 - pbox->y1,
-		     and, xor);
-#ifndef FB_ACCESS_WRAPPER
-	}
-#endif
-	fbValidateDrawable (pDrawable);
-	pbox++;
-    }
-    
-    fbFinishAccess (pDrawable);
-}


More information about the xorg-commit mailing list