xserver: Branch 'master' - 7 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Sep 3 09:34:24 PDT 2008


 configure.ac                                                        |    1 
 hw/xquartz/Makefile.am                                              |    2 
 hw/xquartz/X11Application.h                                         |    2 
 hw/xquartz/X11Application.m                                         |   36 
 hw/xquartz/X11Controller.m                                          |    7 
 hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib   |   60 -
 hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib |binary
 hw/xquartz/darwin.c                                                 |   50 -
 hw/xquartz/darwin.h                                                 |    5 
 hw/xquartz/darwinEvents.c                                           |   20 
 hw/xquartz/doc/Xquartz.man.pre                                      |  117 --
 hw/xquartz/mach-startup/bundle-main.c                               |   15 
 hw/xquartz/pbproxy/Makefile.am                                      |   15 
 hw/xquartz/pbproxy/main.m                                           |  168 +++
 hw/xquartz/pbproxy/pbproxy.h                                        |   41 
 hw/xquartz/pbproxy/trick_autotools.c                                |    3 
 hw/xquartz/pbproxy/x-input.m                                        |  113 ++
 hw/xquartz/pbproxy/x-selection.h                                    |   69 +
 hw/xquartz/pbproxy/x-selection.m                                    |  491 ++++++++++
 mi/mieq.c                                                           |   29 
 20 files changed, 1059 insertions(+), 185 deletions(-)

New commits:
commit 1669308be6d4cc6265e5fa8ef47fbf2cbef6f093
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 09:23:06 2008 -0700

    XQuartz: Added pasteboard proxy code stripped out of quartz-wm.
    (cherry picked from commit 1f842c71c35db031a24de646429834d6054adf1d)
    (cherry picked from commit 144746223d8dc3f6ff2a0e805aa27a6e57df558a)

diff --git a/configure.ac b/configure.ac
index 8e0fe33..51f17c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1865,6 +1865,7 @@ hw/xquartz/GL/Makefile
 hw/xquartz/bundle/Makefile
 hw/xquartz/doc/Makefile
 hw/xquartz/mach-startup/Makefile
+hw/xquartz/pbproxy/Makefile
 hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ephyr/Makefile
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 7bbfee5..782321e 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/miext/rootless
 
 # GL
-SUBDIRS = bundle . xpr mach-startup doc
+SUBDIRS = bundle . xpr mach-startup doc pbproxy
 
 libXquartz_la_SOURCES = \
 	$(top_srcdir)/fb/fbcmap_mi.c \
