diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog
index 8dca381ef8326b2a05b23f7ca1a1dda518091719..a5392673070d2b5eb7d7ccdb04d5eab2b427521f 100644
--- a/x11vnc/ChangeLog
+++ b/x11vnc/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-15  Karl Runge <runge@karlrunge.com>
+	* x11vnc: fix find_display and usleep() prototype on macosx.
+	  -display console and check DISPLAY /tmp/...:0 on macosx.
+	  implement -noxinerama.
+
 2007-11-12  Karl Runge <runge@karlrunge.com>
 	* x11vnc: add clear_locks (Caps_Lock, etc) action.  Fix
 	  ssh tunnel on Darwin.
diff --git a/x11vnc/README b/x11vnc/README
index 60e43c66c3d422c6b3170a795c75b19712407d9e..f45476c8d743a983365724eaf1a20be4781491c3 100644
--- a/x11vnc/README
+++ b/x11vnc/README
@@ -1,5 +1,5 @@
 
-x11vnc README file                         Date: Wed Nov  7 17:16:51 EST 2007
+x11vnc README file                         Date: Sat Dec 15 19:10:20 EST 2007
 
 The following information is taken from these URLs:
 
@@ -4135,16 +4135,17 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    You next connect to x11vnc with a VNC viewer, give your username and
    password to the X login prompt to start your session.
 
-   Note:  gdm seems to have an annoying setting that causes x11vnc (and
-   any other X clients) to be killed after the user logs in. Setting
+   Note:  GDM: gdm seems to have an annoying setting that causes x11vnc
+   (and any other X clients) to be killed after the user logs in. Setting
    KillInitClients=false in the [daemon] section of /etc/X11/gdm/gdm.conf
-   avoids this. Otherwise, just restart x11vnc and then reconnect your
-   viewer. Other display managers (kdm, etc) may also have a similar
-   problem.
-
-   Note:  For dtlogin in addition to the above sort of trick (BTW, the
-   auth file should be in /var/dt), you'll also need to add something
-   like Dtlogin*grabServer:False to the Xconfig file
+   (or /etc/gdm/gdm.conf, etc.) avoids this. Otherwise, just restart
+   x11vnc and then reconnect your viewer. Other display managers (kdm,
+   etc) may also have a similar problem. One user reports having to alter
+   "gdm.conf-custom" as well.
+
+   Note:  Solaris: For dtlogin in addition to the above sort of trick
+   (BTW, the auth file should be in /var/dt), you'll also need to add
+   something like Dtlogin*grabServer:False to the Xconfig file
    (/etc/dt/config/Xconfig or /usr/dt/config/Xconfig on Solaris, see
    [585]the example at the end of this FAQ). Then restart dtlogin, e.g.:
    /etc/init.d/dtlogin stop; /etc/init.d/dtlogin start or reboot.
@@ -4174,8 +4175,9 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    watch out for.
 
    Note:  The above gdm setting of KillInitClients=false in
-   /etc/X11/gdm/gdm.conf for GDM is needed here as well. Other display
-   managers (KDM, etc) may also have a similar problem.
+   /etc/X11/gdm/gdm.conf (or /etc/gdm/gdm.conf, etc.) for GDM is needed
+   here as well. Other display managers (KDM, etc) may also have a
+   similar problem.
 
    Note:  The above Dtlogin*grabServer:False step for Solaris will be
    needed for dtlogin here as well.
@@ -4202,8 +4204,8 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
   /usr/local/bin/x11vnc -rfbauth /etc/x11vnc.passwd -forever -bg -o /var/log/x1
 1vnc.log
 
-   And then add this line to /etc/X11/gdm/gdm.conf in the [daemon]
-   section:
+   And then add this line to /etc/X11/gdm/gdm.conf (or /etc/gdm/gdm.conf,
+   etc.) in the [daemon] section:
   KillInitClients=false
 
    Then restart: /usr/sbin/gdm-restart (or reboot). The
@@ -8000,8 +8002,9 @@ or:
    Q-124: Thanks for your program and for your help! Can I make a
    donation?
 
-   Please do (any amount is appreciated) and thank you for your support!
-   Click on the PayPal button below for more info.
+   Please do (any amount is appreciated; only a handful of people have
+   donated anything) and thank you for your support! Click on the PayPal
+   button below for more info.
 
    [PayPal]
 
@@ -11839,7 +11842,7 @@ x11vnc: a VNC server for real X displays
    Here are all of x11vnc command line options:
 % x11vnc -opts      (see below for -help long descriptions)
 
-x11vnc: allow VNC connections to real X11 displays. 0.9.4 lastmod: 2007-11-07
+x11vnc: allow VNC connections to real X11 displays. 0.9.4 lastmod: 2007-12-15
 
 x11vnc options:
   -display disp            -auth file               -N                     