diff --git a/hw/xquartz/pbproxy/Makefile.am b/hw/xquartz/pbproxy/Makefile.am
new file mode 100644
index 0000000..f3fcba0
--- /dev/null
+++ b/hw/xquartz/pbproxy/Makefile.am
@@ -0,0 +1,15 @@
+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 = \
+	trick_autotools.c \
+	main.m \
+	x-input.m \
+	x-selection.m
+
+EXTRA_DIST = \
+	pbproxy.h \
+	x-selection.h
+
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
new file mode 100644
index 0000000..eaf14a7
--- /dev/null
+++ b/hw/xquartz/pbproxy/main.m
@@ -0,0 +1,168 @@
+/* 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 <X11/extensions/applewm.h>
+#include <HIServices/CoreDockServices.h>
+
+Display *x_dpy;
+int x_apple_wm_event_base, x_apple_wm_error_base;
+
+Atom x_atom_wm_state, x_atom_wm_protocols, x_atom_wm_delete_window;
+Atom x_atom_clipboard, x_atom_text, x_atom_utf8_string;
+Atom x_atom_targets, x_atom_multiple, x_atom_cstring;
+
+static int x_grab_count;
+static Bool x_grab_synced;
+
+static BOOL _is_active = YES;		/* FIXME: should query server */
+
+static 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);
+    }
+    
+    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 ();
+    
+	x_error_shutdown ();
+    
+    return 0;
+}
+
+static void x_init (void) {
+    x_dpy = XOpenDisplay (NULL);
+    if (x_dpy == NULL) {
+        fprintf (stderr, "can't open default display\n");
+        exit (1);
+    }
+    
+    XSetIOErrorHandler (x_io_error_handler);
+    x_atom_clipboard = XInternAtom (x_dpy, "CLIPBOARD", False);
+    x_atom_text = XInternAtom (x_dpy, "TEXT", False);
+    x_atom_utf8_string = XInternAtom (x_dpy, "UTF8_STRING", False);
+    x_atom_targets = XInternAtom (x_dpy, "TARGETS", False);
+    x_atom_multiple = XInternAtom (x_dpy, "MULTIPLE", False);
+    x_atom_cstring = XInternAtom (x_dpy, "CSTRING", False);
+        
+    if (!XAppleWMQueryExtension (x_dpy, &x_apple_wm_event_base,
+                                 &x_apple_wm_error_base)) {
+        fprintf (stderr, "can't open AppleWM server extension\n");
+        exit (1);
+    }
+        
+    XAppleWMSelectInput (x_dpy, AppleWMActivationNotifyMask |
+                         AppleWMPasteboardNotifyMask);
+    
+    _selection_object = [[x_selection alloc] init];
+    
+    x_input_register ();
+    x_input_run ();
+}
+
+static void x_shutdown (void) {
+    [_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;
+}
+
+Time x_current_timestamp (void) {
+    /* FIXME: may want to fetch a timestamp from the server.. */
+    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;
+}
+
+/* Startup */
+static void signal_handler (int sig) {
+    x_shutdown ();
+}
+
+int main (int argc, const char *argv[]) {
+    NSAutoreleasePool *pool;
+
+    pool = [[NSAutoreleasePool alloc] init];
+    
+    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;
+    
+    if (spew == -1) {
+        char *x = getenv ("DEBUG");
+        spew = (x != NULL && atoi (x) != 0);
+    }
+    
+    if (spew) {
+        va_list args;
+        va_start(args, fmt);
+        vfprintf (stderr, fmt, args);
+        va_end(args);
+    }
+}
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
new file mode 100644
index 0000000..ddadbb3
--- /dev/null
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -0,0 +1,41 @@
+/* pbproxy.h
+   Copyright (c) 2002 Apple Computer, Inc. All rights reserved. */
+
+#ifndef PBPROXY_H
+#define PBPROXY_H 1
+
+#import  <Foundation/Foundation.h>
+
+#define  Cursor X_Cursor
+#undef _SHAPE_H_
+#include <X11/Xlib.h>
+#include <X11/extensions/shape.h>
+#undef   Cursor
+
+#define DEBUG 1
+
+/* from main.m */
+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 Display *x_dpy;
+extern int x_apple_wm_event_base, x_apple_wm_error_base;
+extern Atom x_atom_clipboard, x_atom_text, x_atom_utf8_string;
+extern Atom x_atom_targets, x_atom_multiple, x_atom_cstring;
+
+/* from x-input.m */
+extern void x_input_register (void);
+extern void x_input_run (void);
+ 
+#if DEBUG == 0
+# define DB(msg, args...) do {} while (0)
+#else
+# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
+#endif
+
+#define TRACE() DB("TRACE\n")
+extern void debug_printf (const char *fmt, ...);
+
+#endif /* PBPROXY_H */
diff --git a/hw/xquartz/pbproxy/trick_autotools.c b/hw/xquartz/pbproxy/trick_autotools.c
new file mode 100644
index 0000000..a38f077
--- /dev/null
+++ b/hw/xquartz/pbproxy/trick_autotools.c
@@ -0,0 +1,3 @@
+int this_is_just_here_to_make_automake_work() {
+	return 0;
+}
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
new file mode 100644
index 0000000..2e77250
--- /dev/null
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -0,0 +1,113 @@
+/* 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. */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <CoreFoundation/CFSocket.h>
+#include <CoreFoundation/CFRunLoop.h>
+
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/extensions/applewm.h>
+
+#include <unistd.h>
+
+/* FIXME: .. */
+CFRunLoopSourceRef x_dpy_source;
+
+/* Timestamp when the X server last told us it's active */
+static Time last_activation_time;
+
+static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
+    switch (e->type - x_apple_wm_event_base) {              
+        case AppleWMActivationNotify:
+            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;
+            }
+            break;
+            
+        case AppleWMPasteboardNotify:
+            switch (e->kind) {
+                case AppleWMCopyToPasteboard:
+                    [x_selection_object () x_copy:e->time];
+            }
+            break;
+    }
+}
+
+void x_input_run (void) {
+    while (XPending (x_dpy) != 0) {
+        XEvent e;
+        
+        XNextEvent (x_dpy, &e);
+        
+        switch (e.type) {                
+            case SelectionClear:
+                [x_selection_object () clear_event:&e.xselectionclear];
+                break;
+                
+            case SelectionRequest:
+                [x_selection_object () request_event:&e.xselectionrequest];
+                break;
+                
+            case SelectionNotify:
+                [x_selection_object () notify_event:&e.xselection];
+                break;
+                
+            default:
+                if (e.type - x_apple_wm_event_base >= 0
+                    && e.type - x_apple_wm_event_base < AppleWMNumberEvents) {
+                    x_event_apple_wm_notify ((XAppleWMNotifyEvent *) &e);
+                }
+                break;
+        }
+    }
+}
+
+static int add_input_socket (int sock, CFOptionFlags callback_types,
+                             CFSocketCallBack callback, const CFSocketContext *ctx,
+                             CFRunLoopSourceRef *cf_source) {
+    CFSocketRef cf_sock;
+    
+    cf_sock = CFSocketCreateWithNative (kCFAllocatorDefault, sock,
+                                        callback_types, callback, ctx);
+    if (cf_sock == NULL) {
+        close (sock);
+        return FALSE;
+    }
+    
+    *cf_source = CFSocketCreateRunLoopSource (kCFAllocatorDefault,
+                                              cf_sock, 0);
+    CFRelease (cf_sock);
+    
+    if (*cf_source == NULL)
+        return FALSE;
+    
+    CFRunLoopAddSource (CFRunLoopGetCurrent (),
+                        *cf_source, kCFRunLoopDefaultMode);
+    return TRUE;
+}
+
+static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
+                              CFDataRef address, const void *data, void *info) {
+    x_input_run ();
+}
+
+void x_input_register(void) {
+    if (!add_input_socket (ConnectionNumber (x_dpy), kCFSocketReadCallBack,
+                           x_input_callback, NULL, &x_dpy_source)) {
+        exit (1);
+    }
+}
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
new file mode 100644
index 0000000..b31bf63
--- /dev/null
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -0,0 +1,69 @@
+/* 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.
+
+   Permission is hereby granted, free of charge, to any person
+   obtaining a copy of this software and associated documentation files
+   (the "Software"), to deal in the Software without restriction,
+   including without limitation the rights to use, copy, modify, merge,
+   publish, distribute, sublicense, and/or sell copies of the Software,
+   and to permit persons to whom the Software is furnished to do so,
+   subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+   HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
+
+   Except as contained in this notice, the name(s) of the above
+   copyright holders shall not be used in advertising or otherwise to
+   promote the sale, use or other dealings in this Software without
+   prior written authorization. */
+
+#ifndef X_SELECTION_H
+#define X_SELECTION_H 1
+
+#include "pbproxy.h"
+#include <AppKit/NSPasteboard.h>
+
+ at interface x_selection : NSObject
+{
+ at private
+
+    /* 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;
+
+    /* Name of the selection we're proxying onto the pasteboard. */
+    Atom _proxied_selection;
+
+    /* When true, we're expecting a SelectionNotify event. */
+    unsigned int _pending_notify :1;
+}
+
+- (void) x_active:(Time)timestamp;
+- (void) x_inactive:(Time)timestamp;
+
+- (void) x_copy:(Time)timestamp;
+
+- (void) clear_event:(XSelectionClearEvent *)e;
+- (void) request_event:(XSelectionRequestEvent *)e;
+- (void) notify_event:(XSelectionEvent *)e;
+
+ at end
+
+#endif /* X_SELECTION_H */
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
new file mode 100644
index 0000000..5b2ba9c
--- /dev/null
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -0,0 +1,491 @@
+/* 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.
+
+   Permission is hereby granted, free of charge, to any person
+   obtaining a copy of this software and associated documentation files
+   (the "Software"), to deal in the Software without restriction,
+   including without limitation the rights to use, copy, modify, merge,
+   publish, distribute, sublicense, and/or sell copies of the Software,
+   and to permit persons to whom the Software is furnished to do so,
+   subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be
+   included in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+   HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
+
+   Except as contained in this notice, the name(s) of the above
+   copyright holders shall not be used in advertising or otherwise to
+   promote the sale, use or other dealings in this Software without
+   prior written authorization. */
+
+#import "x-selection.h"
+
+#include <X11/Xatom.h>
+
+#include <unistd.h>
+
+ at implementation x_selection
+
+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;
+}
+
+float
+get_time (void)
+{
+  extern void Microseconds ();
+  UnsignedWide usec;
+  long long ll;
+
+  Microseconds (&usec);
+  ll = ((long long) usec.hi << 32) | usec.lo;
+
+  return ll / 1e6;
+}
+
+static Bool
+IfEventWithTimeout (Display *dpy, XEvent *e, int timeout,
+		    Bool (*pred) (Display *, XEvent *, XPointer),
+		    XPointer arg)
+{
+    float start = get_time ();
+    fd_set fds;
+    struct timeval tv;
+
+    do {
+	if (XCheckIfEvent (x_dpy, e, pred, arg))
+	    return True;
+
+	FD_ZERO (&fds);
+	FD_SET (ConnectionNumber (x_dpy), &fds);
+	tv.tv_usec = 0;
+	tv.tv_sec = timeout;
+
+	if (select (FD_SETSIZE, &fds, NULL, NULL, &tv) != 1)
+	    break;
+
+    } while (start + timeout > get_time ());
+
+    return False;
+}
+
+/* Called when X11 becomes active (i.e. has key focus) */
+- (void) x_active:(Time)timestamp
+{
+    TRACE ();
+
+    if ([_pasteboard changeCount] != _my_last_change)
+    {
+	if ([_pasteboard availableTypeFromArray: _known_types] != nil)
+	{
+	    /* Pasteboard has data we should proxy; I think it makes
+	       sense to put it on both CLIPBOARD and PRIMARY */
+
+	    XSetSelectionOwner (x_dpy, x_atom_clipboard,
+				_selection_window, timestamp);
+	    XSetSelectionOwner (x_dpy, XA_PRIMARY,
+				_selection_window, timestamp);
+	}
+    }
+}
+
+/* Called when X11 loses key focus */
+- (void) x_inactive:(Time)timestamp
+{
+    Window w;
+
+    TRACE ();
+
+    if (_proxied_selection == XA_PRIMARY)
+      return;
+
+    w = XGetSelectionOwner (x_dpy, x_atom_clipboard);
+
+    if (w != None && w != _selection_window)
+    {
+	/* An X client has the selection, proxy it to the pasteboard */
+
+	_my_last_change = [_pasteboard declareTypes:_known_types owner:self];
+	_proxied_selection = x_atom_clipboard;
+    }
+}
+
+/* Called when the Edit/Copy item on the main X11 menubar is selected
+   and no appkit window claims it. */
+- (void) x_copy:(Time)timestamp
+{
+    Window w;
+
+    /* Lazily copies the PRIMARY selection to the pasteboard. */
+
+    w = XGetSelectionOwner (x_dpy, XA_PRIMARY);
+
+    if (w != None && w != _selection_window)
+    {
+	XSetSelectionOwner (x_dpy, x_atom_clipboard,
+			    _selection_window, timestamp);
+	_my_last_change = [_pasteboard declareTypes:_known_types owner:self];
+	_proxied_selection = XA_PRIMARY;
+    }
+    else
+    {
+	XBell (x_dpy, 0);
+    }
+}
+
+
+/* X events */
+
+- (void) clear_event:(XSelectionClearEvent *)e
+{
+    TRACE ();
+
+    /* Right now we don't care about this. */
+}
+
+static Atom
+convert_1 (XSelectionRequestEvent *e, NSString *data, Atom target, Atom prop)
+{
+    Atom ret = None;
+
+    if (data == nil)
+	return ret;
+
+    if (target == x_atom_text)
+	target = x_atom_utf8_string;
+
+    if (target == XA_STRING
+	|| target == x_atom_cstring
+	|| target == x_atom_utf8_string)
+    {
+	const char *bytes;
+
+	if (target == XA_STRING)
+	    bytes = [data lossyCString];
+	else
+	    bytes = [data UTF8String];
+
+	if (bytes != NULL)
+	{
+	    XChangeProperty (x_dpy, e->requestor, prop, target,
+			     8, PropModeReplace, (unsigned char *) bytes,
+			     strlen (bytes));
+	    ret = prop;
+	}
+    }
+    /* FIXME: handle COMPOUND_TEXT target */
+
+    return ret;
+}
+
+- (void) request_event:(XSelectionRequestEvent *)e
+{
+    /* Someone's asking us for the data on the pasteboard */
+
+    XEvent reply;
+    NSString *data;
+    Atom target;
+
+    TRACE ();
+
+    reply.xselection.type = SelectionNotify;
+    reply.xselection.selection = e->selection;
+    reply.xselection.target = e->target;
+    reply.xselection.requestor = e->requestor;
+    reply.xselection.time = e->time;
+    reply.xselection.property = None;
+
+    target = e->target;
+
+    if (target == x_atom_targets)
+    {
+	long data[2];
+
+	data[0] = x_atom_utf8_string;
+	data[1] = XA_STRING;
+
+	XChangeProperty (x_dpy, e->requestor, e->property, target,
+			 8, PropModeReplace, (unsigned char *) &data,
+			 sizeof (data));
+	reply.xselection.property = e->property;
+    }
+    else if (target == x_atom_multiple)
+    {
+	if (e->property != None)
+	{
+	    int i, nitems;
+	    unsigned long *atoms;
+
+	    atoms = read_prop_32 (e->requestor, e->property, &nitems);
+
+	    if (atoms != NULL)
+	    {
+		data = [_pasteboard stringForType:NSStringPboardType];
+
+		for (i = 0; i < nitems; i += 2)
+		{
+		    Atom target = atoms[i], prop = atoms[i+1];
+
+		    atoms[i+1] = convert_1 (e, data, target, prop);
+		}
+
+		XChangeProperty (x_dpy, e->requestor, e->property, target,
+				 32, PropModeReplace, (unsigned char *) atoms,
+				 nitems);
+		XFree (atoms);
+	    }
+	}
+    }
+
+    data = [_pasteboard stringForType:NSStringPboardType];
+    if (data != nil)
+    {
+	reply.xselection.property = convert_1 (e, data, target, e->property);
+    }
+
+    XSendEvent (x_dpy, e->requestor, False, 0, &reply);
+}
+
+- (void) notify_event:(XSelectionEvent *)e
+{
+    /* Someone sent us data we're waiting for. */
+
+    Atom type;
+    int format, r, offset;
+    unsigned long nitems, bytes_after;
+    unsigned char *data, *buf;
+    NSString *string;
+
+    TRACE ();
+
+    if (e->target == x_atom_targets)
+    {
+	/* Was trying to fetch the TARGETS property; it lists the
+	   formats supported by the selection owner. */
+
+	unsigned long *atoms;
+	int natoms;
+	int i, utf8_i = -1, string_i = -1;
+
+	if (e->property != None
+	    && (atoms = read_prop_32 (e->requestor,
+				      e->property, &natoms)) != NULL)
+	{
+	    for (i = 0; i < natoms; i++)
+	    {
+		if (atoms[i] == XA_STRING)
+		    string_i = i;
+		else if (atoms[i] == x_atom_utf8_string)
+		    utf8_i = i;
+	    }
+	    XFree (atoms);
+	}
+
+	/* May as well try as STRING if nothing else, it can only
+	   fail, and it will help broken clients who don't support
+	   the TARGETS selection.. */
+
+	if (utf8_i >= 0)
+	    type = x_atom_utf8_string;
+	else
+	    type = XA_STRING;
+
+	XConvertSelection (x_dpy, e->selection, type,
+			   e->selection, e->requestor, e->time);
+	_pending_notify = YES;
+	return;
+    }
+
+    if (e->property == None)
+	return;				/* FIXME: notify pasteboard? */
+
+    /* Should be the data. Find out how big it is and what format it's in. */
+
+    r = XGetWindowProperty (x_dpy, e->requestor, e->property,
+			    0, 0, False, AnyPropertyType, &type,
+			    &format, &nitems, &bytes_after, &data);
+    if (r != Success)
+	return;
+
+    XFree (data);
+    if (type == None || format != 8)
+	return;
+
+    bytes_after += nitems;
+    
+    /* Read it into a buffer. */
+
+    buf = malloc (bytes_after + 1);
+    if (buf == NULL)
+	return;
+
+    for (offset = 0; bytes_after > 0; offset += nitems)
+    {
+	r = XGetWindowProperty (x_dpy, e->requestor, e->property,
+				offset / 4, (bytes_after / 4) + 1,
+				False, AnyPropertyType, &type,
+				&format, &nitems, &bytes_after, &data);
+	if (r != Success)
+	{
+	    free (buf);
+	    return;
+	}
+
+	memcpy (buf + offset, data, nitems);
+	XFree (data);
+    }
+    buf[offset] = 0;
+    XDeleteProperty (x_dpy, e->requestor, e->property);
+
+    /* Convert to an NSString and write to the pasteboard. */
+
+    if (type == XA_STRING)
+	string = [NSString stringWithCString:(char *) buf];
+    else /* if (type == x_atom_utf8_string) */
+	string = [NSString stringWithUTF8String:(char *) buf];
+
+    free (buf);
+
+    [_pasteboard setString:string forType:NSStringPboardType];
+}
+
+
+/* NSPasteboard-required methods */
+
+static Bool
+selnotify_pred (Display *dpy, XEvent *e, XPointer arg)
+{
+    return e->type == SelectionNotify;
+}
+
+- (void) pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
+{
+    XEvent e;
+    Atom request;
+
+    TRACE ();
+
+    /* Don't ask for the data yet, first find out which formats
+       the selection owner supports. */
+
+    request = x_atom_targets;
+
+again:
+    XConvertSelection (x_dpy, _proxied_selection, request,
+		       _proxied_selection, _selection_window, CurrentTime);
+
+    _pending_notify = YES;
+
+    /* Seems like we need to be synchronous here.. Actually, this really
+       sucks, since it means we could get deadlocked if people don't
+       respond to our request. So we need to implement our own timeout
+       code.. */
+
+    while (_pending_notify
+	   && IfEventWithTimeout (x_dpy, &e, 1, selnotify_pred, NULL))
+    {
+	_pending_notify = NO;
+	[self notify_event:&e.xselection];
+    }
+
+    if (_pending_notify && request == x_atom_targets)
+    {
+	/* App didn't respond to request for TARGETS selection. Let's
+	   try the STRING selection as a last resort.. Helps broken
+	   applications (e.g. nedit, see #3199867) */
+
+	request = XA_STRING;
+	goto again;
+    }
+
+    _pending_notify = NO;
+}
+
+- (void) pasteboardChangedOwner:(NSPasteboard *)sender
+{
+    TRACE ();
+
+    /* Right now we don't care with this. */
+}
+
+
+/* Allocation */
+
+- init
+{
+    unsigned long pixel;
+
+    self = [super init];
+    if (self == nil)
+	return nil;
+
+    _pasteboard = [[NSPasteboard generalPasteboard] retain];
+
+    _known_types = [[NSArray arrayWithObject:NSStringPboardType] retain];
+
+    pixel = BlackPixel (x_dpy, DefaultScreen (x_dpy));
+    _selection_window = XCreateSimpleWindow (x_dpy, DefaultRootWindow (x_dpy),
+					     0, 0, 1, 1, 0, pixel, pixel);
+
+    return self;
+}
+
+- (void) dealloc
+{
+    [_pasteboard releaseGlobally];
+    [_pasteboard release];
+    _pasteboard = nil;
+
+    [_known_types release];
+    _known_types = nil;
+
+    if (_selection_window != 0)
+    {
+	XDestroyWindow (x_dpy, _selection_window);
+	_selection_window = 0;
+    }
+
+    [super dealloc];
+}
+
+ at end
commit 46168b3b404164c1f2e7876031e70fb77192fe75
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 09:11:25 2008 -0700

    XQuartz: Updated Tablet code to include ranges for valuators and added cursor and erasor
    (cherry picked from commit 6bca78760951cb5cb57ea66b7631a2dc230dc27a)
    (cherry picked from commit fafcafd6de39cf6b5967793f03b30b49db36fec5)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index a1c09ef..3bc4899 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -923,12 +923,48 @@ static void send_nsevent(NSEvent *e) {
                 tilt_x   = [e tilt].x;
                 tilt_y   = [e tilt].y; 
             }
+            
+            if([e subtype] != NSTabletProximityEventSubtype) {
+                switch([e pointingDeviceType]) {
+                    case NSEraserPointingDevice:
+                        darwinTabletCurrent=darwinTabletEraser;
+                        break;
+                    case NSPenPointingDevice:
+                        darwinTabletCurrent=darwinTabletStylus;
+                        break;
+                    case NSCursorPointingDevice:
+                    case NSUnknownPointingDevice:
+                    default:
+                        darwinTabletCurrent=darwinTabletCursor;
+                        break;
+                }
+
+                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:
+                if([e subtype] != NSTabletProximityEventSubtype) {
+                    switch([e pointingDeviceType]) {
+                        case NSEraserPointingDevice:
+                            darwinTabletCurrent=darwinTabletEraser;
+                            break;
+                        case NSPenPointingDevice:
+                            darwinTabletCurrent=darwinTabletStylus;
+                            break;
+                        case NSCursorPointingDevice:
+                        case NSUnknownPointingDevice:
+                        default:
+                            darwinTabletCurrent=darwinTabletCursor;
+                            break;
+                    }
+                }
+                    
 			DarwinSendProximityEvents([e isEnteringProximity]?ProximityIn:ProximityOut,
                                       pointer_x, pointer_y);
             break;
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index fb0a806..19fe323 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -120,9 +120,12 @@ int                     darwinAppKitModMask = 0; // Any of these bits
 int                     windowItemModMask = NX_COMMANDMASK;
 
 // devices
-DeviceIntPtr            darwinPointer = NULL;
-DeviceIntPtr            darwinTablet = NULL;
 DeviceIntPtr            darwinKeyboard = NULL;
+DeviceIntPtr            darwinPointer = NULL;
+DeviceIntPtr            darwinTabletCurrent = NULL;
+DeviceIntPtr            darwinTabletStylus = NULL;
+DeviceIntPtr            darwinTabletCursor = NULL;
+DeviceIntPtr            darwinTabletEraser = NULL;
 
 // Common pixmap formats
 static PixmapFormatRec formats[] = {
@@ -354,7 +357,8 @@ static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
                                     GetMotionHistory,
                                     (PtrCtrlProcPtr)NoopDDA,
                                     GetMotionHistorySize(), 2);
-								pPointer->name = strdup("Quartz Pointing Device");
+			InitAbsoluteClassDeviceStruct(pPointer);
+            pPointer->valuator->mode = Absolute; // Relative
             break;
         case DEVICE_ON:
             pPointer->public.on = TRUE;
@@ -381,10 +385,22 @@ static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
             InitPointerDeviceStruct((DevicePtr)pPointer, map, 3,
                                     GetMotionHistory,
                                     (PtrCtrlProcPtr)NoopDDA,
-                                    GetMotionHistorySize(), 7);
+                                    GetMotionHistorySize(), 5);
+            pPointer->valuator->mode = Absolute; // Relative
             InitProximityClassDeviceStruct(pPointer);