@@ -11958,7 +11961,7 @@ libvncserver-tight-extension options:
 
 % x11vnc -help
 
-x11vnc: allow VNC connections to real X11 displays. 0.9.4 lastmod: 2007-11-07
+x11vnc: allow VNC connections to real X11 displays. 0.9.4 lastmod: 2007-12-15
 
 (type "x11vnc -opts" to just list the options.)
 
diff --git a/x11vnc/keyboard.c b/x11vnc/keyboard.c
index a3f012082e08ddeb72083c67b51a0a78769e85bc..d52d7cfd02c3fb678677cd194db0edb52464a7d1 100644
--- a/x11vnc/keyboard.c
+++ b/x11vnc/keyboard.c
@@ -259,7 +259,7 @@ void clear_locks(void) {
 #else
 	XModifierKeymap *map;
 	int i, j, k = 0;
-	unsigned int state;
+	unsigned int state = 0;
 
 	RAWFB_RET_VOID
 
@@ -279,6 +279,7 @@ void clear_locks(void) {
 #endif
 	{
 		state = mask_state();
+		/* this may contain non-locks too... */
 		rfbLog("state:   0x%x\n", state);
 	}
 	if (! state) {
diff --git a/x11vnc/macosxCG.c b/x11vnc/macosxCG.c
index ce8e662a0b7c07420545c35036ab0118bf8be641..8152aa314b3a8dd573bbdce2ff9786b8b1881291 100644
--- a/x11vnc/macosxCG.c
+++ b/x11vnc/macosxCG.c
@@ -139,7 +139,11 @@ extern void do_new_fb(int);
 extern int macosx_wait_for_switch, macosx_resize;
 
 extern void macosxGCS_poll_pb(void);
+#if 0
 extern void usleep(unsigned long usec);
+#else
+extern int usleep(useconds_t usec);
+#endif
 extern unsigned int sleep(unsigned int seconds);
 extern void clean_up_exit (int ret);
 
diff --git a/x11vnc/macosxCGS.c b/x11vnc/macosxCGS.c
index 35cb9de8594f6b16186a3112c306652e721b079c..176a3361c981609a381c11883304d0aabe51828b 100644
--- a/x11vnc/macosxCGS.c
+++ b/x11vnc/macosxCGS.c
@@ -135,7 +135,11 @@ int macosxCGS_find_index(int w) {
 	return -1;
 }
 
+#if 0
 extern void usleep(unsigned long usec);
+#else
+extern int usleep(useconds_t usec);
+#endif
 
 int macosxCGS_follow_animation_win(int win, int idx, int grow) {
 	double t = dnow();
@@ -496,7 +500,9 @@ void macosxGCS_initpb(void) {
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	pblock = [[NSLock alloc] init];
 	if (![NSPasteboard generalPasteboard]) {
-		macosx_log("macosxGCS_initpb: pasteboard inaccessible.\n");
+		macosx_log("macosxGCS_initpb: **PASTEBOARD INACCESSIBLE**.\n");
+		macosx_log("macosxGCS_initpb: Clipboard exchange will NOT work.\n");
+		macosx_log("macosxGCS_initpb: Start x11vnc *inside* Aqua for Clipboard.\n");
 		pbcnt = 0;
 		pbstr = [[NSString alloc] initWithString:@"\e<PASTEBOARD INACCESSIBLE>\e"]; 
 	}
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index cd61a15ae368511ab738d260b2f5913e322ff6c0..ace6511ea8787ccbfc027afc4234f70335b37b37 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -848,17 +848,29 @@ char find_display[] =
 "# who(1) output column 2:\n"
 "#gone=`last $user | grep 'gone.*no.logout' | awk '{print $2}' | grep '^:' | sed -e 's,/.*,,' | tr '\\n' '|'`\n"
 "#gone=\"${gone}__quite_impossible__\"\n"
-"#display=`who | grep \"^${user}[ 	][ 	]*:[0-9]\" | egrep -v \" ($gone)\\>\" | head -n 1 \\\n"
+"#display=`who 2>/dev/null | grep \"^${user}[ 	][ 	]*:[0-9]\" | egrep -v \" ($gone)\\>\" | head -n 1 \\\n"
 "#    | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
 "poss=\"\"\n"
-"list=`who | grep \"^${user}[ 	][ 	]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
-"list=\"$list \"`w -h \"$user\" | grep \"^${user}[ 	][ 	]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
-"list=\"$list \"`who | grep \"^${user}[ 	]\" | awk '{print $NF}' | grep '(:[0-9]' | sed -e 's/[()]//g'`\n"
-"host=`hostname | sed -e 's/\\..*$//'`\n"
+"list=`who 2>/dev/null | grep \"^${user}[ 	][ 	]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
+"list=\"$list \"`w -h \"$user\" 2>/dev/null | grep \"^${user}[ 	][ 	]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
+"list=\"$list \"`who 2>/dev/null | grep \"^${user}[ 	]\" | awk '{print $NF}' | grep '(:[0-9]' | sed -e 's/[()]//g'`\n"
+"host=`hostname 2>/dev/null | sed -e 's/\\..*$//'`\n"
 "if [ \"X$X11VNC_FINDDISPLAY_SKIP_XAUTH\" = \"X\" ]; then\n"
 "	list=\"$list \"`xauth list | awk '{print $1}' | grep /unix | grep \"^${host}\" | sed -e 's/^.*:/:/' | sort -n | uniq`\n"
 "fi\n"
 "\n"
+"if [ \"X$uname\" = \"XDarwin\" ]; then\n"
+"	if who 2>/dev/null | grep -i \"^${user}[ 	][ 	]*console[ 	]\" > /dev/null; then\n"
+"		echo \"DISPLAY=console\"\n"
+"		if [ \"X$FIND_DISPLAY_ALL\" = \"X\" ]; then\n"
+"			if [ \"X$showxauth\" != \"X\" ]; then\n"
+"				echo \"\"\n"
+"			fi\n"
+"			exit 0\n"
+"		fi\n"
+"	fi\n"
+"fi\n"
+"\n"
 "for p in $list\n"
 "do\n"
 "	xa=`echo \"$p\" | awk -F, '{print $2}'`\n"
diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1
index e72a956655bd3b41121a0df993fbaeecdd1a3049..c69c3fc4ef4e988b4b5aa2988a040f9cedc7ea41 100644
--- a/x11vnc/x11vnc.1
+++ b/x11vnc/x11vnc.1
@@ -1,8 +1,8 @@
 .\" This file was automatically generated from x11vnc -help output.
-.TH X11VNC "1" "November 2007" "x11vnc " "User Commands"
+.TH X11VNC "1" "December 2007" "x11vnc " "User Commands"
 .SH NAME
 x11vnc - allow VNC connections to real X11 displays
-         version: 0.9.4, lastmod: 2007-11-07
+         version: 0.9.4, lastmod: 2007-12-15
 .SH SYNOPSIS
 .B x11vnc
 [OPTION]...
diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c
index 33953cd60f0d4d37f931c0673b441a22e3c0151c..e738cfada6f1227405daec2ad711d2ef8c2ca582 100644
--- a/x11vnc/x11vnc.c
+++ b/x11vnc/x11vnc.c
@@ -2860,6 +2860,8 @@ int main(int argc, char* argv[]) {
 			blackout_str = strdup(argv[++i]);
 		} else if (!strcmp(arg, "-xinerama")) {
 			xinerama = 1;
+		} else if (!strcmp(arg, "-noxinerama")) {
+			xinerama = 0;
 		} else if (!strcmp(arg, "-xtrap")) {
 			xtrap_input = 1;
 		} else if (!strcmp(arg, "-xrandr")) {
@@ -4106,8 +4108,20 @@ if (0) fprintf(stderr, "XA: %s\n", getenv("XAUTHORITY"));
 		}
 	}
 
+#ifdef MACOSX
+	if (use_dpy && !strcmp(use_dpy, "console")) {
+		;
+	} else
+#endif
 	if (use_dpy) {
 		dpy = XOpenDisplay_wr(use_dpy);
+#ifdef MACOSX
+	} else if (!subwin && getenv("DISPLAY")
+	    && strstr(getenv("DISPLAY"), "/tmp/") ) {
+		/* e.g. /tmp/launch-XlspvM/:0 on leopard */
+		rfbLog("MacOSX: Ignoring $DISPLAY '%s'\n", getenv("DISPLAY"));
+		rfbLog("MacOSX: Use -display $DISPLAY to force it.\n");
+#endif
 	} else if ( (use_dpy = getenv("DISPLAY")) ) {
 		dpy = XOpenDisplay_wr(use_dpy);
 	} else {
diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c
index 78f9157e27cd372e17d3d042a27e3261531b8884..7090a0b64e76b0d1653f622a45f9d66459450e48 100644
--- a/x11vnc/x11vnc_defs.c
+++ b/x11vnc/x11vnc_defs.c
@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
 int xdamage_base_event_type = 0;
 
 /*               date +'lastmod: %Y-%m-%d' */
-char lastmod[] = "0.9.4 lastmod: 2007-11-07";
+char lastmod[] = "0.9.4 lastmod: 2007-12-15";
 
 /* X display info */