-//			InitAbsoluteClassDeviceStruct(pPointer);
-			pPointer->name = strdup("pen");			
+			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;
             break;
         case DEVICE_ON:
             pPointer->public.on = TRUE;
@@ -408,7 +424,6 @@ static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
     switch ( onoff ) {
         case DEVICE_INIT:
             DarwinKeyboardInit( pDev );
-			pDev->name = strdup("Quartz Keyboard");
             break;
         case DEVICE_ON:
             pDev->public.on = TRUE;
@@ -530,15 +545,28 @@ int DarwinParseModifierList(const char *constmodifiers, int separatelr)
  */
 void InitInput( int argc, char **argv )
 {
+    darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
+    RegisterKeyboardDevice( darwinKeyboard );
+    darwinKeyboard->name = strdup("Quartz Keyboard");
+
     darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
     RegisterPointerDevice( darwinPointer );
+    darwinPointer->name = strdup("Quartz Pointing Device");
 
-    darwinTablet = AddInputDevice(DarwinTabletProc, TRUE);
-    RegisterPointerDevice( darwinTablet );
+    darwinTabletStylus = AddInputDevice(DarwinTabletProc, TRUE);
+    RegisterPointerDevice( darwinTabletStylus );
+    darwinTabletStylus->name = strdup("stylus");
 
-    darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
-    RegisterKeyboardDevice( darwinKeyboard );
+    darwinTabletCursor = AddInputDevice(DarwinTabletProc, TRUE);
+    RegisterPointerDevice( darwinTabletCursor );
+    darwinTabletCursor->name = strdup("cursor");
 
+    darwinTabletEraser = AddInputDevice(DarwinTabletProc, TRUE);
+    RegisterPointerDevice( darwinTabletEraser );
+    darwinTabletEraser->name = strdup("eraser");
+
+    darwinTabletCurrent = darwinTabletStylus;
+    
     DarwinEQInit();
 
     QuartzInitInput(argc, argv);
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index fd1c6d5..3fac203 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -71,7 +71,10 @@ extern io_connect_t     darwinParamConnect;
 extern int              darwinEventReadFD;
 extern int              darwinEventWriteFD;
 extern DeviceIntPtr     darwinPointer;
-extern DeviceIntPtr     darwinTablet;
+extern DeviceIntPtr     darwinTabletCurrent;
+extern DeviceIntPtr     darwinTabletCursor;
+extern DeviceIntPtr     darwinTabletStylus;
+extern DeviceIntPtr     darwinTabletEraser;
 extern DeviceIntPtr     darwinKeyboard;
 
 // User preferences
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 9cb5533..135e419 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -70,7 +70,7 @@ in this Software without prior written authorization from The Open Group.
 
 /* These values were chosen to match the output of xinput under Linux */
 #define SCALEFACTOR_TILT        64.0
-#define SCALEFACTOR_PRESSURE    1000.0
+#define SCALEFACTOR_PRESSURE    1023.0
 
 #define _APPLEWM_SERVER_
 #include "applewmExt.h"
@@ -416,7 +416,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 	if (pressure == 0 && tilt_x == 0 && tilt_y == 0)
         dev = darwinPointer;
 	else
-        dev = darwinTablet;
+        dev = darwinTabletCurrent;
 
     screen = miPointerGetScreen(dev);
     if(!screen) {
@@ -459,7 +459,7 @@ 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==darwinTablet?5:2, valuators);
+                                      POINTER_ABSOLUTE, 0, dev==darwinTabletCurrent?5:2, valuators);
         for(i=0; i<num_events; i++) mieqEnqueue (dev, &darwinEvents[i]);
         DarwinPokeEQ();
     } darwinEvents_unlock();
@@ -496,7 +496,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y) {
 	int i, num_events;
     ScreenPtr screen;
-    DeviceIntPtr dev = darwinTablet;
+    DeviceIntPtr dev = darwinTabletCurrent;
     int valuators[5];
 
 	DEBUG_LOG("DarwinSendProximityEvents(%d, %d, %d)\n", ev_type, pointer_x, pointer_y);
commit 7f5318131ddf86bed5797c0d9641f6ff34f34be0
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 03:54:42 2008 -0700

    XQuartz: Removed "Done" button from Applications Customization.  Now properly save on exit.
    (cherry picked from commit 2f1e163d5db6063e54fcaa045ea67c29ce3e46aa)
    (cherry picked from commit 7542c00b96461c3474b8c23545171c4b6ddfd29d)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index a56fc5c..e1a2856 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -96,6 +96,13 @@
 		
       [self set_apps_menu:array];
     }
+    
+    [[NSNotificationCenter defaultCenter]
+     addObserver: self
+     selector: @selector(apps_table_done:)
+     name: NSWindowWillCloseNotification
+     object: [apps_table window]];
+    
 }
 
 - (void) item_selected:sender
diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
index ea5dd83..76148da 100644
--- a/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib
@@ -2,7 +2,7 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9F10</string>
+		<string key="IBDocument.SystemVersion">9F30</string>
 		<string key="IBDocument.InterfaceBuilderVersion">670</string>
 		<string key="IBDocument.AppKitVersion">949.34</string>
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
@@ -1083,7 +1083,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string key="NSFrameSize">{484, 280}</string>
 				</object>
 				<string key="NSScreenRect">{{0, 0}, {1280, 938}}</string>
-				<string key="NSMinSize">{320, 262}</string>
+				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_prefs</string>
 			</object>
@@ -1392,31 +1392,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSButton" id="930526262">
-							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{340, 12}, {100, 32}}</string>
-							<reference key="NSSuperview" ref="85544634"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="779207200">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">137887744</int>
-								<string key="NSContents">Done</string>
-								<reference key="NSSupport" ref="463863101"/>
-								<reference key="NSControlView" ref="930526262"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="549406736"/>
-								<object class="NSMutableString" key="NSAlternateContents">
-									<characters key="NS.bytes"/>
-								</object>
-								<object class="NSMutableString" key="NSKeyEquivalent">
-									<characters key="NS.bytes"/>
-								</object>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
 					</object>
 					<string key="NSFrameSize">{454, 271}</string>
 					<reference key="NSSuperview"/>
@@ -1964,14 +1939,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					</object>
 					<int key="connectionID">300394</int>
 				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">apps_table_done:</string>
-						<reference key="source" ref="485884620"/>
-						<reference key="destination" ref="930526262"/>
-					</object>
-					<int key="connectionID">300420</int>
-				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -2584,7 +2551,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference ref="758204686"/>
 							<reference ref="671954382"/>
 							<reference ref="492358940"/>
-							<reference ref="930526262"/>
 						</object>
 						<reference key="parent" ref="604417141"/>
 					</object>
@@ -2993,20 +2959,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<reference key="object" ref="989804990"/>
 						<reference key="parent" ref="57161931"/>
 					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">300418</int>
-						<reference key="object" ref="930526262"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="779207200"/>
-						</object>
-						<reference key="parent" ref="85544634"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">300419</int>
-						<reference key="object" ref="779207200"/>
-						<reference key="parent" ref="930526262"/>
-					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
@@ -3139,8 +3091,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>300368.ImportedFromIB2</string>
 					<string>300370.IBPluginDependency</string>
 					<string>300370.ImportedFromIB2</string>
-					<string>300418.IBPluginDependency</string>
-					<string>300418.ImportedFromIB2</string>
 					<string>305.IBPluginDependency</string>
 					<string>305.ImportedFromIB2</string>
 					<string>310.IBPluginDependency</string>
@@ -3334,11 +3284,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{100, 746}, {155, 33}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{68, 708}, {454, 271}}</string>
+					<string>{{68, 585}, {454, 271}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<string>{{68, 708}, {454, 271}}</string>
+					<string>{{68, 585}, {454, 271}}</string>
 					<reference ref="9"/>
 					<string>{{433, 406}, {486, 327}}</string>
 					<integer value="0"/>
@@ -3480,8 +3430,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
 					<string>{{12, 633}, {218, 203}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
diff --git a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib
index e65937e..197c1be 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib differ
commit 9e70a3cf58c205948f6a415e203d825e9b660d9d
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 09:33:39 2008 -0700

    mieqProcessInputEvents: Check custom event handlers first.

diff --git a/mi/mieq.c b/mi/mieq.c
index e7e16ab..48628fc 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -315,10 +315,21 @@ mieqProcessInputEvents(void)
 #endif
 
         e = &miEventQueue.events[miEventQueue.head];
-        /* Assumption - screen switching can only occur on motion events. */
         miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE;
 
-        if (e->pScreen != DequeueScreen(e->pDev)) {
+        if ((handler = miEventQueue.handlers[e->events->event->u.u.type]))
+        {
+            /* If someone's registered a custom event handler, let them
+             * steal it. */
+            handler(DequeueScreen(e->pDev)->myNum, e->events->event,
+                    e->pDev, e->nevents);
+            if (!e->pDev->isMaster && e->pDev->u.master)
+            {
+                handler(DequeueScreen(e->pDev->u.master)->myNum,
+                        e->events->event, e->pDev->u.master, e->nevents);
+            }
+        } else if (e->pScreen != DequeueScreen(e->pDev)) {
+            /* Assumption - screen switching can only occur on motion events. */
             DequeueScreen(e->pDev) = e->pScreen;
             x = e->events[0].event->u.keyButtonPointer.rootX;
             y = e->events[0].event->u.keyButtonPointer.rootY;
@@ -353,19 +364,6 @@ mieqProcessInputEvents(void)
             } else
                 master_event = NULL;
 
-            /* If someone's registered a custom event handler, let them
-             * steal it. */
-            if ((handler = miEventQueue.handlers[e->events->event->u.u.type]))
-            {
-                handler(DequeueScreen(e->pDev)->myNum, e->events->event,
-                        e->pDev, e->nevents);
-                if (!e->pDev->isMaster && e->pDev->u.master)
-                {
-                    handler(DequeueScreen(e->pDev->u.master)->myNum,
-                            e->events->event, e->pDev->u.master, e->nevents);
-                }
-            } else
-            {
                 /* process slave first, then master */
                 e->pDev->public.processInputProc(event, e->pDev, e->nevents);
 
@@ -374,7 +372,6 @@ mieqProcessInputEvents(void)
                     e->pDev->u.master->public.processInputProc(master_event,
                             e->pDev->u.master, e->nevents);
                 }
-            }
 
             if (e->nevents > 1)
                 xfree(event);
commit 700e8bf33f9b1c3921de912b8110fadf5e0626da
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 02:41:20 2008 -0700

    XQuartz: Updated man page
    (cherry picked from commit 6932d0d19ea75c64ed38b82a246b68c6bbfb8cec)
    (cherry picked from commit 8e3da36b6b0a261975808bc67b5caca733a1a23d)

diff --git a/hw/xquartz/doc/Xquartz.man.pre b/hw/xquartz/doc/Xquartz.man.pre
index 315db1c..100589e 100644
--- a/hw/xquartz/doc/Xquartz.man.pre
+++ b/hw/xquartz/doc/Xquartz.man.pre
@@ -1,6 +1,6 @@
 .TH XQUARTZ 1 __vendorversion__
 .SH NAME
-Xquartz \- X window system server for Quartz operating system
+Xquartz \- X window system server for Mac OSX
 .SH SYNOPSIS
 .B Xquartz
 [ options ] ...
@@ -13,88 +13,35 @@ window system and Mac OS X share your display.  The root window of the
 X11 display is the size of the screen and contains all the other
 windows. The X11 root window is not displayed in rootless mode as Mac
 OS X handles the desktop background.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
+.SH CUSTOMIZATION
+\fIXquartz\fP can be customized using the defaults(1) command. The available options are:
 .TP 8
-.B \-fakebuttons
+.B defaults write org.x.X11 enable_fake_buttons -boolean true
 Emulates a 3 button mouse using modifier keys. By default, the Command modifier
 is used to emulate button 2 and Option is used for button 3. Thus, clicking the
 first mouse button while holding down Command will act like clicking
 button 2. Holding down Option will simulate button 3.
 .TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
+.B defaults write org.x.X11 fake_button2 \fImodifiers\fP
 Change the modifier keys used to emulate the second mouse button. By default,
 Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-swapAltMeta"
-Swaps the meaning of the Alt and Meta modifier keys.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-With this option \fIXquartz\fP queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, defaults to the depth
-of the main display.
-.SH CUSTOMIZATION
-\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write org.x.X11 enable_fake_buttons -boolean true
-Equivalent to the \fB-fakebuttons\fP command line option.
-.TP 8
-.B defaults write org.x.X11 fake_button2 \fImodifiers\fP
-Equivalent to the \fB-fakemouse2\fP option.
+modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
 .TP 8
 .B defaults write org.x.X11 fake_button3 \fImodifiers\fP
-Equivalent to the \fB-fakemouse3\fP option.
-.TP 8
-.B defaults write org.x.X11 swap_alt_meta -boolean true
-Equivalent to the \fB-swapAltMeta\fP option.
-.TP 8
-.B defaults write org.x.X11 keymap_file \fIfilename\fP
-Equivalent to the \fB-keymap\fP option.
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
 .TP 8
 .B defaults write org.x.X11 no_quit_alert -boolean true
 Disables the alert dialog displayed when attempting to quit X11.
 .TP 8
 .B defaults write org.x.X11 no_auth -boolean true
 Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
+connecting.  See Xsecurity(__miscmansuffix__).
 .TP 8
-.B defaults write org.x.X11 nolisten_tcp -boolean true
-Prevents the X server accepting remote connections.
-.TP 8
-.B defaults write org.x.X11 xinit_kills_server -boolean false
-Stops the X server exiting when the xinitrc script terminates.
-.TP 8
-.B defaults write org.x.X11 fullscreen_hotkeys -boolean false
-Allows system hotkeys to be handled while in X11 fullscreen mode.
+.B defaults write org.x.X11 nolisten_tcp -boolean false
+This will tell the server to listen and accept TCP connections.  Doing this without enabling
+xauth is a possible security concern.  See Xsecurity(__miscmansuffix__).
 .TP 8
 .B defaults write org.x.X11 enable_system_beep -boolean false
 Don't use the standard system beep effect for X11 alerts.
@@ -103,13 +50,39 @@ Don't use the standard system beep effect for X11 alerts.
 Disable menu keyboard equivalents while X11 windows are focused.
 .TP 8
 .B defaults write org.x.X11 depth \fIdepth\fP
-Equivalent to the \fB-depth\fP option.
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, or a value of -1 is specified,
+defaults to the depth of the main display.
+.TP 8
+.B defaults write org.x.X11 sync_keymap -boolean true
+Keep the X11 keymap up to date with the OSX system keymap.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Same as enable_fake_buttons above with value true.
+.TP 8
+.B \-nofakebuttons
+Same as enable_fake_buttons above with value false.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Same as fake_button2 above.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Same as fake_button3 above.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Same as depth above.
 .SH "SEE ALSO"
 .PP
 X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1)
 .PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+http://xquartz.macosforge.org
+.PP
+.SH AUTHORS / HISTORY
+X11 was originally ported to Mac OS X Server by John Carmack.  Dave
 Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
 Torrey T. Lyons improved and integrated this code into the XFree86
 Project's mainline for the 4.0.2 release.
@@ -154,3 +127,9 @@ Greg Parker - Rootless support
 Toshimitsu Tanaka - Japanese localization
 .br
 Olivier Verdier - French localization
+.PP
+Code from Apple's X11.app (which was based on XFree86 4.1) was integrated into X.org's XDarwin DDX by Ben Byer for xorg-server-1.2.
+The XDarwin DDX was renamed Xquartz to more accurately reflect its state (the pure-darwin backend was removed).
+Jeremy Huddleston took over as project lead and brought the project up to the X.org 1.4 server branch.
+.PP
+Jeremy Huddleston <jeremyhu at apple.com> is the current maintainer.
commit 7430bb9093ea8cf9589d745742c7353e53a144f8
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 02:37:09 2008 -0700

    XQuartz: Removed dead code (unused option definitions)
    (cherry picked from commit 3d74f77490105c0704c0b10dc7a6eb859bf6e985)
    (cherry picked from commit c1e5ea9ba058f6a13f564165a3d6862335729630)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 5d040de..eaeb369 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -94,8 +94,6 @@ extern int quartzHasRoot, quartzEnableRootless;
 #define PREFS_APPKIT_MODIFIERS      "appkit_modifiers"
 #define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
 #define PREFS_ROOTLESS              "rootless"
-#define PREFS_FULLSCREEN_HOTKEYS    "fullscreen_hotkeys"
-#define PREFS_SWAP_ALT_META         "swap_alt_meta"
 #define PREFS_XP_OPTIONS            "xp_options"
 #define PREFS_ENABLE_STEREO         "enable_stereo"
 #define PREFS_LOGIN_SHELL           "login_shell"
commit b3836e5bdd7e2e04e563246d90f385e1b4741baa
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Sep 3 02:36:39 2008 -0700

    XQuartz: Cleaned up our sleeping before adding the launchd socket.
    (cherry picked from commit ebfe49dfca6e04d66232bad760f522629397cc35)
    (cherry picked from commit 2cf74a76d54d795cfc3c0380a526b9177327782d)

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 15953e3..9cb5533 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -116,18 +116,6 @@ static inline void darwinEvents_lock(void) {
     }
     if(darwinEvents == NULL) {
         pthread_cond_wait(&mieq_ready_cond, &mieq_lock);
-
-        /* We want to give xinit time to finish running xinitrc before we accept
-         * the launchd socket connection.
-         *
-         * Yes, we lock then immediately unlock because the lock does a cond_wait
-         * when darwinEvents == NULL
-         *
-         * TODO: Cleanup this race more elegantly.
-         *
-         * For some reason, xinitrc doesn't run until after this anyways... =/
-         * sleep(2);
-         */
     }
 }
 
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 6f1704e..1d47251 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -190,20 +190,9 @@ static void accept_fd_handoff(int connected_fd) {
      * into it.
      */
 
-#if 0
-    struct timeval start, now;
-    gettimeofday(&start, NULL);
-    gettimeofday(&now, NULL);
-    while((now.tv_sec - start.tv_sec) * 1000000 + (now.tv_usec - start.tv_usec) < 2000000) {
-        unsigned usec = 3000001 - ((now.tv_sec - start.tv_sec) * 1000000 + (now.tv_usec - start.tv_usec));
-        fprintf(stderr, "X11.app: Received new DISPLAY fd: %d ... sleeping to allow xinitrc to catchup (%u).\n", launchd_fd, usec);
-        usleep(usec);
-        gettimeofday(&now, NULL);
-    }
-#else
+    unsigned remain = 3000000;
     fprintf(stderr, "X11.app: Received new DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd);
-    sleep(3);
-#endif
+    while((remain = usleep(remain)) > 0);
 #endif
 
     fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);


More information about the xorg-commit mailing list