diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog
index 263fb0351b8dc40c24163bb5cd56125ad228e10e..cbcfa9dd5a5e106993a20870bf1eebf316e4fd99 100644
--- a/x11vnc/ChangeLog
+++ b/x11vnc/ChangeLog
@@ -1,3 +1,7 @@
+2006-12-28  Karl Runge <runge@karlrunge.com>
+	* x11vnc: more work on -ncache, add macosx support, fix X errors
+	  and improve cache expiration algorithm.
+
 2006-12-17  Karl Runge <runge@karlrunge.com>
 	* x11vnc: first pass at client-side caching, -ncache option.
 	  have -http guess ../classes/.. to run out of build area.
diff --git a/x11vnc/README b/x11vnc/README
index 186866469db487d5d111f42d9df94544d6143af4..152561d70d40c9e77c46e7a9069dbd5e793cb642 100644
--- a/x11vnc/README
+++ b/x11vnc/README
@@ -1,5 +1,5 @@
 
-x11vnc README file                         Date: Sun Dec 17 18:16:37 EST 2006
+x11vnc README file                         Date: Thu Dec 28 00:14:27 EST 2006
 
 The following information is taken from these URLs:
 
@@ -641,17 +641,17 @@ make
    To aid testing of the [84]built-in SSL support for x11vnc, a number of
    VNC Viewer packages for Unix, Mac OS X, and Windows have been created
    that provide SSL Support for the TightVNC Viewer (this is done by
-   [85]wrapper scripts that start STUNNEL, [86]more details here). It
-   should be pretty convenient for automatic SSL and SSH connections. It
-   is described and can be downloaded from the [87]Enhanced TightVNC
-   Viewer (ssvnc) page.
+   [85]wrapper scripts and a GUI that start STUNNEL, [86]more details
+   here). It should be pretty convenient for automatic SSL and SSH
+   connections. It is described and can be downloaded from the
+   [87]Enhanced TightVNC Viewer (ssvnc) page.
 
 
    Here are some features that will appear in the 0.8.4 release:
      * Native Mac OS X support.
      * Wireframe copyrect detection for local user activity (e.g. someone
        sitting at the physical display moving windows)
-     * Option [88]-nodpms to avoid problems with programs like
+     * Option [88]-nodpms to avoid problems with programs like KDE's
        kdesktop_lock that keep restarting the screen saver every few
        seconds.
      * A new login mode: "-display wait:cmd=FINDCREATEDISPLAY -unixpw
@@ -667,11 +667,12 @@ make
        VNC CopyRect encoding is used to move it around (so any viewer
        should work). Until we start modifying viewers you will be able to
        see the cache area if you scroll down (this makes it easier to
-       debug!).
+       debug!). Test it with something like "-ncache 10".
 
    If you have a Mac please try out the native Mac OS X support (build
-   with "./configure --without-x"), even if you don't plan on using it in
-   this mode. Thanks.
+   with "./configure --without-x", or download a binary mentioned above),
+   even if you don't plan on using it in this mode, and let me know how
+   it went. Thanks.
 
 
    Here are some features that appeared in the 0.8.3 release:
@@ -1156,102 +1157,106 @@ make
    [203]Q-68: Can x11vnc try to apply heuristics to detect when a window
    is scrolling its contents and use the CopyRect encoding for a speedup?
    
+   [204]Q-69: Can x11vnc do client-side caching of pixel data? I.e. so
+   when that pixel data is needed again it does not have to be
+   retransmitted over the network. 
+
    [Mouse Cursor Shapes]
 
-   [204]Q-69: Why isn't the mouse cursor shape (the little icon shape
+   [205]Q-70: Why isn't the mouse cursor shape (the little icon shape
    where the mouse pointer is) correct as I move from window to window? 
 
-   [205]Q-70: When using XFIXES cursorshape mode, some of the cursors
+   [206]Q-71: When using XFIXES cursorshape mode, some of the cursors
    look really bad with extra black borders around the cursor and other
    cruft. How can I improve their appearance? 
 
-   [206]Q-71: In XFIXES mode, are there any hacks to handle cursor
+   [207]Q-72: In XFIXES mode, are there any hacks to handle cursor
    transparency ("alpha channel") exactly? 
 
    [Mouse Pointer]
 
-   [207]Q-72: Why does the mouse arrow just stay in one corner in my
+   [208]Q-73: Why does the mouse arrow just stay in one corner in my
    vncviewer, whereas my cursor (that does move) is just a dot? 
 
-   [208]Q-73: Can I take advantage of the TightVNC extension to the VNC
+   [209]Q-74: Can I take advantage of the TightVNC extension to the VNC
    protocol where Cursor Positions Updates are sent back to all connected
    clients (i.e. passive viewers can see the mouse cursor being moved
    around by another viewer)? 
 
-   [209]Q-74: Is it possible to swap the mouse buttons (e.g. left-handed
+   [210]Q-75: Is it possible to swap the mouse buttons (e.g. left-handed
    operation), or arbitrarily remap them? How about mapping button clicks
    to keystrokes, e.g. to partially emulate Mouse wheel scrolling? 
 
    [Keyboard Issues]
 
-   [210]Q-75: How can I get my AltGr and Shift modifiers to work between
+   [211]Q-76: How can I get my AltGr and Shift modifiers to work between
    keyboards for different languages? 
 
-   [211]Q-76: When I try to type a "<" (i.e. less than) instead I get ">"
+   [212]Q-77: When I try to type a "<" (i.e. less than) instead I get ">"
    (i.e. greater than)! Strangely, typing ">" works OK!! 
 
-   [212]Q-77: When I try to type a "<" (i.e. less than) instead I get
+   [213]Q-78: When I try to type a "<" (i.e. less than) instead I get
    "<," (i.e. an extra comma). 
 
-   [213]Q-78: I'm using an "international" keyboard (e.g. German "de", or
+   [214]Q-79: I'm using an "international" keyboard (e.g. German "de", or
    Danish "dk") and the -modtweak mode works well if the VNC viewer is
    run on a Unix/Linux machine with a similar keyboard.   But if I run
    the VNC viewer on Unix/Linux with a different keyboard (e.g. "us") or
    Windows with any keyboard, I can't type some keys like:   "@", "$",
    "<", ">", etc. How can I fix this? 
 
-   [214]Q-79: When typing I sometimes get double, triple, or more of my
+   [215]Q-80: When typing I sometimes get double, triple, or more of my
    keystrokes repeated. I'm sure I only typed them once, what can I do? 
 
-   [215]Q-80: The x11vnc -norepeat mode is in effect, but I still get
+   [216]Q-81: The x11vnc -norepeat mode is in effect, but I still get
    repeated keystrokes!! 
 
-   [216]Q-81: The machine where I run x11vnc has an AltGr key, but the
+   [217]Q-82: The machine where I run x11vnc has an AltGr key, but the
    local machine where I run the VNC viewer does not. Is there a way I
    can map a local unused key to send an AltGr? How about a Compose key
    as well? 
 
-   [217]Q-82: I have a Sun machine I run x11vnc on. Its Sun keyboard has
+   [218]Q-83: I have a Sun machine I run x11vnc on. Its Sun keyboard has
    just one Alt key labelled "Alt" and two Meta keys labelled with little
    diamonds. The machine where I run the VNC viewer only has Alt keys.
    How can I send a Meta keypress? (e.g. emacs needs this) 
 
-   [218]Q-83: Can I map a keystroke to a mouse button click on the remote
+   [219]Q-84: Can I map a keystroke to a mouse button click on the remote
    machine? 
 
-   [219]Q-84: How can I get Caps_Lock to work between my VNC viewer and
+   [220]Q-85: How can I get Caps_Lock to work between my VNC viewer and
    x11vnc? 
 
    [Screen Related Issues and Features]
 
-   [220]Q-85: The remote display is larger (in number of pixels) than the
+   [221]Q-86: The remote display is larger (in number of pixels) than the
    local display I am running the vncviewer on. I don't like the
    vncviewer scrollbars, what I can do? 
 
-   [221]Q-86: Does x11vnc support server-side framebuffer scaling? (E.g.
+   [222]Q-87: Does x11vnc support server-side framebuffer scaling? (E.g.
    to make the desktop smaller). 
 
-   [222]Q-87: Does x11vnc work with Xinerama? (i.e. multiple monitors
+   [223]Q-88: Does x11vnc work with Xinerama? (i.e. multiple monitors
    joined together to form one big, single screen). 
 
-   [223]Q-88: Can I use x11vnc on a multi-headed display that is not
+   [224]Q-89: Can I use x11vnc on a multi-headed display that is not
    Xinerama (i.e. separate screens :0.0, :0.1, ... for each monitor)? 
 
-   [224]Q-89: Can x11vnc show only a portion of the display? (E.g. for a
+   [225]Q-90: Can x11vnc show only a portion of the display? (E.g. for a
    special purpose rfb application). 
 
-   [225]Q-90: Does x11vnc support the XRANDR (X Resize, Rotate and
+   [226]Q-91: Does x11vnc support the XRANDR (X Resize, Rotate and
    Reflection) extension? Whenever I rotate or resize the screen x11vnc
    just seems to crash. 
 
-   [226]Q-91: Independent of any XRANDR, can I have x11vnc rotate and/or
+   [227]Q-92: Independent of any XRANDR, can I have x11vnc rotate and/or
    reflect the screen that the VNC viewers see? (e.g. for a handheld
    whose screen is rotated 90 degrees). 
 
-   [227]Q-92: Why is the view in my VNC viewer completely black? Or why
+   [228]Q-93: Why is the view in my VNC viewer completely black? Or why
    is everything flashing around randomly? 
 
-   [228]Q-93: I use Linux Virtual Consoles (VC's) to implement 'Fast User
+   [229]Q-94: I use Linux Virtual Consoles (VC's) to implement 'Fast User
    Switching' between users' sessions (e.g. Betty is on Ctrl-Alt-F7,
    Bobby is on Ctrl-Alt-F8, and Sid is on Ctrl-Alt-F1: they use those
    keystrokes to switch between their sessions).   How come the view in a
@@ -1259,60 +1264,60 @@ make
    otherwise all messed up unless the X session x11vnc is attached to is
    in the active VC? 
 
-   [229]Q-94: I am using x11vnc where my local machine has "popup/hidden
+   [230]Q-95: I am using x11vnc where my local machine has "popup/hidden
    taskbars" and the remote display where x11vnc runs also has
    "popup/hidden taskbars" and they interfere and fight with eachother.
    What can I do? 
 
-   [230]Q-95: Help! x11vnc and my KDE screensaver keep switching each
+   [231]Q-96: Help! x11vnc and my KDE screensaver keep switching each
    other on and off every few seconds. 
 
-   [231]Q-96: Can I use x11vnc to view my VMWare session remotely? 
+   [232]Q-97: Can I use x11vnc to view my VMWare session remotely? 
 
    [Exporting non-X11 devices via VNC]
 
-   [232]Q-97: Can non-X devices (e.g. a raw framebuffer) be viewed (and
+   [233]Q-98: Can non-X devices (e.g. a raw framebuffer) be viewed (and
    even controlled) via VNC with x11vnc? 
 
-   [233]Q-98: Can I export via VNC a Webcam or TV tuner framebuffer using
+   [234]Q-99: Can I export via VNC a Webcam or TV tuner framebuffer using
    x11vnc? 
 
-   [234]Q-99: Can I connect via VNC to a Qt-embedded/Qtopia application
+   [235]Q-100: Can I connect via VNC to a Qt-embedded/Qtopia application
    running on my handheld or PC using the Linux console framebuffer (i.e.
    not X11)? 
 
-   [235]Q-100: Now that non-X11 devices can be exported via VNC using
+   [236]Q-101: Now that non-X11 devices can be exported via VNC using
    x11vnc, can I build it with no dependencies on X11 header files and
    libraries? 
 
-   [236]Q-101: Does x11vnc support Mac OS X Aqua/Quartz displays natively
+   [237]Q-102: Does x11vnc support Mac OS X Aqua/Quartz displays natively
    (i.e. no X11 involved)? 
 
    [Misc: Clipboard, File Transfer/Sharing, Printing, Sound, Beeps,
    Thanks, etc.]
 
-   [237]Q-102: Does the Clipboard/Selection get transferred between the
+   [238]Q-103: Does the Clipboard/Selection get transferred between the
    vncviewer and the X display? 
 
-   [238]Q-103: Can I use x11vnc to record a Shock Wave Flash (or other
+   [239]Q-104: Can I use x11vnc to record a Shock Wave Flash (or other
    format) video of my desktop, e.g. to record a tutorial or demo? 
 
-   [239]Q-104: Can I transfer files back and forth with x11vnc? 
+   [240]Q-105: Can I transfer files back and forth with x11vnc? 
 
-   [240]Q-105: Can I (temporarily) mount my local (viewer-side)
+   [241]Q-106: Can I (temporarily) mount my local (viewer-side)
    Windows/Samba File share on the machine where x11vnc is running? 
 
-   [241]Q-106: Can I redirect CUPS print jobs from the remote desktop
+   [242]Q-107: Can I redirect CUPS print jobs from the remote desktop
    where x11vnc is running to a printer on my local (viewer-side)
    machine? 
 
-   [242]Q-107: How can I hear the sound (audio) from the remote
+   [243]Q-108: How can I hear the sound (audio) from the remote
    applications on the desktop I am viewing via x11vnc? 
 
-   [243]Q-108: Why don't I hear the "Beeps" in my X session (e.g. when
+   [244]Q-109: Why don't I hear the "Beeps" in my X session (e.g. when
    typing tput bel in an xterm)? 
 
-   [244]Q-109: Thanks for your program and for your help! Can I make a
+   [245]Q-110: Thanks for your program and for your help! Can I make a
    donation? 
      _________________________________________________________________
 
@@ -1325,7 +1330,7 @@ make
 
    For the former error, you need to specify the X display to connect to
    (it also needs to be on the same machine the x11vnc process is to run
-   on). Set your DISPLAY environment variable or use the [245]-display
+   on). Set your DISPLAY environment variable or use the [246]-display
    option to specify it. Nearly always the correct value will be ":0" (in
    fact, x11vnc will now assume :0 if given no other information).
 
@@ -1342,9 +1347,9 @@ make
    working when you try to start x11vnc via, say, a remote shell.
 
    How to Solve:  See the xauth(1), Xsecurity(7), and xhost(1) man pages
-   or [246]this Howto for much info on X11 permissions. For example, you
+   or [247]this Howto for much info on X11 permissions. For example, you
    may need to set your XAUTHORITY environment variable or use the
-   [247]-auth option to point to the correct MIT-MAGIC-COOKIE file (e.g.
+   [248]-auth option to point to the correct MIT-MAGIC-COOKIE file (e.g.
    /home/joe/.Xauthority or /var/gdm/:0.Xauth or /var/lib/kdm/A:0-crWk72K
    or /tmp/.gdmzndVlR, etc.), or simply be sure you run x11vnc as the
    correct user (i.e. the user who is logged into the X session you wish
@@ -1366,7 +1371,7 @@ make
   x11vnc -display :0 -auth /var/gdm/:0.Xauth
 
    (this is for the display manager gdm and requires root permission to
-   read the gdm cookie file, see [248]this faq for other display manager
+   read the gdm cookie file, see [249]this faq for other display manager
    cookie file names). While running x11vnc as root, remember it comes
    with no warranty ;-).
 
@@ -1376,7 +1381,7 @@ make
    (from the same machine). The person could then type "xhost -localhost"
    after x11vnc has connected to go back to the default permissions.
    Also, for some situations the "-users lurk=" option may be of use
-   (please read the documentation on the [249]-users option).
+   (please read the documentation on the [250]-users option).
 
    To test out your X11 permissions from a remote shell, set DISPLAY and
    possibly XAUTHORITY (see your shell's man page, bash(1), tcsh(1), on
@@ -1554,7 +1559,7 @@ h
    earlier and perhaps non-Solaris):
 
    First use the environment settings (CPPFLAGS, LDFLAGS, etc.) in the
-   above [250]Solaris build script to run the configure command. That
+   above [251]Solaris build script to run the configure command. That
    should succeed without failure. Then you have to hand edit the
    autogenerated rfb/rfbconfig.h file in the source tree, and just before
    the last #endif at the bottom of that file insert these workaround
@@ -1580,7 +1585,7 @@ typedef unsigned int in_addr_t;
    on other older OS (Solaris, Linux, ...) releases.
 
    Here are some notes for similar steps that need to be done to build on
-   [251]SunOS 4.x
+   [252]SunOS 4.x
 
    Please let us know if you had to use the above workaround (and whether
    it worked or not). If there is enough demand we will try to push clean
@@ -1590,28 +1595,28 @@ typedef unsigned int in_addr_t;
    Q-5: Where can I get a precompiled x11vnc binary for my Operating
    System?
 
-   Hopefully the [252]build steps above and [253]FAQ provide enough info
+   Hopefully the [253]build steps above and [254]FAQ provide enough info
    for a painless compile for most environments. Please report problems
    with the x11vnc configure, make, etc. on your system (if your system
    is known to compile other GNU packages successfully).
 
    There are precompiled x11vnc binaries built by other groups that are
    available at the following locations:
-    Debian:         (.deb)  [254]http://packages.debian.org/x11vnc
-
-   Slackware: (.tgz) [255]http://www.linuxpackages.net/ Redhat/Fedora:
-   (.rpm) [256]http://dag.wieers.com/packages/x11vnc/
-   [257]http://dries.ulyssis.org/rpm/packages/x11vnc SuSE: (.rpm)
-   [258]http://linux01.gwdg.de/~pbleser/ Solaris: (pkg)
-   [259]http://www.sunfreeware.com/ FreeBSD: (.tbz)
-   [260]http://www.freebsd.org/ [261]http://www.freshports.org/net/x11vnc
-   OpenBSD: (.tgz) [262]http://www.openbsd.org/ NetBSD: (src)
-   [263]http://pkgsrc.se/x11/x11vnc Nokia 770 (.deb)
-   [264]http://mike.saunby.net/770/x11vnc/ Sharp Zaurus
-   [265]http://www.pdaxrom.org/ and [266]http://www.focv.com/
+    Debian:         (.deb)  [255]http://packages.debian.org/x11vnc
+
+   Slackware: (.tgz) [256]http://www.linuxpackages.net/ Redhat/Fedora:
+   (.rpm) [257]http://dag.wieers.com/packages/x11vnc/
+   [258]http://dries.ulyssis.org/rpm/packages/x11vnc SuSE: (.rpm)
+   [259]http://linux01.gwdg.de/~pbleser/ Solaris: (pkg)
+   [260]http://www.sunfreeware.com/ FreeBSD: (.tbz)
+   [261]http://www.freebsd.org/ [262]http://www.freshports.org/net/x11vnc
+   OpenBSD: (.tgz) [263]http://www.openbsd.org/ NetBSD: (src)
+   [264]http://pkgsrc.se/x11/x11vnc Nokia 770 (.deb)
+   [265]http://mike.saunby.net/770/x11vnc/ Sharp Zaurus
+   [266]http://www.pdaxrom.org/ and [267]http://www.focv.com/
 
    If the above binaries don't work and building x11vnc on your OS fails
-   (and all else fails!) you can try one of [267]my collection of
+   (and all else fails!) you can try one of [268]my collection of
    binaries for various OS's and x11vnc releases.
 
    As a general note, the x11vnc program is simple enough you don't
@@ -1629,7 +1634,7 @@ typedef unsigned int in_addr_t;
    If you use a standalone binary like this and also want x11vnc to serve
    up the Java VNC Viewer jar file (either SSL enabled or regular one),
    then you will need to extract the classes subdirectory from the source
-   tarball and point x11vnc to it via the [268]-httpdir option. E.g.:
+   tarball and point x11vnc to it via the [269]-httpdir option. E.g.:
     x11vnc -httpdir /path/to/x11vnc-0.8.3/classes/ssl ...
 
 
@@ -1638,11 +1643,11 @@ typedef unsigned int in_addr_t;
 
    To obtain VNC viewers for the viewing side (Windows, Mac OS, or Unix)
    try here:
-     * [269]http://www.tightvnc.com/download.html
-     * [270]http://www.realvnc.com/download-free.html
-     * [271]http://sourceforge.net/projects/cotvnc/
-     * [272]http://www.ultravnc.com/
-     * [273]Our Enhanced TightVNC Viewer (ssvnc)
+     * [270]http://www.tightvnc.com/download.html
+     * [271]http://www.realvnc.com/download-free.html
+     * [272]http://sourceforge.net/projects/cotvnc/
+     * [273]http://www.ultravnc.com/
+     * [274]Our Enhanced TightVNC Viewer (ssvnc)
 
 
    Q-7: How can I see all of x11vnc's command line options and
@@ -1650,7 +1655,7 @@ typedef unsigned int in_addr_t;
 
    Run:  x11vnc -opts   to list just the option names or run:  x11vnc
    -help   for long descriptions about each option. The output is listed
-   [274]here as well. Yes, x11vnc does have a lot of options, doesn't
+   [275]here as well. Yes, x11vnc does have a lot of options, doesn't
    it...
 
 
@@ -1682,10 +1687,10 @@ display :0
    program is needed for operation. The gui is not particularly
    user-friendly, it just provides a point and click mode to set all the
    many x11vnc parameters and obtain help on them. It is also very useful
-   for testing. See the [275]-gui option for more info. Examples: "x11vnc
+   for testing. See the [276]-gui option for more info. Examples: "x11vnc
    ... -gui" and "x11vnc ... -gui other:0" in the latter case the gui is
    displayed on other:0, not the X display x11vnc is polling. There is
-   also a "[276]-gui tray" system tray mode.
+   also a "[277]-gui tray" system tray mode.
 
 
    Q-9: How can I get the GUI to run in the System Tray, or at least be a
@@ -1724,11 +1729,11 @@ display :0
    Q-11: Can I make x11vnc more quiet and also go into the background
    after starting up?
 
-   Use the [277]-q and [278]-bg options, respectively.  (also: -quiet is
+   Use the [278]-q and [279]-bg options, respectively.  (also: -quiet is
    an alias for -q)
 
    Note that under -bg the stderr messages will be lost unless you use
-   the "[279]-o logfile" option.
+   the "[280]-o logfile" option.
 
 
    Q-12: Sometimes when a VNC viewer dies abruptly, x11vnc also dies with
@@ -1749,7 +1754,7 @@ display :0
 
    There are some options. They are enabled by adding something like
    -Dxxxx=1 to the CPPFLAGS environment variable before running configure
-   (see the [280]build notes for general background).
+   (see the [281]build notes for general background).
 /*
  * Mar/2006
  * Build-time customization via CPPFLAGS.
@@ -1820,21 +1825,21 @@ display :0
    dual-screen mode to pass the keystrokes and mouse motions to the X11
    display?
 
-   Yes, for best response start up x11vnc with the "[281]-nofb" option
+   Yes, for best response start up x11vnc with the "[282]-nofb" option
    (disables framebuffer polling, and does other optimizations) on the
    secondary display (X11) machine. Then start up Win2VNC on the primary
    display (Windows) referring it to the secondary display.
 
-   This will also work X11 to X11 using [282]x2vnc, however you would
+   This will also work X11 to X11 using [283]x2vnc, however you would
    probably just want to avoid VNC and use x2x for that.
 
    For reference, here are some links to Win2VNC-like programs for
    multiple monitor setups:
-     * [283]Original Win2VNC
-     * [284]Enhanced Win2VNC and [285]sourceforge link
-     * [286]x2vnc
-     * [287]x2x also [288]here
-     * [289]zvnc (MorphOS)
+     * [284]Original Win2VNC
+     * [285]Enhanced Win2VNC and [286]sourceforge link
+     * [287]x2vnc
+     * [288]x2x also [289]here
+     * [290]zvnc (MorphOS)
 
    All of them will work with x11vnc (except x2x where it is not needed).
 
@@ -1854,7 +1859,7 @@ display :0
    on your display to be depth 24 TrueColor? Sun machines often have 8+24
    overlay/multi-depth visuals, and you can make the default visual depth
    24 TrueColor (see fbconfig(1) and Xsun(1)). 2) As of Feb/2004 x11vnc
-   has the [290]-visual option to allow you to force the framebuffer
+   has the [291]-visual option to allow you to force the framebuffer
    visual to whatever you want (this usually messes up the colors unless
    you are very clever). In this case, the option provides a convenient
    workaround for the Win2VNC bug:
@@ -1868,7 +1873,7 @@ display :0
    and keyboard input to it from Windows and X11 machines via Win2VNC and
    x2vnc, respectively?
 
-   Yes, as of Nov/2006 [291]you can. There may be a trick or two you'll
+   Yes, as of Nov/2006 [292]you can. There may be a trick or two you'll
    need to do to get the Clipboard exchange between the machines to work.
 
 
@@ -1879,7 +1884,7 @@ display :0
    PseudoColor (i.e. only 256 distinct colors). The x11vnc colors may
    start out OK, but after a while they are incorrect in certain windows.
 
-   Use the [292]-flashcmap option to have x11vnc watch for changes in the
+   Use the [293]-flashcmap option to have x11vnc watch for changes in the
    colormap, and propagate those changes back to connected clients. This
    can be slow (since the whole screen must be updated over the network
    whenever the colormap changes). This flashing colormap behavior often
@@ -1888,13 +1893,13 @@ display :0
    example of this. Consider reconfiguring the system to 16 bpp or depth
    24 TrueColor if at all possible.
 
-   Also note the option [293]-8to24 (Jan/2006) can often remove the need
+   Also note the option [294]-8to24 (Jan/2006) can often remove the need
    for flashing the colormap. Everything is dynamically transformed to
    depth 24 at 32 bpp using the colormaps. There may be painting errors
    however (see the following FAQ for tips on reducing and correcting
    them).
 
-   In some rare cases the [294]-notruecolor option has corrected colors
+   In some rare cases the [295]-notruecolor option has corrected colors
    on 8bpp displays. The red, green, and blue masks were non-zero in 8bpp
    PseudoColor on an obscure setup, and this option corrected the
    problems.
@@ -1905,13 +1910,13 @@ display :0
    different color depths: e.g. there are both depth 8 and 24 visuals
    available at the same time.
 
-   You may want to review the [295]previous question regarding 8 bpp
+   You may want to review the [296]previous question regarding 8 bpp
    PseudoColor.
 
-   On some hardware (Sun/SPARC and SGI), the [296]-overlay option
+   On some hardware (Sun/SPARC and SGI), the [297]-overlay option
    discussed a couple paragraphs down may solve this for you (you may
    want to skip to it directly). On other hardware the less robust
-   [297]-8to24 option may help (also discussed below).
+   [298]-8to24 option may help (also discussed below).
 
    Run xdpyinfo(1) to see what the default visual is and what the depths
    of the other visuals are. Does the default visual have a depth of 8
@@ -1947,7 +1952,7 @@ TrueColor defdepth 24
 
    The -overlay mode: Another option is if the system with overlay
    visuals is a Sun system running Solaris or SGI running IRIX you can
-   use the [298]-overlay x11vnc option (Aug/2004) to have x11vnc use the
+   use the [299]-overlay x11vnc option (Aug/2004) to have x11vnc use the
    Solaris XReadScreen(3X11) function to poll the "true view" of the
    whole screen at depth 24 TrueColor. XReadDisplay(3X11) is used on
    IRIX. This is useful for Legacy applications (older versions of
@@ -1972,7 +1977,7 @@ TrueColor defdepth 24
    Xsun, e.g. in your /etc/dt/config/Xservers file).
 
 
-   The -8to24 mode: The [299]-8to24 x11vnc option (Jan/2006) is a kludge
+   The -8to24 mode: The [300]-8to24 x11vnc option (Jan/2006) is a kludge
    to try to dynamically rewrite the pixel values so that the 8bpp part
    of the screen is mapped onto depth 24 TrueColor. This is less robust
    than the -overlay mode because it is done by x11vnc outside of the X
@@ -1986,11 +1991,11 @@ TrueColor defdepth 24
    32bpp view is exported via VNC.
 
    Even on pure 8bpp displays it can be used as an alternative to
-   [300]-flashcmap to avoid color flashing completely.
+   [301]-flashcmap to avoid color flashing completely.
 
    This scheme is approximate and can often lead to painting errors. You
    can manually correct most painting errors by pressing 3 Alt_L's in a
-   row, or by using something like: [301]-fixscreen V=3.0 to
+   row, or by using something like: [302]-fixscreen V=3.0 to
    automatically refresh the screen every 3 seconds. Also -fixscreen
    8=3.0 has been added to just refresh the non-default visual parts of
    the screen.
@@ -2003,23 +2008,23 @@ TrueColor defdepth 24
    nogetimage can give a nice speedup if the default depth 24 X server
    supports hiding the 8bpp bits in bits 25-32 of the framebuffer data.
    On very slow machines -8to24 poll=0.2,cachewin=5.0 gives an useful
-   speedup. See the [302]-8to24 help description for information on
+   speedup. See the [303]-8to24 help description for information on
    tunable parameters, etc.
 
 
    Colors still not working correctly? Run xwininfo on the application
    with the incorrect colors to verify that the depth of its visual is
    different from the default visual depth (gotten from xdpyinfo). One
-   possible workaround in this case is to use the [303]-id option to
+   possible workaround in this case is to use the [304]-id option to
    point x11vnc at the application window itself. If the application is
    complicated (lots of toplevel windows and popup menus) this may not be
    acceptable, and may even crash x11vnc (but not the application).
 
    It is theoretically possible to solve this problem in general (see
    xwd(1) for example), but it does not seem trivial or sufficiently fast
-   for x11vnc to be able to do so in real time. The [304]-8to24 method
+   for x11vnc to be able to do so in real time. The [305]-8to24 method
    does this approximately and is somewhat usable. Fortunately the
-   [305]-overlay option works for Solaris machines with overlay visuals
+   [306]-overlay option works for Solaris machines with overlay visuals
    where most of this problem occurs.
 
 
@@ -2030,9 +2035,9 @@ TrueColor defdepth 24
    the desired application window. After clicking, it will print out much
    information, including the window id (e.g. 0x6000010). Also, the
    visual and depth of the window printed out is often useful in
-   debugging x11vnc [306]color problems.
+   debugging x11vnc [307]color problems.
 
-   Also, as of Dec/2004 you can use "[307]-id pick" to have x11vnc run
+   Also, as of Dec/2004 you can use "[308]-id pick" to have x11vnc run
    xwininfo(1) for you and after you click the window it extracts the
    windowid. Besides "pick" there is also "id:root" to allow you to go
    back to root window when doing remote-control.
@@ -2050,7 +2055,7 @@ TrueColor defdepth 24
    you should be able to see these transient windows.
 
    If things are not working and you still want to do the single window
-   polling, try the [308]-sid windowid option ("shifted" windowid).
+   polling, try the [309]-sid windowid option ("shifted" windowid).
 
 
    Q-21: My X display is depth 24 at 24bpp (instead of the normal depth
@@ -2085,7 +2090,7 @@ TrueColor defdepth 24
    handle 24bpp from the server, so you may want to use those. They
    evidently request 32 bpp and libvncserver obliges.
 
-   Update: as of Apr/2006 you can use the [309]-24to32 option to have
+   Update: as of Apr/2006 you can use the [310]-24to32 option to have
    x11vnc dynamically transform the 24bpp pixel data to 32bpp. This extra
    transformation could slow things down further however.
 
@@ -2104,15 +2109,15 @@ TrueColor defdepth 24
    since you will be polling the X display over the network as opposed to
    over the local hardware. To do this, run x11vnc on a UNIX machine as
    close as possible network-wise (e.g. same switch) to the Xterminal
-   machine. Use the [310]-display option to point the display to that of
+   machine. Use the [311]-display option to point the display to that of
    the Xterminal (you'll of course need basic X11 permission to do that)
-   and finally supply the [311]-noshm option (this enables the polling
+   and finally supply the [312]-noshm option (this enables the polling
    over the network).
 
    The response will likely be sluggish (maybe only one "frame" per
    second). This mode is not recommended except for "quick checks" of
    hard to get to X servers. Use something like "-wait 150" to cut down
-   on the polling rate. You may also need [312]-flipbyteorder if the
+   on the polling rate. You may also need [313]-flipbyteorder if the
    colors get messed up due to endian byte order differences.
 
    Q-23: How do I get my X permissions (MIT-MAGIC-COOKIE file) correct
@@ -2136,7 +2141,7 @@ TrueColor defdepth 24
    copied to the Xterminal. If $HOME/.Xauthority is exported via NFS
    (this is insecure of course, but has been going on for decades), then
    x11vnc can simply pick it up via NFS (you may need to use the
-   [313]-auth option to point to the correct file). Other options include
+   [314]-auth option to point to the correct file). Other options include
    copying the auth file using scp, or something like:
   central-server>  xauth nextract - xterm123:0 | ssh xterm123 xauth nmerge -
 
@@ -2148,7 +2153,7 @@ TrueColor defdepth 24
    details.
 
    If the display name in the cookie file needs to be changed between the
-   two hosts, see [314]this note on the "xauth add ..." command.
+   two hosts, see [315]this note on the "xauth add ..." command.
 
    A less secure option is to run something like "xhost +127.0.0.1" while
    sitting at the Xterminal box to allow cookie-free local access for
@@ -2162,7 +2167,7 @@ TrueColor defdepth 24
    occasional app more efficiently locally on the Xterminal box (e.g.
    realplayer).
 
-   Not recommended, but as a last resort, you could have x11vnc [315]poll
+   Not recommended, but as a last resort, you could have x11vnc [316]poll
    the Xterminal Display over the network. For this you would run a
    "x11vnc -noshm ..." process on the central-server (and hope the
    network admin doesn't get angry...)
@@ -2191,13 +2196,13 @@ TrueColor defdepth 24
 
    Q-24: I'm having trouble using x11vnc with my Sun Ray session.
 
-   The [316]Sun Ray technology is a bit like "VNC done in hardware" (the
+   The [317]Sun Ray technology is a bit like "VNC done in hardware" (the
    Sun Ray terminal device, DTU, playing the role of the vncviewer).
    Completely independent of that, the SunRay user's session is still an
    X server that speaks the X11 protocol and so x11vnc simply talks to
    the X server part to export the SunRay desktop to any place in the
    world (i.e. not only to a Sun Ray terminal device), creating a sort of
-   "Soft Ray". Please see [317]this discussion of Sun Ray issues for
+   "Soft Ray". Please see [318]this discussion of Sun Ray issues for
    solutions to problems.
 
    [Remote Control]
@@ -2205,18 +2210,18 @@ TrueColor defdepth 24
    Q-25: How do I stop x11vnc once it is running in the background?
 
    As of Dec/2004 there is a remote control feature. It can change a huge
-   amount of things on the fly: see the [318]-remote and [319]-query
+   amount of things on the fly: see the [319]-remote and [320]-query
    options. To shut down the running x11vnc server just type "x11vnc -R
    stop". To disconnect all clients do "x11vnc -R disconnect:all", etc.
 
-   If the [320]-forever option has not been supplied, x11vnc will
+   If the [321]-forever option has not been supplied, x11vnc will
    automatically exit after the first client disconnects. In general if
    you cannot use the remote control, then you will have to kill the
    x11vnc process This can be done via: "kill NNNNN" (where NNNNN is the
    x11vnc process id number found from ps(1)), or "pkill x11vnc", or
    "killall x11vnc" (Linux only).
 
-   If you have not put x11vnc in the background via the [321]-bg option
+   If you have not put x11vnc in the background via the [322]-bg option
    or shell & operator, then simply press Ctrl-C in the shell where
    x11vnc is running to stop it.
 
@@ -2226,15 +2231,15 @@ TrueColor defdepth 24
    down state in the Xserver. Tapping the stuck key (either via a new
    x11vnc or at the physical console) will release it from the stuck
    state. If the keyboard seems to be acting strangely it is often fixed
-   by tapping Ctrl, Shift, and Alt. Alternatively, the [322]-clear_mods
-   option and [323]-clear_keys option can be used to release pressed keys
+   by tapping Ctrl, Shift, and Alt. Alternatively, the [323]-clear_mods
+   option and [324]-clear_keys option can be used to release pressed keys
    at startup and exit.
 
 
    Q-26: Can I change settings in x11vnc without having to restart it?
    Can I remote control it?
 
-   Look at the [324]-remote (same as -R) and [325]-query (same as -Q)
+   Look at the [325]-remote (same as -R) and [326]-query (same as -Q)
    options added in Dec/2004. They allow nearly everything to be changed
    dynamically and settings to be queried. Examples: "x11vnc -R shared",
    "x11vnc -R forever", "x11vnc -R scale:3/4", "x11vnc -Q modtweak",
@@ -2245,7 +2250,7 @@ TrueColor defdepth 24
    correctly for communication to be possible.
 
    There is also a simple Tcl/Tk gui based on this remote control
-   mechanism. See the [326]-gui option for more info. You will need to
+   mechanism. See the [327]-gui option for more info. You will need to
    have Tcl/Tk (i.e. /usr/bin/wish) installed for it to work. It can also
    run in the system tray: "-gui tray" or as a standalone icon window:
    "-gui icon".
@@ -2260,12 +2265,12 @@ TrueColor defdepth 24
    vncpasswd(1) program from those packages.
 
    As of Jun/2004 x11vnc supports the -storepasswd "pass" "file"
-   [327]option, which is the same functionality of storepasswd. Be sure
+   [328]option, which is the same functionality of storepasswd. Be sure
    to quote the "pass" if it contains shell meta characters, spaces, etc.
    Example:
   x11vnc -storepasswd 'sword*fish' $HOME/myvncpasswd
 
-   You then use the password via the x11vnc option: "[328]-rfbauth
+   You then use the password via the x11vnc option: "[329]-rfbauth
    $HOME/myvncpasswd"
 
    As of Jan/2006 if you do not supply any arguments:
@@ -2277,11 +2282,11 @@ TrueColor defdepth 24
    ~/.mypass", the password you are prompted for will be stored in that
    file.
 
-   x11vnc also has the [329]-passwdfile and -passwd/-viewpasswd plain
+   x11vnc also has the [330]-passwdfile and -passwd/-viewpasswd plain
    text (i.e. not obscured like the -rfbauth VNC passwords) password
    options.
 
-   You can use the [330]-usepw option to automatically use any password
+   You can use the [331]-usepw option to automatically use any password
    file you have in ~/.vnc/passwd or ~/.vnc/passwdfile (the latter is
    used with the -passwdfile option).
 
@@ -2313,14 +2318,14 @@ TrueColor defdepth 24
    Q-29: Can I have two passwords for VNC viewers, one for full access
    and the other for view-only access to the display?
 
-   Yes, as of May/2004 there is the [331]-viewpasswd option to supply the
-   view-only password. Note the full-access password option [332]-passwd
+   Yes, as of May/2004 there is the [332]-viewpasswd option to supply the
+   view-only password. Note the full-access password option [333]-passwd
    must be supplied at the same time. E.g.: -passwd sword -viewpasswd
    fish.
 
    To avoid specifying the passwords on the command line (where they
    could be observed via the ps(1) command by any user) you can use the
-   [333]-passwdfile option to specify a file containing plain text
+   [334]-passwdfile option to specify a file containing plain text
    passwords. Presumably this file is readable only by you, and ideally
    it is located on the machine x11vnc is run on (to avoid being snooped
    on over the network). The first line of this file is the full-access
@@ -2328,7 +2333,7 @@ TrueColor defdepth 24
    it is taken as the view-only password. (use "__EMPTY__" to supply an
    empty one).
 
-   View-only passwords currently do not work for the [334]-rfbauth
+   View-only passwords currently do not work for the [335]-rfbauth
    password option (standard VNC password storing mechanism). FWIW, note
    that although the output (usually placed in $HOME/.vnc/passwd) by the
    vncpasswd or storepasswd programs (or from x11vnc -storepasswd) looks
@@ -2341,7 +2346,7 @@ TrueColor defdepth 24
    Q-30: Can I have as many full-access and view-only passwords as I
    like?
 
-   Yes, as of Jan/2006 in the libvncserver CVS the [335]-passwdfile
+   Yes, as of Jan/2006 in the libvncserver CVS the [336]-passwdfile
    option has been extended to handle as many passwords as you like. You
    put the view-only passwords after a line __BEGIN_VIEWONLY__.
 
@@ -2351,7 +2356,7 @@ TrueColor defdepth 24
 
    Q-31: Does x11vnc support Unix usernames and passwords? Can I further
    limit the set of Unix usernames who can connect to the VNC desktop?
-   Update: as of Feb/2006 x11vnc has the [336]-unixpw option that does
+   Update: as of Feb/2006 x11vnc has the [337]-unixpw option that does
    this outside of the VNC protocol and libvncserver. The standard su(1)
    program is used to validate the user's password. A familiar "login:"
    and "Password:" dialog is presented to the user on a black screen
@@ -2361,7 +2366,7 @@ TrueColor defdepth 24
    A list of allowed Unix usernames may also be supplied along with
    per-user settings.
 
-   There is also the [337]-unixpw_nis option for non-shadow-password
+   There is also the [338]-unixpw_nis option for non-shadow-password
    (typically NIS environments, hence the name) systems where the
    traditional getpwnam() and crypt() functions are used instead of
    su(1). The encrypted user passwords must be accessible to the user
@@ -2370,11 +2375,11 @@ TrueColor defdepth 24
    shadow(5).
 
    Two settings are enforced in the -unixpw and -unixpw_nis modes to
-   provide extra security: the 1) [338]-localhost and 2) [339]-stunnel or
-   [340]-ssl options. Without these one might send the Unix username and
+   provide extra security: the 1) [339]-localhost and 2) [340]-stunnel or
+   [341]-ssl options. Without these one might send the Unix username and
    password data in clear text over the network which is a very bad idea.
    They can be relaxed if you want to provide encryption other than
-   stunnel or [341]-ssl (the constraint is automatically relaxed if
+   stunnel or [342]-ssl (the constraint is automatically relaxed if
    SSH_CONNECTION is set and indicates you have ssh-ed in, however the
    -localhost requirement is still enforced).
 
@@ -2393,13 +2398,13 @@ TrueColor defdepth 24
    approximate at best.
 
    One approximate method involves starting x11vnc with the
-   [342]-localhost option. This basically requires the viewer user to log
+   [343]-localhost option. This basically requires the viewer user to log
    into the workstation where x11vnc is running via their Unix username
    and password, and then somehow set up a port redirection of his
    vncviewer connection to make it appear to emanate from the local
    machine. As discussed above, ssh is useful for this: "ssh -L
    5900:localhost:5900 user@hostname ..." See the ssh wrapper scripts
-   mentioned [343]elsewhere on this page. [344]stunnel does this as well.
+   mentioned [344]elsewhere on this page. [345]stunnel does this as well.
 
    Of course a malicious user could allow other users to get in through
    his channel, but that is a problem with every method. Another thing to
@@ -2410,7 +2415,7 @@ TrueColor defdepth 24
    traditional way would be to further require a VNC password to supplied
    (-rfbauth, -passwd, etc) and only tell the people allowed in what the
    VNC password is. A scheme that avoids a second password involves using
-   the [345]-accept option that runs a program to examine the connection
+   the [346]-accept option that runs a program to examine the connection
    information to determine which user is connecting from the local
    machine. That may be difficult to do, but, for example, the program
    could use the ident service on the local machine (normally ident
@@ -2446,7 +2451,7 @@ exit 1  # reject it
    method (e.g. Dynamic/One-time passwords or non-Unix (LDAP) usernames
    and passwords)?
    Yes, there are several possibilities. For background see the FAQ on
-   the [346]-accept where an external program may be run to decide if a
+   the [347]-accept where an external program may be run to decide if a
    VNC client should be allowed to try to connect and log in. If the
    program (or local user prompted by a popup) answers "yes", then
    -accept proceeds to the normal VNC and x11vnc authentication methods,
@@ -2454,26 +2459,26 @@ exit 1  # reject it
 
    To provide more direct coupling to the VNC client's username and/or
    supplied password the following options were added in Sep/2006:
-     * [347]-unixpw_cmd command
-     * [348]-passwdfile cmd:command
-     * [349]-passwdfile custom:command
+     * [348]-unixpw_cmd command
+     * [349]-passwdfile cmd:command
+     * [350]-passwdfile custom:command
 
    In each case "command" is an external command run by x11vnc. You
    supply it. For example, it may couple to your LDAP system or other
    servers you set up.
 
-   For [350]-unixpw_cmd the normal [351]-unixpw Login: and Password:
+   For [351]-unixpw_cmd the normal [352]-unixpw Login: and Password:
    prompts are supplied to the VNC viewer and the strings the client
    returns are then piped into "command" as the first two lines of its
    standard input. If the command returns success, i.e. exit(0), the VNC
    client is accepted, otherwise it is rejected.
 
-   For "[352]-passwdfile cmd:command" the command is run and it returns a
-   password list (like a password file, see the [353]-passwdfile
+   For "[353]-passwdfile cmd:command" the command is run and it returns a
+   password list (like a password file, see the [354]-passwdfile
    read:filename mode). Perhaps a dynamic, one-time password is retrieved
    from a server this way.
 
-   For "[354]-passwdfile custom:command" one gets complete control over
+   For "[355]-passwdfile custom:command" one gets complete control over
    the VNC challenge-response dialog with the VNC client. x11vnc sends
    out a string of random bytes (16 by the VNC spec) and the client
    returns the same number of bytes in a way the server can verify only
@@ -2487,7 +2492,7 @@ exit 1  # reject it
    it is rejected.
 
    In all cases the "RFB_*" enviornment variables are set as under
-   [355]-accept. These variables can provide useful information for the
+   [356]-accept. These variables can provide useful information for the
    externally supplied program to use.
 
 
@@ -2497,15 +2502,15 @@ exit 1  # reject it
 
    These defaults are simple safety measures to avoid someone unknowingly
    leaving his X11 desktop exposed (to the internet, say) for long
-   periods of time. Use the [356]-forever option (aka -many) to have
+   periods of time. Use the [357]-forever option (aka -many) to have
    x11vnc wait for more connections after the first client disconnects.
-   Use the [357]-shared option to have x11vnc allow multiple clients to
+   Use the [358]-shared option to have x11vnc allow multiple clients to
    connect simultaneously.
 
-   Recommended additional safety measures include using ssh ([358]see
-   above), stunnel, [359]-ssl, or a VPN to authenticate and encrypt the
+   Recommended additional safety measures include using ssh ([359]see
+   above), stunnel, [360]-ssl, or a VPN to authenticate and encrypt the
    viewer connections or to at least use the -rfbauth passwd-file
-   [360]option to use VNC password protection (or [361]-passwdfile) It is
+   [361]option to use VNC password protection (or [362]-passwdfile) It is
    up to YOU to apply these security measures, they will not be done for
    you automatically.
 
@@ -2513,7 +2518,7 @@ exit 1  # reject it
    Q-34: Can I limit which machines incoming VNC clients can connect
    from?
 
-   Yes, look at the [362]-allow and [363]-localhost options to limit
+   Yes, look at the [363]-allow and [364]-localhost options to limit
    connections by hostname or IP address. E.g.
   x11vnc -allow 192.168.0.1,192.168.0.2
 
@@ -2525,7 +2530,7 @@ exit 1  # reject it
    Note that -localhost achieves the same thing as "-allow 127.0.0.1"
 
    For more control, build libvncserver with libwrap support
-   [364](tcp_wrappers) and then use /etc/hosts.allow See hosts_access(5)
+   [365](tcp_wrappers) and then use /etc/hosts.allow See hosts_access(5)
    for complete details.
 
 
@@ -2545,7 +2550,7 @@ exit 1  # reject it
    is "vnc", e.g.:
   vnc: 192.168.100.3 .example.com
 
-   Note that if you run x11vnc out of [365]inetd you do not need to build
+   Note that if you run x11vnc out of [366]inetd you do not need to build
    x11vnc with libwrap support because the /usr/sbin/tcpd reference in
    /etc/inetd.conf handles the tcp_wrappers stuff.
 
@@ -2554,15 +2559,15 @@ exit 1  # reject it
    internal LAN) rather than having it listen on all network interfaces
    and relying on -allow to filter unwanted connections out?
 
-   As of Mar/2005 there is the "[366]-listen ipaddr" option that enables
+   As of Mar/2005 there is the "[367]-listen ipaddr" option that enables
    this. For ipaddr either supply the desired network interface's IP
    address (or use a hostname that resolves to it) or use the string
    "localhost". For additional filtering simultaneously use the
-   "[367]-allow host1,..." option to allow only specific hosts in.
+   "[368]-allow host1,..." option to allow only specific hosts in.
 
    This option is useful if you want to insure that no one can even begin
    a dialog with x11vnc from untrusted network interfaces (e.g. ppp0).
-   The option [368]-localhost now implies "-listen localhost" since that
+   The option [369]-localhost now implies "-listen localhost" since that
    is what most people expect it to do.
 
 
@@ -2570,7 +2575,7 @@ exit 1  # reject it
    interface, how I can occasionally allow in a non-localhost via the -R
    allowonce remote control command?
 
-   To do this specify "[369]-allow localhost". Unlike [370]-localhost
+   To do this specify "[370]-allow localhost". Unlike [371]-localhost
    this will leave x11vnc listening on all interfaces (but of course only
    allowing in local connections, e.g. ssh redirs). Then you can later
    run "x11vnc -R allowonce:somehost" or use to gui to permit a one-shot
@@ -2581,7 +2586,7 @@ exit 1  # reject it
    some users just be able to move the mouse, but not click or type
    anything?
 
-   As of Feb/2005, the [371]-input option allows you to do this. "K",
+   As of Feb/2005, the [372]-input option allows you to do this. "K",
    "M", "B", and "C" stand for Keystroke, Mouse-motion, Button-clicks,
    and Clipboard, respectively. The setting: "-input M" makes attached
    viewers only able to move the mouse. "-input KMBC,M" lets normal
@@ -2596,7 +2601,7 @@ exit 1  # reject it
    some clients view-only? How about running an arbitrary program to make
    the decisions?
 
-   Yes, look at the "[372]-accept command" option, it allows you to
+   Yes, look at the "[373]-accept command" option, it allows you to
    specify an external command that is run for each new client. (use
    quotes around the command if it contains spaces, etc.). If the
    external command returns 0 the client is accepted, otherwise the
@@ -2615,7 +2620,7 @@ exit 1  # reject it
    own simple popup window. To accept the client press "y" or click mouse
    on the "Yes" button. To reject the client press "n" or click mouse on
    the "No" button. To accept the client View-only, press "v" or click
-   mouse on the "View" button. If the [373]-viewonly option has been
+   mouse on the "View" button. If the [374]-viewonly option has been
    supplied, the "View" action will not be present: the whole display is
    view only in that case.
 
@@ -2631,7 +2636,7 @@ exit 1  # reject it
    program to prompt the user whether the client should be accepted or
    not. This requires that you have xmessage installed and available via
    PATH. In case it is not already on your system, the xmessage program
-   is available at [374]ftp://ftp.x.org/
+   is available at [375]ftp://ftp.x.org/
 
    To include view-only decisions for the external commands, prefix the
    command something like this: "yes:0,no:*,view:3 mycommand ..." This
@@ -2670,7 +2675,7 @@ elif [ $rc = 4 ]; then
 fi
 exit 1
 
-   Stefan Radman has written a nice dtksh script [375]dtVncPopup for use
+   Stefan Radman has written a nice dtksh script [376]dtVncPopup for use
    in CDE environments to do the same sort of thing. Information on how
    to use it is found at the top of the file. He encourages you to
    provide feedback to him to help improve the script.
@@ -2679,13 +2684,13 @@ exit 1
    popup is being run, so attached clients will not receive screen
    updates, etc during this period.
 
-   To run a command when a client disconnects, use the "[376]-gone
+   To run a command when a client disconnects, use the "[377]-gone
    command" option. This is for the user's convenience only: the return
    code of the command is not interpreted by x11vnc. The same environment
    variables are set as in "-accept command" (except that RFB_MODE will
    be "gone").
 
-   As of Jan/2006 the "[377]-afteraccept command" option will run the
+   As of Jan/2006 the "[378]-afteraccept command" option will run the
    command only after the VNC client has been accepted and authenticated.
    Like -gone the return code is not interprted. RFB_MODE will be
    "afteraccept").
@@ -2695,7 +2700,7 @@ exit 1
    display manager like gdm(1). Can I have x11vnc later switch to a
    different user?
 
-   As of Feb/2005 x11vnc has the [378]-users option that allows things
+   As of Feb/2005 x11vnc has the [379]-users option that allows things
    like this. Please read the documentation on it (also in the x11vnc
    -help output) carefully for features and caveats. It's use can often
    decrease security unless care is taken.
@@ -2720,7 +2725,7 @@ exit 1
 
    In any event, as of Jun/2004 there is an experimental utility to make
    it more difficult for nosey people to see your x11vnc activities. The
-   source for it is [379]blockdpy.c The idea behind it is simple (but
+   source for it is [380]blockdpy.c The idea behind it is simple (but
    obviously not bulletproof): when a VNC client attaches to x11vnc put
    the display monitor in the DPMS "off" state, if the DPMS state ever
    changes immediately start up the screen-lock program. The x11vnc user
@@ -2736,8 +2741,8 @@ exit 1
    bulletproof. A really robust solution would likely require X server
    and perhaps even video hardware support.
 
-   The blockdpy utility is launched by the [380]-accept option and told
-   to exit via the [381]-gone option (the vnc client user should
+   The blockdpy utility is launched by the [381]-accept option and told
+   to exit via the [382]-gone option (the vnc client user should
    obviously re-lock the screen before disconnecting!). Instructions can
    be found in the source code for the utility at the above link.
 
@@ -2745,7 +2750,7 @@ exit 1
    Q-42: Can I have x11vnc automatically lock the screen when I
    disconnect the VNC viewer?
 
-   Yes, a user mentions he uses the [382]-gone option under CDE to run a
+   Yes, a user mentions he uses the [383]-gone option under CDE to run a
    screen lock program:
   x11vnc -display :0 -forever -gone 'dtaction LockDisplay'
 
@@ -2754,7 +2759,7 @@ exit 1
   x11vnc -display :0 -forever -gone 'kdesktop_lock'
   x11vnc -display :0 -forever -gone 'xlock &'
 
-   Here is a scheme using the [383]-afteraccept option (in version 0.7.3)
+   Here is a scheme using the [384]-afteraccept option (in version 0.7.3)
    to unlock the screen after the first valid VNC login and to lock the
    screen after the last valid VNC login disconnects:
   x11vnc -display :0 -forever -shared -afteraccept ./myxlocker -gone ./myxlocke
@@ -2785,21 +2790,21 @@ fi
    Q-43: How can I tunnel my connection to x11vnc via an encrypted SSH
    channel between two Unix machines?
 
-   See the description earlier on this page on [384]how to tunnel VNC via
+   See the description earlier on this page on [385]how to tunnel VNC via
    SSH from Unix to Unix. A number of ways are described along with some
    issues you may encounter.
 
    Other secure encrypted methods exists, e.g. stunnel, IPSEC, various
    VPNs, etc.
 
-   See also the [385]Enhanced TightVNC Viewer (ssvnc) page where much of
+   See also the [386]Enhanced TightVNC Viewer (ssvnc) page where much of
    this is now automated.
 
 
    Q-44: How can I tunnel my connection to x11vnc via an encrypted SSH
    channel from Windows using an SSH client like Putty?
 
-   [386]Above we described how to tunnel VNC via SSH from Unix to Unix,
+   [387]Above we described how to tunnel VNC via SSH from Unix to Unix,
    you may want to review it. To do this from Windows using Putty it
    would go something like this:
      * In the Putty dialog window under 'Session' enter the hostname or
@@ -2820,11 +2825,11 @@ fi
    :0 (plus other cmdline options) in the 'Remote command' Putty setting
    under 'Connections/SSH'.
 
-   See also the [387]Enhanced TightVNC Viewer (ssvnc) page where much of
+   See also the [388]Enhanced TightVNC Viewer (ssvnc) page where much of
    this is now automated via the Putty plink utility.
 
-   For extra protection feel free to run x11vnc with the [388]-localhost
-   and [389]-rfbauth/[390]-passwdfile options.
+   For extra protection feel free to run x11vnc with the [389]-localhost
+   and [390]-rfbauth/[391]-passwdfile options.
 
    If the machine you SSH into via Putty is not the same machine with the
    X display you wish to view (e.g. your company provides incoming SSH
@@ -2832,11 +2837,11 @@ fi
    dialog setting to: 'Destination: otherhost:5900', Once logged in,
    you'll need to do a second login (ssh or rsh) to the workstation
    machine 'otherhost' and then start up x11vnc on it. This can also be
-   automated by [391]chaining ssh's.
+   automated by [392]chaining ssh's.
 
-   As discussed [392]above another option is to first start the VNC
+   As discussed [393]above another option is to first start the VNC
    viewer in "listen" mode, and then launch x11vnc with the
-   "[393]-connect localhost" option to establish the reverse connection.
+   "[394]-connect localhost" option to establish the reverse connection.
    In this case a Remote port redirection (not Local) is needed for port
    5500 instead of 5900 (i.e. 'Source port:  5500' and
    'Destination:  localhost:5500' for a Remote connection).
@@ -2846,7 +2851,7 @@ fi
    channel using an external tool like stunnel?
 
    It is possible to use a "lighter weight" encryption setup than SSH or
-   IPSEC. SSL tunnels such as [394]stunnel (also [395]stunnel.mirt.net)
+   IPSEC. SSL tunnels such as [395]stunnel (also [396]stunnel.mirt.net)
    provide an encrypted channel without the need for Unix users,
    passwords, and key passphrases required for ssh (and at the other
    extreme SSL can also provide a complete signed certificate chain of
@@ -2854,12 +2859,12 @@ fi
    often let its port through, ssh is frequently the path of least
    resistance (it also nicely manages public keys for you).
 
-   Update: As of Feb/2006 x11vnc has the options [396]-ssl,
-   [397]-stunnel, and [398]-sslverify to provide integrated SSL schemes.
-   They are discussed [399]in the Next FAQ (you may want to skip to it
+   Update: As of Feb/2006 x11vnc has the options [397]-ssl,
+   [398]-stunnel, and [399]-sslverify to provide integrated SSL schemes.
+   They are discussed [400]in the Next FAQ (you may want to skip to it
    now).
 
-   Here are some basic examples using [400]stunnel but the general idea
+   Here are some basic examples using [401]stunnel but the general idea
    for any SSL tunnel utility is the same:
      * Start up x11vnc and constrain it to listen on localhost.
      * Then start up the SSL tunnel running on the same machine to
@@ -2883,7 +2888,7 @@ fi
 
    The above two commands are run on host "far-away.east". The
    stunnel.pem is the self-signed PEM file certificate created when
-   stunnel is built. One can also create certificates [401]signed by
+   stunnel is built. One can also create certificates [402]signed by
    Certificate Authorities or self-signed if desired using the x11vnc
    utilities described there.
 
@@ -2897,7 +2902,7 @@ fi
    Then point the viewer to the local tunnel on port 5902:
   vncviewer -encodings "copyrect tight zrle hextile" localhost:2
 
-   That's it.  (note that the [402]ss_vncviewer script can automate
+   That's it.  (note that the [403]ss_vncviewer script can automate
    this.)
 
    Be sure to use a VNC password because unlike ssh by default the
@@ -2905,13 +2910,13 @@ fi
    some extra configuration one could also set up certificates to provide
    authentication of either or both sides as well (and hence avoid
    man-in-the-middle attacks). See the stunnel and openssl documentation
-   and also [403]the key management section for details.
+   and also [404]the key management section for details.
 
    stunnel has also been ported to Windows, and there are likely others
    to choose from for that OS. Much info for using it on Windows can be
-   found at the stunnel site and in this [404]article The article also
+   found at the stunnel site and in this [405]article The article also
    shows the detailed steps to set up all the authentication
-   certificates. (for both server and clients, see also the [405]x11vnc
+   certificates. (for both server and clients, see also the [406]x11vnc
    utilities that do this). The default Windows client setup (no certs)
    is simpler and only 4 files are needed in a folder: stunnel.exe,
    stunnel.conf, libssl32.dll, libeay32.dll. We used an stunnel.conf
@@ -2932,7 +2937,7 @@ connect = far-away.east:5901
    As an aside, if you don't like the little "gap" of unencrypted TCP
    traffic (and a localhost listening socket) on the local machine
    between stunnel and x11vnc it can actually be closed by having stunnel
-   start up x11vnc in [406]-inetd mode:
+   start up x11vnc in [407]-inetd mode:
   stunnel -p /path/to/stunnel.pem -P none -d 5900 -l ./x11vnc_sh
 
    Where the script x11vnc_sh starts up x11vnc:
@@ -2975,28 +2980,28 @@ connect = 5900
    they probably wouldn't work since the SSL negotiation is likely
    embedded in the VNC protocol unlike our case where it is external.
 
-   Note: as of Mar/2006 libvncserver/x11vnc provides a [407]SSL-enabled
-   Java applet that can be served up via the [408]-httpdir or [409]-http
-   options when [410]-ssl is enabled. It will also be served via HTTPS
+   Note: as of Mar/2006 libvncserver/x11vnc provides a [408]SSL-enabled
+   Java applet that can be served up via the [409]-httpdir or [410]-http
+   options when [411]-ssl is enabled. It will also be served via HTTPS
    via either the VNC port (e.g. https://host:5900/) or a 2nd port via
-   the [411]-https option.
+   the [412]-https option.
 
    In general current SSL VNC solutions are not particularly "seemless".
    But it can be done, and with a wrapper script on the viewer side and
-   the [412]-stunnel or [413]-ssl option on the server side it works well
-   and is convenient. Here is a simple script [414]ss_vncviewer that
+   the [413]-stunnel or [414]-ssl option on the server side it works well
+   and is convenient. Here is a simple script [415]ss_vncviewer that
    automates running stunnel on the VNC viewer side on Unix a little more
    carefully than the commands printed above. (One could probably do a
    similar thing with a .BAT file on Windows in the stunnel folder.)
 
-   Update Jul/2006: we now provide an [415]Enhanced TightVNC Viewer
+   Update Jul/2006: we now provide an [416]Enhanced TightVNC Viewer
    (ssvnc) package that starts up STUNNEL automatically along with some
    other features. All binaries are provided in the package.
 
 
    Q-46: Does x11vnc have built-in SSL tunneling?
 
-   You can read about non-built-in methods [416]in the Previous FAQ
+   You can read about non-built-in methods [417]in the Previous FAQ
 
    SSL tunnels provide an encrypted channel without the need for Unix
    users, passwords, and key passphrases required for ssh (and at the
@@ -3007,14 +3012,14 @@ connect = 5900
 
    Built-in SSL x11vnc options:
 
-   As of Feb/2006 the x11vnc [417]-ssl and [418]-stunnel options automate
-   the SSL tunnel creation on the x11vnc server side. An [419]SSL-enabled
+   As of Feb/2006 the x11vnc [418]-ssl and [419]-stunnel options automate
+   the SSL tunnel creation on the x11vnc server side. An [420]SSL-enabled
    Java Viewer applet is also provided that can be served via HTTP or
    HTTPS to automate SSL on the client side.
 
-   The [420]-ssl mode uses the [421]www.openssl.org library if available
-   at build time. The [422]-stunnel mode requires the
-   [423]www.stunnel.org command stunnel(8) to be installed on the system.
+   The [421]-ssl mode uses the [422]www.openssl.org library if available
+   at build time. The [423]-stunnel mode requires the
+   [424]www.stunnel.org command stunnel(8) to be installed on the system.
 
    Both modes require an SSL certificate and key (i.e. .pem file). These
    are usually created via the openssl(1) (in fact in for options "-ssl"
@@ -3066,12 +3071,12 @@ connect = 5900
    is to encrypt the key with a passphrase (note however this requires
    supplying the passphrase each time x11vnc is started up).
 
-   See the discussion on [424]x11vnc Key Management for some utilities
+   See the discussion on [425]x11vnc Key Management for some utilities
    provided for creating and managing certificates and keys and even for
    creating your own Certificate Authority (CA) for signing VNC server
    and client certificates. This may be done by importing the certificate
    into Web Browser or Java plugin keystores, or pointing stunnel to it.
-   The wrapper script [425]ss_vncviewer provides an example on unix
+   The wrapper script [426]ss_vncviewer provides an example on unix
    (-verify option).
 
    Here are some notes on the simpler default (non-CA) operation. To have
@@ -3087,7 +3092,7 @@ connect = 5900
    to machines where the VNC Viewer will be run to enable authenticating
    the x11vnc SSL VNC server to the clients. When authentication takes
    place this way (or via the more sophisticated CA signing described
-   [426]here), then Man-In-The-Middle-Attacks are prevented. Otherwise,
+   [427]here), then Man-In-The-Middle-Attacks are prevented. Otherwise,
    the SSL encryption only provides protection against passive network
    traffic "sniffing". Nowadays, most people seem mostly concerned about
    only the latter (and the default x11vnc SSL modes protect against it.)
@@ -3112,7 +3117,7 @@ connect = 5900
    including using https to download it into the browser and connect to
    x11vnc.
 
-   See the [427]next FAQ for SSL enabled VNC Viewers.
+   See the [428]next FAQ for SSL enabled VNC Viewers.
 
 
    Q-47: How do I use VNC Viewers with built-in SSL tunneling?
@@ -3123,9 +3128,9 @@ connect = 5900
    The SSL enabled Java VNC Viewer (VncViewer.jar) in the x11vnc package
    supports only SSL based connections by default (set the applet
    parameter disableSSL=yes in index.vnc to override). As mentioned above
-   the [428]-httpdir can be used to specify the path to .../classes/ssl.
+   the [429]-httpdir can be used to specify the path to .../classes/ssl.
    A typical location might be /usr/local/share/x11vnc/classes/ssl. Or
-   [429]-http can be used to try to have it find the directory
+   [430]-http can be used to try to have it find the directory
    automatically.
 
    The Java viewer uses SSL to communicate securely with x11vnc. Note
@@ -3150,7 +3155,7 @@ connect = 5900
    example) can occasionally be slow or unreliable (it has to read some
    input and try to guess if the connection is VNC or HTTP). If it is
    unreliable and you still want to serve the Java applet via https, use
-   the [430]-https option to get an additional port dedicated to https
+   the [431]-https option to get an additional port dedicated to https
    (its URL will also be printed in the output).
 
    Another possibility is to add the GET applet parameter:
@@ -3163,7 +3168,7 @@ connect = 5900
 
    You may also use "urlPrefix=somestring" to have /somestring prepended
    to /request.https.vnc.connection". Perhaps you are using a web server
-   [431]proxy scheme to enter a firewall or otherwise have rules applied
+   [432]proxy scheme to enter a firewall or otherwise have rules applied
    to the URL. If you need to have any slashes "/" in "somestring" use
    "_2F_" (a deficiency in libvncserver prevents using the more natural
    "%2F".)
@@ -3187,11 +3192,11 @@ connect = 5900
    connection is VNC instead of the HTTPS it actually is (but since you
    have paused too long at the dialog the GET request comes too late).
    Often hitting Reload and going through the dialogs more quickly will
-   let you connect. Use the [432]-https option if you want a dedicated
+   let you connect. Use the [433]-https option if you want a dedicated
    port for HTTPS connections instead of sharing the VNC port.
 
    To see example x11vnc output for a successful https://host:5900/
-   connection with the Java Applet see [433]This Page.
+   connection with the Java Applet see [434]This Page.
 
 
    Notes on the VNC Viewer ss_vncviewer wrapper script:
@@ -3199,10 +3204,10 @@ connect = 5900
    If you want to use a native VNC Viewer with the SSL enabled x11vnc you
    will need to run an external SSL tunnel on the Viewer side. There do
    not seem to be any native SSL VNC Viewers outside of the x11vnc
-   package. The basic ideas of doing this were discussed [434]for
+   package. The basic ideas of doing this were discussed [435]for
    external tunnel utilities here.
 
-   The [435]ss_vncviewer script provided with x11vnc can set up the
+   The [436]ss_vncviewer script provided with x11vnc can set up the
    stunnel tunnel automatically on unix as long as the stunnel command is
    installed on the Viewer machine and available in PATH (and vncviewer
    too of course). Note that on Debian based system you will need to
@@ -3234,14 +3239,14 @@ connect = 5900
 
    The fifth one shows that Web proxies can be used if that is the only
    way to get out of the firewall. If the "double proxy" situation arises
-   separate the two by commas. See [436]this page for more information on
+   separate the two by commas. See [437]this page for more information on
    how Web proxies come into play.
 
-   If one uses a Certificate Authority (CA) scheme described [437]here,
+   If one uses a Certificate Authority (CA) scheme described [438]here,
    the wrapper script would use the CA cert instead of the server cert:
   3')  ss_vncviewer -verify ./cacert.crt far-away.east:0
 
-   Update Jul/2006: we now provide an [438]Enhanced TightVNC Viewer
+   Update Jul/2006: we now provide an [439]Enhanced TightVNC Viewer
    (ssvnc) package that starts up STUNNEL automatically along with some
    other features. All binaries are provided in the package.
 
@@ -3277,7 +3282,7 @@ connect = 5900
    (instead of the unsigned one in https://yourmachine.com:5900/ that
    gives the default index.vnc)
 
-   Note that the [439]ss_vncviewer stunnel wrapper script can use Web
+   Note that the [440]ss_vncviewer stunnel wrapper script can use Web
    proxies as well.
 
    Proxies that limit CONNECT to ports 443 and 563:
@@ -3306,7 +3311,7 @@ connect = 5900
   https://yourmachine.com/proxy.vnc?PORT=443
 
    this is cleaner because it avoids editing the file, but requires more
-   parameters in the URL. To use the GET [440]trick discussed above, do:
+   parameters in the URL. To use the GET [441]trick discussed above, do:
   https://yourmachine.com/proxy.vnc?PORT=443&GET=1
 
 
@@ -3314,7 +3319,7 @@ connect = 5900
    SSL from the Internet with a Web browser to x11vnc running on their
    workstations behind a firewall?
    Yes. You will need to configure apache to forward these connections.
-   It is discussed [441]here. This provides a clean alternative to the
+   It is discussed [442]here. This provides a clean alternative to the
    traditional method where the user uses SSH to log in through the
    gateway to create the encrypted port redirection to x11vnc running on
    her desktop.
@@ -3322,7 +3327,7 @@ connect = 5900
 
    Q-50: Can I create and use my own SSL Certificate Authority (CA) with
    x11vnc?
-   Yes, see [442]this page for how to do this and the utility commands
+   Yes, see [443]this page for how to do this and the utility commands
    x11vnc provides to create and manage many types of certificates and
    private keys.
 
@@ -3341,14 +3346,14 @@ connect = 5900
    need to have sufficient permissions to connect to the X display.
 
    Here are some ideas:
-     * Use the description under "Continuously" in the [443]FAQ on x11vnc
+     * Use the description under "Continuously" in the [444]FAQ on x11vnc
        and Display Managers
-     * Use the description in the [444]FAQ on x11vnc and inetd(8)
-     * Use the description in the [445]FAQ on Unix user logins and
+     * Use the description in the [445]FAQ on x11vnc and inetd(8)
+     * Use the description in the [446]FAQ on Unix user logins and
        inetd(8)
      * Start x11vnc from your $HOME/.xsession (or $HOME/.xinitrc or
        autostart script or ...)
-     * Although less reliable, see the [446]x11vnc_loop rc.local hack
+     * Although less reliable, see the [447]x11vnc_loop rc.local hack
        below.
 
    The display manager scheme will not be specific to which user has the
@@ -3370,7 +3375,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    X startup scripts (traditionally .xsession/.xinitrc) may have to be in
    a different directory or have a different basename. One user
    recommends the description under 'Running Scripts Automatically' at
-   [447]this link.
+   [448]this link.
 
 
    Q-52: How can I use x11vnc to connect to an X login screen like xdm,
@@ -3385,7 +3390,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    while running x11vnc as root, e.g. for the gnome display manager, gdm:
   x11vnc -auth /var/gdm/:0.Xauth -display :0
 
-   (the [448]-auth option sets the XAUTHORITY variable for you).
+   (the [449]-auth option sets the XAUTHORITY variable for you).
 
    There will be a similar thing for xdm using however a different auth
    directory path (perhaps something like
@@ -3410,7 +3415,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    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
-   [449]the example at the end of this FAQ). Then restart dtlogin, e.g.:
+   [450]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.
 
    Continuously.   Have x11vnc reattach each time the X server is
@@ -3473,7 +3478,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
 
    Then restart: /usr/sbin/gdm-restart (or reboot). The
    KillInitClients=false setting is important: without it x11vnc will be
-   killed immediately after the user logs in. Here are [450]full details
+   killed immediately after the user logs in. Here are [451]full details
    on how to configure gdm
      _________________________________________________________________
 
@@ -3515,14 +3520,14 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
 
    If you do not want to deal with any display manager startup scripts,
    here is a kludgey script that can be run manually or out of a boot
-   file like rc.local: [451]x11vnc_loop It will need some local
+   file like rc.local: [452]x11vnc_loop It will need some local
    customization before running. Because the XAUTHORITY auth file must be
    guessed by this script, use of the display manager script method
-   described above is greatly preferred. There is also the [452]-loop
+   described above is greatly preferred. There is also the [453]-loop
    option that does something similar.
 
    If the machine is a traditional Xterminal you may want to read
-   [453]this FAQ.
+   [454]this FAQ.
 
 
    Q-53: Can I run x11vnc out of inetd(8)? How about xinetd(8)?
@@ -3532,7 +3537,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
 
   5900 stream tcp nowait root /usr/sbin/tcpd /usr/local/bin/x11vnc_sh
 
-   where the shell script /usr/local/bin/x11vnc_sh uses the [454]-inetd
+   where the shell script /usr/local/bin/x11vnc_sh uses the [455]-inetd
    option and looks something like (you'll need to customize to your
    settings).
 #!/bin/sh
@@ -3545,7 +3550,7 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    and that confuses it greatly, causing it to abort). If you do not use
    a wrapper script as above but rather call x11vnc directly in
    /etc/inetd.conf and do not redirect stderr to a file, then you must
-   specify the -q (aka [455]-quiet) option: "/usr/local/bin/x11vnc -q
+   specify the -q (aka [456]-quiet) option: "/usr/local/bin/x11vnc -q
    -inetd ...". When you supply both -q and -inet and no "-o logfile"
    then stderr will automatically be closed (to prevent, e.g. library
    stderr messages leaking out to the viewer). The recommended practice
@@ -3553,12 +3558,12 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
    script with "2>logfile" redirection because the errors and warnings
    printed out are very useful in troubleshooting problems.
 
-   Note also the need to set XAUTHORITY via [456]-auth to point to the
+   Note also the need to set XAUTHORITY via [457]-auth to point to the
    MIT-COOKIE auth file to get permission to connect to the X display
    (setting and exporting the XAUTHORITY variable accomplishes the same
    thing). See the x11vnc_loop file in the previous question for more
    ideas on what that auth file may be, etc. The scheme described in the
-   [457]FAQ on Unix user logins and inetd(8) works around the XAUTHORITY
+   [458]FAQ on Unix user logins and inetd(8) works around the XAUTHORITY
    issue nicely.
 
    Note:  On Solaris you cannot have the bare number 5900 in
@@ -3624,13 +3629,13 @@ service x11vncservice
    and then have it find her X display on that machine and then connect
    to it?
 
-   The easiest way to do this is via [458]inetd(8) using the [459]-unixpw
-   and [460]-display WAIT options. The reason inetd(8) makes this easier
+   The easiest way to do this is via [459]inetd(8) using the [460]-unixpw
+   and [461]-display WAIT options. The reason inetd(8) makes this easier
    is that it starts a new x11vnc process for each new user connection.
    Otherwise a wrapper would have to listen for connections and spawn new
-   x11vnc's (see [461]this example).
+   x11vnc's (see [462]this example).
 
-   The [462]-display WAIT option makes x11vnc wait until a VNC viewer is
+   The [463]-display WAIT option makes x11vnc wait until a VNC viewer is
    connected before attaching to the X display. Additionally it can be
    used to run an external command that returns the DISPLAY and
    XAUTHORITY data. So one could supply "-display
@@ -3674,7 +3679,7 @@ exit 0
    or raw xauth data (the above example does the latter). On Linux if the
    virtual terminal is known append ",VT=n" to the DISPLAY line.
 
-   The [463]-unixpw option allows [464]UNIX password logins. Here are a
+   The [464]-unixpw option allows [465]UNIX password logins. Here are a
    couple /etc/inetd.conf examples for this:
 5900  stream  tcp  nowait  nobody  /usr/sbin/tcpd /usr/local/bin/x11vnc -inetd
 -unixpw \
@@ -3694,9 +3699,9 @@ xpw=
    directory will need to be set up to allow "nobody" to use them.
 
    In the second one x11vnc is run as root and switches to the user that
-   logs in due to the "[465]-users unixpw=" option.
+   logs in due to the "[466]-users unixpw=" option.
 
-   Note that [466]SSL is required for this mode because otherwise the
+   Note that [467]SSL is required for this mode because otherwise the
    unix password would be passed in clear text over the network. In
    general -unixpw is not required for this sort of scheme, but it is
    convenient because it determines exactly who the user is whose display
@@ -3708,7 +3713,7 @@ xpw=
    FINDDISPLAY method it will create an X server session for the user.
    This is the only time x11vnc actually tries to start up an X server.
    By default it will only try to start up virtual (non-hardware) X
-   servers: first [467]Xdummy and if that does not work Xvfb. Note that
+   servers: first [468]Xdummy and if that does not work Xvfb. Note that
    Xdummy requires root permission and only works on Linux.
 
    So an inetd(8) example might look like:
@@ -3718,7 +3723,7 @@ xpw=
 11vnc
 
    Where the very long lines have been split. This will allow direct SSL
-   (e.g. [468]ss_vncviewer) access and also Java Web browers access via:
+   (e.g. [469]ss_vncviewer) access and also Java Web browers access via:
    https://hostname:5915/.
 
    For reference, xinetd format in the file, say, /etc/xinetd.d/x11vnc:
@@ -3743,7 +3748,7 @@ ocal/bin/x11vnc
    WAIT:cmd=FINDCREATEDISPLAY-X,Xvfb,Xdummy". The "X" one means to try to
    start up a real, hardware X server (if there is already a real X
    server running this may only work on Linux and the chvt program may
-   [469]need to be run to switch to the correct Linux virtual terminal).
+   [470]need to be run to switch to the correct Linux virtual terminal).
    x11vnc will try to run chvt automatically if it can determine which VT
    should be switched to.
 
@@ -3759,7 +3764,7 @@ ocal/bin/x11vnc
    Q-55: Can I have x11vnc restart itself after it terminates?
 
    One could do this in a shell script, but now there is an option
-   [470]-loop that makes it easier. Of course when x11vnc restarts it
+   [471]-loop that makes it easier. Of course when x11vnc restarts it
    needs to have permissions to connect to the (potentially new) X
    display. This mode could be useful if the X server restarts often. Use
    e.g. "-loop5000" to sleep 5000 ms between restarts. Also "-loop2000,5"
@@ -3770,7 +3775,7 @@ ocal/bin/x11vnc
    web browser?
 
    To have x11vnc serve up a Java VNC viewer applet to any web browsers
-   that connect to it, run x11vnc with this [471]option:
+   that connect to it, run x11vnc with this [472]option:
   -httpdir /path/to/the/java/classes/dir
 
    (this directory will contain the files index.vnc and, for example,
@@ -3789,7 +3794,7 @@ ocal/bin/x11vnc
    then you can connect to that URL with any Java enabled browser. Feel
    free to customize the default index.vnc file in the classes directory.
 
-   As of May/2005 the [472]-http option will try to guess where the Java
+   As of May/2005 the [473]-http option will try to guess where the Java
    classes jar file is by looking in expected locations and ones relative
    to the x11vnc binary.
 
@@ -3805,7 +3810,7 @@ ocal/bin/x11vnc
    As of Mar/2004 x11vnc supports reverse connections. On Unix one starts
    the VNC viewer in listen mode: vncviewer -listen (see your
    documentation for Windows, etc), and then starts up x11vnc with the
-   [473]-connect option. To connect immediately at x11vnc startup time
+   [474]-connect option. To connect immediately at x11vnc startup time
    use the "-connect host:port" option (use commas for a list of hosts to
    connect to). The ":port" is optional (default is 5500).
 
@@ -3813,7 +3818,7 @@ ocal/bin/x11vnc
    file is checked periodically (about once a second) for new hosts to
    connect to.
 
-   The [474]-remote control option (aka -R) can also be used to do this
+   The [475]-remote control option (aka -R) can also be used to do this
    during an active x11vnc session, e.g.:
 x11vnc -display :0 -R connect:hostname.domain
 
@@ -3825,7 +3830,7 @@ x11vnc -display :0 -R connect:hostname.domain
    starting x11vnc.
 
    To use the vncconnect(1) program (from the core VNC package at
-   www.realvnc.com) specify the [475]-vncconnect option to x11vnc (Note:
+   www.realvnc.com) specify the [476]-vncconnect option to x11vnc (Note:
    as of Dec/2004 -vncconnect is now the default). vncconnect(1) must be
    pointed to the same X11 DISPLAY as x11vnc (since it uses X properties
    to communicate with x11vnc). If you do not have or do not want to get
@@ -3868,8 +3873,8 @@ xprop -root -f VNC_CONNECT 8s -set VNC_CONNECT "$1"
    "screen scrape" it efficiently (more than, say, 100X faster than
    normal video hardware).
 
-   Update Nov/2006: See the [476]FINDCREATEDISPLAY discussion of the
-   "[477]-display WAIT:cmd=FINDDISPLAY" option where virtual (Xvfb or
+   Update Nov/2006: See the [477]FINDCREATEDISPLAY discussion of the
+   "[478]-display WAIT:cmd=FINDDISPLAY" option where virtual (Xvfb or
    Xdummy, or even real ones by changing an option) X servers are started
    automatically for new users connecting. This provides a "desktop
    service" for the machine. You either get your real X session or your
@@ -3878,7 +3883,7 @@ xprop -root -f VNC_CONNECT 8s -set VNC_CONNECT "$1"
 
    There are some annoyances WRT Xvfb though. The default keyboard
    mapping seems to be very poor. One should run x11vnc with
-   [478]-add_keysyms option to have keysyms added automatically. Also, to
+   [479]-add_keysyms option to have keysyms added automatically. Also, to
    add the Shift_R and Control_R modifiers something like this is needed:
 #!/bin/sh
 xmodmap -e "keycode any = Shift_R"
@@ -3904,11 +3909,11 @@ xmodmap -e "add Mod1 = Alt_L Alt_R Meta_L"
 
    The main drawback to this method (besides requiring extra
    configuration and possibly root permission) is that it also does the
-   Linux Virtual Console/Terminal (VC/VT) [479]switching even though it
+   Linux Virtual Console/Terminal (VC/VT) [480]switching even though it
    does not need to (since it doesn't use a real framebuffer). There are
    some "dual headed" (actually multi-headed/multi-user) patches to the X
    server that turn off the VT usage in the X server. Update: As of
-   Jul/2005 we have an LD_PRELOAD script [480]Xdummy that allows you to
+   Jul/2005 we have an LD_PRELOAD script [481]Xdummy that allows you to
    use a stock (i.e. unpatched) Xorg or XFree86 server with the "dummy"
    driver and not have any VT switching problems! Currently Xdummy needs
    to be run as root, but with some luck that may be relaxed in the
@@ -3940,7 +3945,7 @@ startx -- /path/to/Xdummy :1
    An X server can be started on the headless machine (sometimes this
    requires configuring the X server to not fail if it cannot detect a
    keyboard or mouse, see the next paragraph). Then you can export that X
-   display via x11vnc (e.g. see [481]this FAQ) and access it from
+   display via x11vnc (e.g. see [482]this FAQ) and access it from
    anywhere on the network via a VNC viewer.
 
    Some tips on getting X servers to start on machines without keyboard
@@ -3963,7 +3968,7 @@ startx -- /path/to/Xdummy :1
    cards as it can hold to provide multiple simultaneous access or
    testing on different kinds of video hardware.
 
-   See also the [482]FINDCREATEDISPLAY discussion of the "[483]-display
+   See also the [483]FINDCREATEDISPLAY discussion of the "[484]-display
    WAIT:cmd=FINDDISPLAY" option where virtual Xvfb or Xdummy, or real X
    servers are started automatically for new users connecting.
 
@@ -3987,7 +3992,7 @@ startx -- /path/to/Xdummy :1
   19/03/2004 10:10:58 error creating tile-row shm for len=4
   19/03/2004 10:10:58 reverting to single_copytile mode
 
-   Here is a shell script [484]shm_clear to list and prompt for removal
+   Here is a shell script [485]shm_clear to list and prompt for removal
    of your unattached shm segments (attached ones are skipped). I use it
    while debugging x11vnc (I use "shm_clear -y" to assume "yes" for each
    prompt). If x11vnc is regularly not cleaning up its shm segments,
@@ -4021,40 +4026,40 @@ ied)
    in /etc/system. See the next paragraph for more workarounds.
 
    To minimize the number of shm segments used by x11vnc try using the
-   [485]-onetile option (corresponds to only 3 shm segments used, and
+   [486]-onetile option (corresponds to only 3 shm segments used, and
    adding -fs 1.0 knocks it down to 2). If you are having much trouble
    with shm segments, consider disabling shm completely via the
-   [486]-noshm option. Performance will be somewhat degraded but when
+   [487]-noshm option. Performance will be somewhat degraded but when
    done over local machine sockets it should be acceptable (see an
-   [487]earlier question discussing -noshm).
+   [488]earlier question discussing -noshm).
 
 
    Q-61: How can I make x11vnc use less system resources?
 
-   The [488]-nap (now on by default) and "[489]-wait n" (where n is the
+   The [489]-nap (now on by default) and "[490]-wait n" (where n is the
    sleep between polls in milliseconds, the default is 30 or so) option
-   are good places to start. Something like "[490]-sb 15" will cause
+   are good places to start. Something like "[491]-sb 15" will cause
    x11vnc to go into a deep-sleep mode after 15 seconds of no activity
    (instead of the default 60).
 
    Reducing the X server bits per pixel depth (e.g. to 16bpp or even
    8bpp) will further decrease memory I/O and network I/O. The ShadowFB
-   will make x11vnc's screen polling less severe. Using the [491]-onetile
+   will make x11vnc's screen polling less severe. Using the [492]-onetile
    option will use less memory and use fewer shared memory slots (add
-   [492]-fs 1.0 for one less slot).
+   [493]-fs 1.0 for one less slot).
 
 
    Q-62: How can I make x11vnc use MORE system resources?
 
-   You can try [493]-threads and dial down the wait time (e.g. -wait 1)
-   and possibly dial down [494]-defer as well. Note that if you try to
+   You can try [494]-threads and dial down the wait time (e.g. -wait 1)
+   and possibly dial down [495]-defer as well. Note that if you try to
    increase the "frame rate" too much you can bog down the server end
    with the extra work it needs to do compressing the framebuffer data,
    etc.
 
    That said, it is possible to "stream" video via x11vnc if the video
    window is small enough. E.g. a 256x192 xawtv TV capture window (using
-   the x11vnc [495]-id option) can be streamed over a LAN or wireless at
+   the x11vnc [496]-id option) can be streamed over a LAN or wireless at
    a reasonable frame rate.
 
 
@@ -4070,7 +4075,7 @@ ied)
      * Use a smaller desktop size (e.g. 1024x768 instead of 1280x1024)
      * Make sure the desktop background is a solid color (the background
        is resent every time it is re-exposed). Consider using the
-       [496]-solid [color] option to try to do this automatically.
+       [497]-solid [color] option to try to do this automatically.
      * Configure your window manager or desktop "theme" to not use fancy
        images, shading, and gradients for the window decorations, etc.
        Disable window animations, etc. Maybe your desktop has a "low
@@ -4079,9 +4084,9 @@ ied)
        -> Use Smooth Scrolling (deselect it).
      * Avoid small scrolls of large windows using the Arrow keys or
        scrollbar. Try to use PageUp/PageDown instead. (not so much of a
-       problem in x11vnc 0.7.2 if [497]-scrollcopyrect is active and
+       problem in x11vnc 0.7.2 if [498]-scrollcopyrect is active and
        detecting scrolls for the application).
-     * If the [498]-wireframe option is not available (earlier than
+     * If the [499]-wireframe option is not available (earlier than
        x11vnc 0.7.2 or you have disabled it via -nowireframe) then
        Disable Opaque Moves and Resizes in the window manager/desktop.
      * However if -wireframe is active (on by default in x11vnc 0.7.2)
@@ -4104,7 +4109,7 @@ ied)
        noticed.
 
      VNC viewer parameters:
-     * Use a [499]TightVNC enabled viewer! (Actually, RealVNC 4.x viewer
+     * Use a [500]TightVNC enabled viewer! (Actually, RealVNC 4.x viewer
        with ZRLE encoding is not too bad either; some claim it is
        faster).
      * Make sure the tight (or zrle) encoding is being used (look at
@@ -4126,37 +4131,37 @@ ied)
        file.
 
      x11vnc parameters:
-     * Make sure the [500]-wireframe option is active (it should be on by
+     * Make sure the [501]-wireframe option is active (it should be on by
        default) and you have Opaque Moves/Resizes Enabled in the window
        manager.
-     * Make sure the [501]-scrollcopyrect option is active (it should be
+     * Make sure the [502]-scrollcopyrect option is active (it should be
        on by default). This detects scrolls in many (but not all)
        applications an applies the CopyRect encoding for a big speedup.
      * Enforce a solid background when VNC viewers are connected via
-       [502]-solid
-     * Specify [503]-speeds modem to force the wireframe and
+       [503]-solid
+     * Specify [504]-speeds modem to force the wireframe and
        scrollcopyrect heuristic parameters (and any future ones) to those
        of a dialup modem connection (or supply the rd,bw,lat numerical
        values that characterize your link).
      * If wireframe and scrollcopyrect aren't working, try using the more
-       drastic [504]-nodragging (no screen updates when dragging mouse,
+       drastic [505]-nodragging (no screen updates when dragging mouse,
        but sometimes you miss visual feedback)
-     * Set [505]-fs 1.0 (disables fullscreen updates)
-     * Try increasing [506]-wait or [507]-defer (reduces the maximum
+     * Set [506]-fs 1.0 (disables fullscreen updates)
+     * Try increasing [507]-wait or [508]-defer (reduces the maximum
        "frame rate", but won't help much for large screen changes)
-     * Try the [508]-progressive pixelheight mode with the block
+     * Try the [509]-progressive pixelheight mode with the block
        pixelheight 100 or so (delays sending vertical blocks since they
        may change while viewer is receiving earlier ones)
-     * If you just want to watch one (simple) window use [509]-id (cuts
+     * If you just want to watch one (simple) window use [510]-id (cuts
        down extraneous polling and updates, but can be buggy or
        insufficient)
-     * Set [510]-nosel (disables all clipboard selection exchange)
-     * Use [511]-nocursor and [512]-nocursorpos (repainting the remote
+     * Set [511]-nosel (disables all clipboard selection exchange)
+     * Use [512]-nocursor and [513]-nocursorpos (repainting the remote
        cursor position and shape takes resources and round trips)
      * On very slow links (e.g. <= 28.8) you may need to increase the
-       [513]-readtimeout n setting if it sometimes takes more than 20sec
+       [514]-readtimeout n setting if it sometimes takes more than 20sec
        to paint the full screen, etc.
-     * Do not use [514]-fixscreen to automatically refresh the whole
+     * Do not use [515]-fixscreen to automatically refresh the whole
        screen, tap three Alt_L's then the screen has painting errors
        (rare problem).
 
@@ -4179,7 +4184,7 @@ ied)
 
    Note that the DAMAGE extension does not speed up the actual reading of
    pixels from the video card framebuffer memory, by, say, mirroring them
-   in main memory. So reading the fb is still painfully [515]slow (e.g.
+   in main memory. So reading the fb is still painfully [516]slow (e.g.
    5MB/sec), and so even using X DAMAGE when large changes occur on the
    screen the bulk of the time is still spent retrieving them. Not ideal,
    but use of the ShadowFB XFree86/Xorg option speeds up the reading
@@ -4197,20 +4202,20 @@ ied)
    DAMAGE rectangles to contain real damage. The larger rectangles are
    only used as hints to focus the traditional scanline polling (i.e. if
    a scanline doesn't intersect a recent DAMAGE rectangle, the scan is
-   skipped). You can use the "[516]-xd_area A" option to adjust the size
+   skipped). You can use the "[517]-xd_area A" option to adjust the size
    of the trusted DAMAGE rectangles. The default is 20000 pixels (e.g. a
    140x140 square, etc). Use "-xd_area 0" to disable the cutoff and trust
    all DAMAGE rectangles.
 
-   The option "[517]-xd_mem f" may also be of use in tuning the
-   algorithm. To disable using DAMAGE entirely use "[518]-noxdamage".
+   The option "[518]-xd_mem f" may also be of use in tuning the
+   algorithm. To disable using DAMAGE entirely use "[519]-noxdamage".
 
 
    Q-65: My OpenGL application shows no screen updates unless I supply
    the -noxdamage option to x11vnc.
    One user reports in his environment (MythTV using the NVIDIA OpenGL
    drivers) he gets no updates after the initial screen is drawn unless
-   he uses the "[519]-noxdamage" option.
+   he uses the "[520]-noxdamage" option.
 
    This seems to be a bug in the X DAMAGE implementation of that driver.
    You may have to use -noxdamage as well. A way to autodetect this will
@@ -4222,14 +4227,14 @@ ied)
    things really bog down (unless I do the drag in a single, quick
    motion). Is there anything to do to improve things?
 
-   This problem is primarily due to [520]slow hardware read rates from
+   This problem is primarily due to [521]slow hardware read rates from
    video cards: as you scroll or move a large window around the screen
    changes are much too rapid for x11vnc to keep up them (it can usually
    only read the video card at about 5-10 MB/sec, so it can take a good
    fraction of a second to read the changes induce from moving a large
    window, if this to be done a number of times in succession the window
    or scroll appears to "lurch" forward). See the description in the
-   [521]-pointer_mode option for more info. The next bottleneck is
+   [522]-pointer_mode option for more info. The next bottleneck is
    compressing all of these changes and sending them out to connected
    viewers, however the VNC protocol is pretty much self-adapting with
    respect to that (updates are only packaged and sent when viewers ask
@@ -4239,26 +4244,26 @@ ied)
    default should now be much better than before and dragging small
    windows around should no longer be a huge pain. If for some reason
    these changes make matters worse, you can go back to the old way via
-   the "[522]-pointer_mode 1" option.
+   the "[523]-pointer_mode 1" option.
 
-   Also added was the [523]-nodragging option that disables all screen
+   Also added was the [524]-nodragging option that disables all screen
    updates while dragging with the mouse (i.e. mouse motion with a button
    held down). This gives the snappiest response, but might be undesired
    in some circumstances when you want to see the visual feedback while
    dragging (e.g. menu traversal or text selection).
 
-   As of Dec/2004 the [524]-pointer_mode n option was introduced. n=1 is
+   As of Dec/2004 the [525]-pointer_mode n option was introduced. n=1 is
    the original mode, n=2 an improvement, etc.. See the -pointer_mode n
    help for more info.
 
-   Also, in some circumstances the [525]-threads option can improve
+   Also, in some circumstances the [526]-threads option can improve
    response considerably. Be forewarned that if more than one vncviewer
    is connected at the same time then libvncserver may not be thread safe
    (try to get the viewers to use different VNC encodings, e.g. tight and
    ZRLE).
 
-   As of Apr/2005 two new options (see the [526]wireframe FAQ and
-   [527]scrollcopyrect FAQ below) provide schemes to sweep this problem
+   As of Apr/2005 two new options (see the [527]wireframe FAQ and
+   [528]scrollcopyrect FAQ below) provide schemes to sweep this problem
    under the rug for window moves or resizes and for some (but not all)
    window scrolls. These are the preferred way of avoiding the "lurching"
    problem, contact me if they are not working. Note on SuSE and some
@@ -4282,8 +4287,8 @@ EndSection
    the window move/resize stops, it returns to normal processing: you
    should only see the window appear in the new position. This spares you
    from interacting with a "lurching" window between all of the
-   intermediate steps. BTW the lurching is due to [528]slow video card
-   read rates (see [529]here too). A displacement, even a small one, of a
+   intermediate steps. BTW the lurching is due to [529]slow video card
+   read rates (see [530]here too). A displacement, even a small one, of a
    large window requires a non-negligible amount of time, a good fraction
    of a second, to read in from the hardware framebuffer.
 
@@ -4291,7 +4296,7 @@ EndSection
    for -wireframe to do any good.
 
    The mode is currently on by default because most people are afflicted
-   with the problem. It can be disabled with the [530]-nowireframe option
+   with the problem. It can be disabled with the [531]-nowireframe option
    (aka -nowf). Why might one want to turn off the wireframing? Since
    x11vnc is merely guessing when windows are being moved/resized, it may
    guess poorly for your window-manager or desktop, or even for the way
@@ -4336,13 +4341,13 @@ EndSection
      * Maximum time to show a wireframe animation.
      * Minimum time between sending wireframe outlines.
 
-   See the [531]"-wireframe tweaks" option for more details. On a slow
+   See the [532]"-wireframe tweaks" option for more details. On a slow
    link, e.g. dialup modem, the parameters may be automatically adjusted
    for better response.
 
 
    CopyRect encoding:  In addition to the above there is the
-   [532]"-wirecopyrect mode" option. It is also on by default. This
+   [533]"-wirecopyrect mode" option. It is also on by default. This
    instructs x11vnc to not only show the wireframe animation, but to also
    instruct all connected VNC viewers to locally translate the window
    image data from the original position to the new position on the
@@ -4390,7 +4395,7 @@ EndSection
    requiring the image data to be transmitted over the network. For fast
    links the speedup is primarily due to x11vnc not having to read the
    scrolled framebuffer data from the X server (recall that reading from
-   the hardware framebuffer is [533]slow).
+   the hardware framebuffer is [534]slow).
 
    To do this x11vnc uses the RECORD X extension to snoop the X11
    protocol between the X client with the focus window and the X server.
@@ -4417,10 +4422,10 @@ EndSection
    the X server display: if one falls too far behind it could become a
    mess...
 
-   The initial implementation of [534]-scrollcopyrect option is useful in
+   The initial implementation of [535]-scrollcopyrect option is useful in
    that it detects many scrolls and thus gives a much nicer working
-   environment (especially when combined with the [535]-wireframe
-   [536]-wirecopyrect [537]options, which are also on by default; and if
+   environment (especially when combined with the [536]-wireframe
+   [537]-wirecopyrect [538]options, which are also on by default; and if
    you are willing to enable the ShadowFB things are very fast). The fact
    that there aren't long delays or lurches during scrolling is the
    primary improvement.
@@ -4453,10 +4458,10 @@ EndSection
        One can tap the Alt_L key (Left "Alt" key) 3 times in a row to
        signal x11vnc to refresh the screen to all viewers. Your
        VNC-viewer may have its own screen refresh hot-key or button. See
-       also: [538]-fixscreen
+       also: [539]-fixscreen
      * Some applications, notably OpenOffice, do XCopyArea scrolls in
        weird ways that assume ancestor window clipping is taking place.
-       See the [539]-scr_skip option for ways to tweak this on a
+       See the [540]-scr_skip option for ways to tweak this on a
        per-application basis.
      * Selecting text while dragging the mouse may be slower, especially
        if the Button-down event happens near the window's edge. This is
@@ -4473,7 +4478,7 @@ EndSection
        because it fails to detect scrolls in it. Sometimes clicking
        inside the application window or selecting some text in it to
        force the focus helps.
-     * When using the [540]-scale option there will be a quick CopyRect
+     * When using the [541]-scale option there will be a quick CopyRect
        scroll, but it needs to be followed by a slower "cleanup" update.
        This is because for a fixed finite screen resolution (e.g. 75 dpi)
        scaling and copyrect-ing are not exactly independent. Scaling
@@ -4486,7 +4491,7 @@ EndSection
 
    If you find the -scrollcopyrect behavior too approximate or
    distracting you can go back to the standard polling-only update method
-   with the [541]-noscrollcopyrect (or -noscr for short). If you find
+   with the [542]-noscrollcopyrect (or -noscr for short). If you find
    some extremely bad and repeatable behavior for -scrollcopyrect please
    report a bug.
 
@@ -4507,10 +4512,81 @@ EndSection
        errors.
 
 
+   Q-69: Can x11vnc do client-side caching of pixel data? I.e. so when
+   that pixel data is needed again it does not have to be retransmitted
+   over the network.
+
+   As of Dec/2006 in the [543]0.8.4 development tarball there is an
+   experimental client-side caching implementation enabled by the
+   "[544]-ncache n" option.
+
+   It is a simple scheme where the lower portion of the framebuffer (i.e.
+   below the user's actual display) is used for storing pixel data.
+   CopyRect; a fast, local, viewer-side VNC encoding; is used to move the
+   pixel data in and out of the actual display area. It gives a good
+   speedup for iconifying/deiconifying and moving windows and re-posting
+   of menus.
+
+   This scheme is nice because it does all of this within the existing
+   VNC protocol, and so it works with all VNC viewers.
+
+   A challenge to doing more sophisticated (e.g. compressed) client-side
+   caching is that one needs to extend the VNC protocol and then also get
+   users to adopt your VNC Viewer or modify existing viewers and get them
+   to be used instead...
+
+   A drawback of the "-ncache n" method is that in the VNC Viewer you can
+   scroll down and actually see the cached pixel data. One will need to
+   try to adjust the size of the VNC Viewer window so the cache area
+   cannot be seen.
+
+   At some point Libvncserver may implement a "rfbFBCrop" pseudoencoding
+   that viewers can use to learn which portion of the framebuffer to
+   actually show to the users (with the hidden part used for caching, or
+   perhaps something else).
+
+   Another drawback of the scheme is that it is very memory intensive,
+   the n in "-ncache n" is the factor of increase over the base
+   framebuffer size to use for caching. It is an even integer and should
+   be fairly large, 6-10, to acheive good response. This usually requires
+   about 50MB of additional RAM on both the client and server sides. So
+   with n=6 a 1280x1024 display will use a framebuffer that is 1280x7168:
+   everything below row 1024 is the buffer cache.
+
+   The reason for so much memory is because the pixel data is not
+   compressed and so the whole window to be saved must be stored
+   "offscreen". E.g. for a large web browser window this can be 1 million
+   pixels, and that is just for a single window. One typically wants to
+   cycle between 5-10 large active windows. Also because both
+   backing-store and save-unders are used for window caching that
+   introduces a factor of 2 in memory use. The large memory consumption
+   of the current implementation can be thought of as a tradeoff of
+   providing caching and being compatible with all VNC viewers and also
+   ease of implementing. Hopefully it can be tuned to use less.
+
+
+   Gotcha for older Unix VNC Viewers: The older Unix VNC viewers (e.g.
+   current TightVNC Unix Viewer) require X server backingstore to keep
+   off-viewer screen data local. If the viewer-side X server has
+   backingstore disabled (sadly, currently the default on Linux, etc),
+   then to get the offscreen pixels the viewer has to ask for a refresh
+   over the network, thereby defeating the caching. Use something like
+   this in your viewer-side /etc/X11/xorg.conf file (or otherwise get
+   your viewer-side system to do it)
+Section "Device"
+        ...
+        Option  "backingstore"
+        ...
+EndSection
+
+   No problems like this have been observed with Windows VNC Viewers:
+   they all seem to keep their entire framebuffer in local memory.
+
+
 
    [Mouse Cursor Shapes]
 
-   Q-69: Why isn't the mouse cursor shape (the little icon shape where
+   Q-70: Why isn't the mouse cursor shape (the little icon shape where
    the mouse pointer is) correct as I move from window to window?
 
    On X servers supporting XFIXES or Solaris/IRIX Overlay extensions it
@@ -4525,23 +4601,23 @@ EndSection
    this is because the cursor shape is often downloaded to the graphics
    hardware (video card), but I could be mistaken.
 
-   A simple kludge is provided by the "[542]-cursor X" option that
+   A simple kludge is provided by the "[545]-cursor X" option that
    changes the cursor when the mouse is on the root background (or any
    window has the same cursor as the root background). Note that desktops
    like GNOME or KDE often cover up the root background, so this won't
-   work for those cases. Also see the "[543]-cursor some" option for
+   work for those cases. Also see the "[546]-cursor some" option for
    additional kludges.
 
    Note that as of Aug/2004 on Solaris using the SUN_OVL overlay
    extension and IRIX, x11vnc can show the correct mouse cursor when the
-   [544]-overlay option is supplied. See [545]this FAQ for more info.
+   [547]-overlay option is supplied. See [548]this FAQ for more info.
 
    Also as of Dec/2004 XFIXES X extension support has been added to allow
    exact extraction of the mouse cursor shape. XFIXES fixes the problem
    of the cursor-shape being write-only: x11vnc can now query the X
    server for the current shape and send it back to the connected
    viewers. XFIXES is available on recent Linux Xorg based distros and
-   [546]Solaris 10.
+   [549]Solaris 10.
 
    The only XFIXES issue is the handling of alpha channel transparency in
    cursors. If a cursor has any translucency then in general it must be
@@ -4549,10 +4625,10 @@ EndSection
    situations where the cursor transparency can also handled exactly:
    when the VNC Viewer requires the cursor shape be drawn into the VNC
    framebuffer or if you apply a patch to your VNC Viewer to extract
-   hidden alpha channel data under 32bpp. [547]Details can be found here.
+   hidden alpha channel data under 32bpp. [550]Details can be found here.
 
 
-   Q-70: When using XFIXES cursorshape mode, some of the cursors look
+   Q-71: When using XFIXES cursorshape mode, some of the cursors look
    really bad with extra black borders around the cursor and other cruft.
    How can I improve their appearance?
 
@@ -4582,17 +4658,17 @@ EndSection
    for most cursor themes and you don't have to worry about it.
 
    In case it still looks bad for your cursor theme, there are (of
-   course!) some tunable parameters. The "[548]-alphacut n" option lets
+   course!) some tunable parameters. The "[551]-alphacut n" option lets
    you set the threshold "n" (between 0 and 255): cursor pixels with
    alpha values below n will be considered completely transparent while
    values equal to or above n will be completely opaque. The default is
-   240. The "[549]-alphafrac f" option tries to correct individual
+   240. The "[552]-alphafrac f" option tries to correct individual
    cursors that did not fare well with the default -alphacut value: if a
    cursor has less than fraction f (between 0.0 and 1.0) of its pixels
    selected by the default -alphacut, the threshold is lowered until f of
    its pixels are selected. The default fraction is 0.33.
 
-   Finally, there is an option [550]-alpharemove that is useful for
+   Finally, there is an option [553]-alpharemove that is useful for
    themes where many cursors are light colored (e.g. "whiteglass").
    XFIXES returns the cursor data with the RGB values pre-multiplied by
    the alpha value. If the white cursors look too grey, specify
@@ -4610,7 +4686,7 @@ EndSection
    heavily on redglass) look fine with the apparent default of alphacut:255.
 
 
-   Q-71: In XFIXES mode, are there any hacks to handle cursor
+   Q-72: In XFIXES mode, are there any hacks to handle cursor
    transparency ("alpha channel") exactly?
 
    As of Jan/2005 libvncserver has been modified to allow an alpha
@@ -4618,10 +4694,10 @@ EndSection
    alpha channel data to libvncserver. However, this data will only be
    used for VNC clients that do not support the CursorShapeUpdates VNC
    extension (or have disabled it). It can be disabled for all clients
-   with the [551]-nocursorshape x11vnc option. In this case the cursor is
+   with the [554]-nocursorshape x11vnc option. In this case the cursor is
    drawn, correctly blended with the background, into the VNC framebuffer
    before being sent out to the client. So the alpha blending is done on
-   the x11vnc side. Use the [552]-noalphablend option to disable this
+   the x11vnc side. Use the [555]-noalphablend option to disable this
    behavior (always approximate transparent cursors with opaque RGB
    values).
 
@@ -4645,17 +4721,17 @@ EndSection
    example on how to change the Windows TightVNC viewer to achieve the
    same thing (send me the patch if you get that working).
 
-   This patch is applied to the [553]Enhanced TightVNC Viewer (ssvnc)
+   This patch is applied to the [556]Enhanced TightVNC Viewer (ssvnc)
    package we provide.
 
    [Mouse Pointer]
 
-   Q-72: Why does the mouse arrow just stay in one corner in my
+   Q-73: Why does the mouse arrow just stay in one corner in my
    vncviewer, whereas my cursor (that does move) is just a dot?
 
-   This default takes advantage of a [554]tightvnc extension
+   This default takes advantage of a [557]tightvnc extension
    (CursorShapeUpdates) that allows specifying a cursor image shape for
-   the local VNC viewer. You may disable it with the [555]-nocursor
+   the local VNC viewer. You may disable it with the [558]-nocursor
    option to x11vnc if your viewer does not have this extension.
 
    Note: as of Aug/2004 this should be fixed: the default for
@@ -4664,22 +4740,22 @@ EndSection
    can also be disabled via -nocursor.
 
 
-   Q-73: Can I take advantage of the TightVNC extension to the VNC
+   Q-74: Can I take advantage of the TightVNC extension to the VNC
    protocol where Cursor Positions Updates are sent back to all connected
    clients (i.e. passive viewers can see the mouse cursor being moved
    around by another viewer)?
 
-   Use the [556]-cursorpos option when starting x11vnc. A VNC viewer must
+   Use the [559]-cursorpos option when starting x11vnc. A VNC viewer must
    support the Cursor Positions Updates for the user to see the mouse
    motions (the TightVNC viewers support this). As of Aug/2004 -cursorpos
-   is the default. See also [557]-nocursorpos and [558]-nocursorshape.
+   is the default. See also [560]-nocursorpos and [561]-nocursorshape.
 
 
-   Q-74: Is it possible to swap the mouse buttons (e.g. left-handed
+   Q-75: Is it possible to swap the mouse buttons (e.g. left-handed
    operation), or arbitrarily remap them? How about mapping button clicks
    to keystrokes, e.g. to partially emulate Mouse wheel scrolling?
 
-   You can remap the mouse buttons via something like: [559]-buttonmap
+   You can remap the mouse buttons via something like: [562]-buttonmap
    13-31 (or perhaps 12-21). Also, note that xmodmap(1) lets you directly
    adjust the X server's button mappings, but in some circumstances it
    might be more desirable to have x11vnc do it.
@@ -4687,7 +4763,7 @@ EndSection
    One user had an X server with only one mouse button(!) and was able to
    map all of the VNC client mouse buttons to it via: -buttonmap 123-111.
 
-   Note that the [560]-debug_pointer option prints out much info for
+   Note that the [563]-debug_pointer option prints out much info for
    every mouse/pointer event and is handy in solving problems.
 
    To map mouse button clicks to keystrokes you can use the alternate
@@ -4709,7 +4785,7 @@ EndSection
 
    Exactly what keystroke "scrolling" events they should be bound to
    depends on one's taste. If this method is too approximate, one could
-   consider not using [561]-buttonmap but rather configuring the X server
+   consider not using [564]-buttonmap but rather configuring the X server
    to think it has a mouse with 5 buttons even though the physical mouse
    does not. (e.g. 'Option "ZAxisMapping" "4 5"').
 
@@ -4736,10 +4812,10 @@ EndSection
    "click" usually gives a multi-line scroll).
    [Keyboard Issues]
 
-   Q-75: How can I get my AltGr and Shift modifiers to work between
+   Q-76: How can I get my AltGr and Shift modifiers to work between
    keyboards for different languages?
 
-   The option [562]-modtweak should help here. It is a mode that monitors
+   The option [565]-modtweak should help here. It is a mode that monitors
    the state of the Shift and AltGr Modifiers and tries to deduce the
    correct keycode to send, possibly by sending fake modifier key presses
    and releases in addition to the actual keystroke.
@@ -4748,20 +4824,20 @@ EndSection
    to get the old behavior). This was done because it was noticed on
    newer XFree86 setups even on bland "us" keyboards like "pc104 us"
    XFree86 included a "ghost" key with both "<" and ">" it. This key does
-   not exist on the keyboard (see [563]this FAQ for more info). Without
+   not exist on the keyboard (see [566]this FAQ for more info). Without
    -modtweak there was then an ambiguity in the reverse map keysym =>
    keycode, making it so the "<" symbol could not be typed.
 
-   Also see the [564]FAQ about the -xkb option for a more powerful method
+   Also see the [567]FAQ about the -xkb option for a more powerful method
    of modifier tweaking for use on X servers with the XKEYBOARD
    extension.
 
    When trying to resolve keyboard mapping problems, note that the
-   [565]-debug_keyboard option prints out much info for every keystroke
+   [568]-debug_keyboard option prints out much info for every keystroke
    and so can be useful debugging things.
 
 
-   Q-76: When I try to type a "<" (i.e. less than) instead I get ">"
+   Q-77: When I try to type a "<" (i.e. less than) instead I get ">"
    (i.e. greater than)! Strangely, typing ">" works OK!!
 
    Does your keyboard have a single key with both "<" and ">" on it? Even
@@ -4769,9 +4845,9 @@ EndSection
    (e.g. pc105 in the XF86Config file when it should be something else,
    say pc104).
 
-   Short Cut: Try the [566]-xkb or [567]-sloppy_keys options and see if
+   Short Cut: Try the [569]-xkb or [570]-sloppy_keys options and see if
    that helps the situation. The discussion below is a bit outdated (e.g.
-   [568]-modtweak is now the default) but it is useful reference for
+   [571]-modtweak is now the default) but it is useful reference for
    various tricks and so is kept.
 
 
@@ -4814,34 +4890,34 @@ EndSection
    -remap less-comma
 
    These are convenient in that they do not modify the actual X server
-   settings. The former ([569]-modtweak) is a mode that monitors the
+   settings. The former ([572]-modtweak) is a mode that monitors the
    state of the Shift and AltGr modifiers and tries to deduce the correct
    keycode sequence to send. Since Jul/2004 -modtweak is now the default.
-   The latter ([570]-remap less-comma) is an immediate remapping of the
+   The latter ([573]-remap less-comma) is an immediate remapping of the
    keysym less to the keysym comma when it comes in from a client (so
    when Shift is down the comma press will yield "<").
 
-   See also the [571]FAQ about the -xkb option as a possible workaround
+   See also the [574]FAQ about the -xkb option as a possible workaround
    using the XKEYBOARD extension.
 
-   Note that the [572]-debug_keyboard option prints out much info for
+   Note that the [575]-debug_keyboard option prints out much info for
    every keystroke to aid debugging keyboard problems.
 
 
-   Q-77: When I try to type a "<" (i.e. less than) instead I get "<,"
+   Q-78: When I try to type a "<" (i.e. less than) instead I get "<,"
    (i.e. an extra comma).
 
    This is likely because you press "Shift" then "<" but then released
-   the Shift key before releasing the "<". Because of a [573]keymapping
+   the Shift key before releasing the "<". Because of a [576]keymapping
    ambiguity the last event "< up" is interpreted as "," because that key
    unshifted is the comma.
 
-   This should not happen in [574]-xkb mode, because it works hard to
+   This should not happen in [577]-xkb mode, because it works hard to
    resolve the ambiguities. If you do not want to use -xkb, try the
-   option [575]-sloppy_keys to attempt a similar type of algorithm.
+   option [578]-sloppy_keys to attempt a similar type of algorithm.
 
 
-   Q-78: I'm using an "international" keyboard (e.g. German "de", or
+   Q-79: I'm using an "international" keyboard (e.g. German "de", or
    Danish "dk") and the -modtweak mode works well if the VNC viewer is
    run on a Unix/Linux machine with a similar keyboard.   But if I run
    the VNC viewer on Unix/Linux with a different keyboard (e.g. "us") or
@@ -4862,7 +4938,7 @@ EndSection
    In both cases no AltGr is sent to the VNC server, but we know AltGr is
    needed on the physical international keyboard to type a "@".
 
-   This all worked fine with x11vnc running with the [576]-modtweak
+   This all worked fine with x11vnc running with the [579]-modtweak
    option (it figures out how to adjust the Modifier keys (Shift or
    AltGr) to get the "@"). However it fails under recent versions of
    XFree86 (and the X.org fork). These run the XKEYBOARD extension by
@@ -4879,7 +4955,7 @@ EndSection
      * there is a new option -xkb to use the XKEYBOARD extension API to
        do the Modifier key tweaking.
 
-   The [577]-xkb option seems to fix all of the missing keys: "@", "<",
+   The [580]-xkb option seems to fix all of the missing keys: "@", "<",
    ">", etc.: it is recommended that you try it if you have this sort of
    problem. Let us know if there are any remaining problems (see the next
    paragraph for some known problems). If you specify the -debug_keyboard
@@ -4887,7 +4963,7 @@ EndSection
    debugging output (send it along with any problems you report).
 
    Update: as of Jun/2005 x11vnc will try to automatically enable
-   [578]-xkb if it appears that would be beneficial (e.g. if it sees any
+   [581]-xkb if it appears that would be beneficial (e.g. if it sees any
    of "@", "<", ">", "[" and similar keys are mapped in a way that needs
    the -xkb to access them). To disable this automatic check use -noxkb.
 
@@ -4902,7 +4978,7 @@ EndSection
        was attached to keycode 93 (no physical key generates this
        keycode) while ISO_Level3_Shift was attached to keycode 113. The
        keycode skipping option was used to disable the ghost key:
-       [579]-skip_keycodes 93
+       [582]-skip_keycodes 93
      * In implementing -xkb we noticed that some characters were still
        not getting through, e.g. "~" and "^". This is not really an
        XKEYBOARD problem. What was happening was the VNC viewer was
@@ -4920,16 +4996,16 @@ EndSection
        What to do? In general the VNC protocol has not really solved this
        problem: what should be done if the VNC viewer sends a keysym not
        recognized by the VNC server side? Workarounds can possibly be
-       created using the [580]-remap x11vnc option:
+       created using the [583]-remap x11vnc option:
   -remap asciitilde-dead_tilde,asciicircum-dead_circumflex
        etc. Use -remap filename if the list is long. Please send us your
        workarounds for this problem on your keyboard. Perhaps we can have
        x11vnc adjust automatically at some point. Also see the
-       [581]-add_keysyms option in the next paragraph.
-       Update: for convenience "[582]-remap DEAD" does many of these
+       [584]-add_keysyms option in the next paragraph.
+       Update: for convenience "[585]-remap DEAD" does many of these
        mappings at once.
-     * To complement the above workaround using the [583]-remap, an
-       option [584]-add_keysyms was added. This option instructs x11vnc
+     * To complement the above workaround using the [586]-remap, an
+       option [587]-add_keysyms was added. This option instructs x11vnc
        to bind any unknown Keysyms coming in from VNC viewers to unused
        Keycodes in the X server. This modifies the global state of the X
        server. When x11vnc exits it removes the extra keymappings it
@@ -4940,7 +5016,7 @@ EndSection
        disable.
 
 
-   Q-79: When typing I sometimes get double, triple, or more of my
+   Q-80: When typing I sometimes get double, triple, or more of my
    keystrokes repeated. I'm sure I only typed them once, what can I do?
 
    This may be due to an interplay between your X server's key autorepeat
@@ -4948,7 +5024,7 @@ EndSection
 
    Short answer: disable key autorepeating by running the command "xset r
    off" on the Xserver where x11vnc is run (restore via "xset r on") or
-   use the new (Jul/2004) [585]-norepeat x11vnc option. You will still
+   use the new (Jul/2004) [588]-norepeat x11vnc option. You will still
    have autorepeating because that is taken care of on your VNC viewer
    side.
 
@@ -4972,18 +5048,18 @@ EndSection
    off", does the problem go away?
 
    The workaround is to manually apply "xset r off" and "xset r on" as
-   needed, or to use the [586]-norepeat (which has since Dec/2004 been
+   needed, or to use the [589]-norepeat (which has since Dec/2004 been
    made the default). Note that with X server autorepeat turned off the
    VNC viewer side of the connection will (nearly always) do its own
    autorepeating so there is no big loss here, unless someone is also
    working at the physical display and misses his autorepeating.
 
 
-   Q-80: The x11vnc -norepeat mode is in effect, but I still get repeated
+   Q-81: The x11vnc -norepeat mode is in effect, but I still get repeated
    keystrokes!!
 
    Are you using x11vnc to log in to an X session via display manager?
-   (as described in [587]this FAQ) If so, x11vnc is starting before your
+   (as described in [590]this FAQ) If so, x11vnc is starting before your
    session and it disables autorepeat when you connect, but then after
    you log in your session startup (GNOME, KDE, ...) could be resetting
    the autorepeat to be on. Or it could be something inside your desktop
@@ -5003,11 +5079,11 @@ EndSection
    should figure out how to disable that somehow.
 
 
-   Q-81: The machine where I run x11vnc has an AltGr key, but the local
+   Q-82: The machine where I run x11vnc has an AltGr key, but the local
    machine where I run the VNC viewer does not. Is there a way I can map
    a local unused key to send an AltGr? How about a Compose key as well?
 
-   Something like "[588]-remap Super_R-Mode_switch" x11vnc option may
+   Something like "[591]-remap Super_R-Mode_switch" x11vnc option may
    work. Note that Super_R is the "Right Windoze(tm) Flaggie" key; you
    may want to choose another. The -debug_keyboard option comes in handy
    in finding keysym names (so does xev(1)).
@@ -5018,7 +5094,7 @@ EndSection
    specify remappings from a file.
 
 
-   Q-82: I have a Sun machine I run x11vnc on. Its Sun keyboard has just
+   Q-83: I have a Sun machine I run x11vnc on. Its Sun keyboard has just
    one Alt key labelled "Alt" and two Meta keys labelled with little
    diamonds. The machine where I run the VNC viewer only has Alt keys.
    How can I send a Meta keypress? (e.g. emacs needs this)
@@ -5030,18 +5106,18 @@ EndSection
 
    Since xmodmap(1) modifies the X server mappings you may not want to do
    this (because it affects local work on that machine). Something like
-   the [589]-remap Alt_L-Meta_L to x11vnc may be sufficient for ones
+   the [592]-remap Alt_L-Meta_L to x11vnc may be sufficient for ones
    needs, and does not modify the X server environment. Note that you
    cannot send Alt_L in this case, maybe -remap Super_L-Meta_L would be a
    better choice if the Super_L key is typically unused in Unix.
 
 
-   Q-83: Can I map a keystroke to a mouse button click on the remote
+   Q-84: Can I map a keystroke to a mouse button click on the remote
    machine?
 
    This can be done directly in some X servers using AccessX and
    Pointer_EnableKeys, but is a bit awkward. It may be more convenient to
-   have x11vnc do the remapping. This can be done via the [590]-remap
+   have x11vnc do the remapping. This can be done via the [593]-remap
    option using the fake "keysyms" Button1, Button2, etc. as the "to"
    keys (i.e. the ones after the "-")
 
@@ -5050,7 +5126,7 @@ EndSection
    button "paste" because (using XFree86/Xorg Emulate3Buttons) you have
    to click both buttons on the touch pad at the same time. This
    remapping:
-  [591]-remap Super_R-Button2
+  [594]-remap Super_R-Button2
 
    maps the Super_R "flag" key press to the Button2 click, thereby making
    X pasting a bit easier.
@@ -5059,7 +5135,7 @@ EndSection
    are generated immediately on the x11vnc side. When the key is released
    (i.e. goes up) no events are generated.
 
-   Q-84: How can I get Caps_Lock to work between my VNC viewer and
+   Q-85: How can I get Caps_Lock to work between my VNC viewer and
    x11vnc?
 
    This is a little tricky because it is possible to get the Caps_Lock
@@ -5069,14 +5145,14 @@ EndSection
    Caps_Lock in the viewer your local machine goes into the Caps_Lock on
    state and sends keysym "A" say when you press "a". x11vnc will then
    fake things up so that Shift is held down to generate "A". The
-   [592]-skip_lockkeys option should help to accomplish this. For finer
-   grain control use something like: "[593]-remap Caps_Lock-None".
+   [595]-skip_lockkeys option should help to accomplish this. For finer
+   grain control use something like: "[596]-remap Caps_Lock-None".
 
-   Also try the [594]-nomodtweak and [595]-capslock options.
+   Also try the [597]-nomodtweak and [598]-capslock options.
 
    [Screen Related Issues and Features]
 
-   Q-85: The remote display is larger (in number of pixels) than the
+   Q-86: The remote display is larger (in number of pixels) than the
    local display I am running the vncviewer on. I don't like the
    vncviewer scrollbars, what I can do?
 
@@ -5095,15 +5171,15 @@ EndSection
    There may also be scaling viewers out there (e.g. TightVNC or UltraVNC
    on Windows) that automatically shrink or expand the remote framebuffer
    to fit the local display. Especially for hand-held devices. See also
-   [596]this FAQ on x11vnc scaling.
+   [599]this FAQ on x11vnc scaling.
 
 
-   Q-86: Does x11vnc support server-side framebuffer scaling? (E.g. to
+   Q-87: Does x11vnc support server-side framebuffer scaling? (E.g. to
    make the desktop smaller).
 
    As of Jun/2004 x11vnc provides basic server-side scaling. It is a
    global scaling of the desktop, not a per-client setting. To enable it
-   use the "[597]-scale fraction" option. "fraction" can either be a
+   use the "[600]-scale fraction" option. "fraction" can either be a
    floating point number (e.g. -scale 0.5) or the alternative m/n
    fraction notation (e.g. -scale 3/4). Note that if fraction is greater
    than one the display is magnified.
@@ -5124,7 +5200,7 @@ EndSection
 
    One can also use the ":nb" with an integer scale factor (say "-scale
    2:nb") to use x11vnc as a screen magnifier for vision impaired
-   [598]applications. Since with integer scale factors the framebuffers
+   [601]applications. Since with integer scale factors the framebuffers
    become huge and scaling operations time consuming, be sure to use
    ":nb" for the fastest response.
 
@@ -5150,7 +5226,7 @@ EndSection
    If one desires per-client scaling for something like 1:1 from a
    workstation and 1:2 from a smaller device (e.g. handheld), currently
    the only option is to run two (or more) x11vnc processes with
-   different scalings listening on separate ports ([599]-rfbport option,
+   different scalings listening on separate ports ([602]-rfbport option,
    etc.).
 
    Update: As of May/2006 x11vnc also supports the UltraVNC server-side
@@ -5160,8 +5236,8 @@ EndSection
    "-rfbversion 3.6" for this to be recognized by UltraVNC viewers.
 
    BTW, whenever you run two or more x11vnc's on the same X display and
-   use the [600]GUI, then to avoid all of the x11vnc's simultaneously
-   answering the gui you will need to use something like [601]"-connect
+   use the [603]GUI, then to avoid all of the x11vnc's simultaneously
+   answering the gui you will need to use something like [604]"-connect
    file1 -gui ..." with different connect files for each x11vnc you want
    to control via the gui (or remote-control). The "-connect file1" usage
    gives separate communication channels between a x11vnc proces and the
@@ -5170,12 +5246,12 @@ EndSection
 
    Update: As of Mar/2005 x11vnc now scales the mouse cursor with the
    same scale factor as the screen. If you don't want that, use the
-   [602]"-scale_cursor frac" option to set the cursor scaling to a
+   [605]"-scale_cursor frac" option to set the cursor scaling to a
    different factor (e.g. use "-scale_cursor 1" to keep the cursor at its
    natural unscaled size).
 
 
-   Q-87: Does x11vnc work with Xinerama? (i.e. multiple monitors joined
+   Q-88: Does x11vnc work with Xinerama? (i.e. multiple monitors joined
    together to form one big, single screen).
 
    Yes, it should generally work because it simply polls the big
@@ -5192,24 +5268,24 @@ EndSection
    screen is not rectangular (e.g. 1280x1024 and 1024x768 monitors joined
    together), then there will be "non-existent" areas on the screen. The
    X server will return "garbage" image data for these areas and so they
-   may be distracting to the viewer. The [603]-blackout x11vnc option
+   may be distracting to the viewer. The [606]-blackout x11vnc option
    allows you to blacken-out rectangles by manually specifying their
    WxH+X+Y geometries. If your system has the libXinerama library, the
-   [604]-xinerama x11vnc option can be used to have it automatically
+   [607]-xinerama x11vnc option can be used to have it automatically
    determine the rectangles to be blackened out. (Note on 8bpp
    PseudoColor displays the fill color may not be black). Update:
-   [605]-xinerama is now on by default.
+   [608]-xinerama is now on by default.
 
    Some users have reported that the mouse does not behave properly for
    their Xinerama display: i.e. the mouse cannot be moved to all regions
-   of the large display. If this happens try using the [606]-xwarppointer
+   of the large display. If this happens try using the [609]-xwarppointer
    option. This instructs x11vnc to fake mouse pointer motions using the
    XWarpPointer function instead of the XTestFakeMotionEvent XTEST
    function. (This may be due to a bug in the X server for XTEST when
    Xinerama is enabled).
 
 
-   Q-88: Can I use x11vnc on a multi-headed display that is not Xinerama
+   Q-89: Can I use x11vnc on a multi-headed display that is not Xinerama
    (i.e. separate screens :0.0, :0.1, ... for each monitor)?
 
    You can, but it is a little bit awkward: you must start separate
@@ -5227,32 +5303,32 @@ EndSection
    Note: if you are running on Solaris 8 or earlier you can easily hit up
    against the maximum of 6 shm segments per process (for Xsun in this
    case) from running multiple x11vnc processes. You should modify
-   /etc/system as mentioned in another [607]FAQ to increase the limit. It
-   is probably also a good idea to run with the [608]-onetile option in
+   /etc/system as mentioned in another [610]FAQ to increase the limit. It
+   is probably also a good idea to run with the [611]-onetile option in
    this case (to limit each x11vnc to 3 shm segments), or even
-   [609]-noshm to use no shm segments.
+   [612]-noshm to use no shm segments.
 
 
-   Q-89: Can x11vnc show only a portion of the display? (E.g. for a
+   Q-90: Can x11vnc show only a portion of the display? (E.g. for a
    special purpose rfb application).
 
-   As of Mar/2005 x11vnc has the "[610]-clip WxH+X+Y" option to select a
+   As of Mar/2005 x11vnc has the "[613]-clip WxH+X+Y" option to select a
    rectangle of width W, height H and offset (X, Y). Thus the VNC screen
    will be the clipped sub-region of the display and be only WxH in size.
-   One user used -clip to split up a large [611]Xinerama screen into two
+   One user used -clip to split up a large [614]Xinerama screen into two
    more managable smaller screens.
 
    This also works to view a sub-region of a single application window if
-   the [612]-id or [613]-sid options are used. The offset is measured
+   the [615]-id or [616]-sid options are used. The offset is measured
    from the upper left corner of the selected window.
 
 
-   Q-90: Does x11vnc support the XRANDR (X Resize, Rotate and Reflection)
+   Q-91: Does x11vnc support the XRANDR (X Resize, Rotate and Reflection)
    extension? Whenever I rotate or resize the screen x11vnc just seems to
    crash.
 
    As of Dec/2004 x11vnc supports XRANDR. You enable it with the
-   [614]-xrandr option to make x11vnc monitor XRANDR events and also trap
+   [617]-xrandr option to make x11vnc monitor XRANDR events and also trap
    X server errors if the screen change occurred in the middle of an X
    call like XGetImage. Once it traps the screen change it will create a
    new framebuffer using the new screen.
@@ -5262,9 +5338,9 @@ EndSection
    then the viewer will automatically resize. Otherwise, the new
    framebuffer is fit as best as possible into the original viewer size
    (portions of the screen may be clipped, unused, etc). For these
-   viewers you can try the [615]-padgeom option to make the region big
+   viewers you can try the [618]-padgeom option to make the region big
    enough to hold all resizes and rotations. We have fixed this problem
-   for the TightVNC Viewer on Unix: [616]enhanced_tightvnc_viewer
+   for the TightVNC Viewer on Unix: [619]enhanced_tightvnc_viewer
 
    If you specify "-xrandr newfbsize" then vnc viewers that do not
    support NewFBSize will be disconnected before the resize. If you
@@ -5272,21 +5348,21 @@ EndSection
    terminate.
 
 
-   Q-91: Independent of any XRANDR, can I have x11vnc rotate and/or
+   Q-92: Independent of any XRANDR, can I have x11vnc rotate and/or
    reflect the screen that the VNC viewers see? (e.g. for a handheld
    whose screen is rotated 90 degrees).
 
-   As of Jul/2006 there is the [617]-rotate option allow this. E.g's:
+   As of Jul/2006 there is the [620]-rotate option allow this. E.g's:
    "-rotate +90", "-rotate -90", "-rotate x", etc.
 
 
-   Q-92: Why is the view in my VNC viewer completely black? Or why is
+   Q-93: Why is the view in my VNC viewer completely black? Or why is
    everything flashing around randomly?
 
    See the next FAQ for a possible explanation.
 
 
-   Q-93: I use Linux Virtual Consoles (VC's) to implement 'Fast User
+   Q-94: I use Linux Virtual Consoles (VC's) to implement 'Fast User
    Switching' between users' sessions (e.g. Betty is on Ctrl-Alt-F7,
    Bobby is on Ctrl-Alt-F8, and Sid is on Ctrl-Alt-F1: they use those
    keystrokes to switch between their sessions).   How come the view in a
@@ -5315,7 +5391,7 @@ EndSection
    "chvt 7" for VC #7.
 
 
-   Q-94: I am using x11vnc where my local machine has "popup/hidden
+   Q-95: I am using x11vnc where my local machine has "popup/hidden
    taskbars" and the remote display where x11vnc runs also has
    "popup/hidden taskbars" and they interfere and fight with eachother.
    What can I do?
@@ -5330,7 +5406,7 @@ EndSection
    click on the task bar panel, and uncheck "enable auto-hide" from the
    panel properties dialog box. This will make the panel always visible.
 
-   Q-95: Help! x11vnc and my KDE screensaver keep switching each other on
+   Q-96: Help! x11vnc and my KDE screensaver keep switching each other on
    and off every few seconds.
 
    This is a new (Jul/2006) problem seen, say, on the version of KDE that
@@ -5341,13 +5417,13 @@ EndSection
 
    This may be a bug in kdesktop_lock. For now the only workaround is to
    disable the screensaver. You can try using another one such as
-   straight xscreensaver (see the instructions [618]here for how to
+   straight xscreensaver (see the instructions [621]here for how to
    disable kdesktop_lock). If you have more info on this or see it
    outside of KDE please let us know.
 
    Update: It appears this is due to kdesktop_lock enabling the screen
    saver when the Monitor is in DPMS low-power state (e.g. standby,
-   suspend, or off). In Nov/2006 the x11vnc [619]-nodpms option was added
+   suspend, or off). In Nov/2006 the x11vnc [622]-nodpms option was added
    as a workaround. Normally it is a good thing that the monitor powers
    down (since x11vnc can still poll the framebuffer in this state), but
    if you experience the kdesktop_lock problem you can specify the
@@ -5356,7 +5432,7 @@ EndSection
    force on" periodically. (if you don't want to do these things just
    disable the screensaver).
 
-   Q-96: Can I use x11vnc to view my VMWare session remotely?
+   Q-97: Can I use x11vnc to view my VMWare session remotely?
 
    Yes, since VMWare usually runs as an X application you can view it via
    x11vnc in the normal way.
@@ -5367,9 +5443,9 @@ EndSection
      * Fullscreen mode
 
    The way VMWare does Fullscreen mode on Linux is to display the Guest
-   desktop in a separate Virtual Console (e.g. VC 8) (see [620]this FAQ
+   desktop in a separate Virtual Console (e.g. VC 8) (see [623]this FAQ
    on VC's for background). Unfortunately, this Fullscreen VC is not an X
-   server. So x11vnc cannot access it (however, [621]see this discussion
+   server. So x11vnc cannot access it (however, [624]see this discussion
    of -rawfb for a possible workaround). x11vnc works fine with "Normal X
    application window" and "Quick-Switch mode" because these use X.
 
@@ -5390,13 +5466,13 @@ EndSection
    improve response. One can also cut the display depth (e.g. to 16bpp)
    in this 2nd X session to improve video performance. This 2nd X session
    emulates Fullscreen mode to some degree and can be viewed via x11vnc
-   as long as the VMWare X session [622]is in the active VC.
+   as long as the VMWare X session [625]is in the active VC.
 
    Also note that with a little bit of playing with "xwininfo -all
    -children" output one can extract the (non-toplevel) windowid of the
    of the Guest desktop only when VMWare is running as a normal X
    application. Then one can export just the guest desktop (i.e. without
-   the VMWare menu buttons) by use of the [623]-id windowid option. The
+   the VMWare menu buttons) by use of the [626]-id windowid option. The
    caveats are the X session VMWare is in must be in the active VC and
    the window must be fully visible, so this mode is not terribly
    convenient, but could be useful in some circumstances (e.g. running
@@ -5408,14 +5484,14 @@ EndSection
 
    [Exporting non-X11 devices via VNC]
 
-   Q-97: Can non-X devices (e.g. a raw framebuffer) be viewed (and even
+   Q-98: Can non-X devices (e.g. a raw framebuffer) be viewed (and even
    controlled) via VNC with x11vnc?
 
    As of Apr/2005 there is support for this. Two options were added:
-   "[624]-rawfb string" (to indicate the raw framembuffer device, file,
-   etc. and its parameters) and "[625]-pipeinput command" (to provide an
+   "[627]-rawfb string" (to indicate the raw framembuffer device, file,
+   etc. and its parameters) and "[628]-pipeinput command" (to provide an
    external program that will inject or otherwise process mouse and
-   keystroke input). Some useful [626]-pipeinput schemes, VID, CONSOLE,
+   keystroke input). Some useful [629]-pipeinput schemes, VID, CONSOLE,
    and UINPUT, have since been built into x11vnc for convenience.
 
    This non-X mode for x11vnc is somewhat experimental because it is so
@@ -5453,9 +5529,9 @@ EndSection
    access method). Only use file if map isn't working. BTW, "mmap" is an
    alias for "map" and if you do not supply a type and the file exists,
    map is assumed (see the -help output and below for some exceptions to
-   this). The "snap:" setting applies the [627]-snapfb option with
+   this). The "snap:" setting applies the [630]-snapfb option with
    "file:" type reading (this is useful for exporting webcams or TV tuner
-   video; see [628]the next FAQ for more info).
+   video; see [631]the next FAQ for more info).
 
    Also, if the string is of the form "setup:cmd" then cmd is run and the
    first line of its output retrieved and used as the rawfb string. This
@@ -5499,7 +5575,7 @@ EndSection
    screen to either shm or a mapped file. The format of these is XWD and
    so the initial header should be skipped. BTW, since XWD is not
    strictly RGB the view will only be approximate, but usable. Of course
-   for the case of Xvfb x11vnc can poll it much better via the [629]X
+   for the case of Xvfb x11vnc can poll it much better via the [632]X
    API, but you get the idea.
 
    By default in -rawfb mode x11vnc will actually close any X display it
@@ -5528,13 +5604,13 @@ EndSection
    tty1-tty6), or X graphical display (usually starting at tty7). In
    addition to the text console other graphical ones may be viewed and
    interacted with as well, e.g. DirectFB or SVGAlib apps, VMWare non-X
-   fullscreen, or [630]Qt-embedded apps (PDAs/Handhelds). By default the
+   fullscreen, or [633]Qt-embedded apps (PDAs/Handhelds). By default the
    pipeinput mechanisms UINPUT and CONSOLE (keystrokes only) are
    automatically attempted in this mode under "-rawfb console".
 
    The Video4Linux Capture device, /dev/video0, etc is either a Webcam or
    a TV capture device and needs to have its driver enabled in the
-   kernel. See [631]this FAQ for details. If specified via "-rawfb Video"
+   kernel. See [634]this FAQ for details. If specified via "-rawfb Video"
    then the pipeinput method "VID" is applied (it lets you change video
    parameters dynamically via keystrokes).
 
@@ -5542,10 +5618,10 @@ EndSection
    also useful in testing.
 
 
-   All of the above [632]-rawfb options are just for viewing the raw
+   All of the above [635]-rawfb options are just for viewing the raw
    framebuffer (although some of the aliases do imply keystroke and mouse
    pipeinput methods). That may be enough for certain applications of
-   this feature (e.g. suppose a [633]video camera mapped its framebuffer
+   this feature (e.g. suppose a [636]video camera mapped its framebuffer
    into memory and you just wanted to look at it via VNC).
    To handle the pointer and keyboard input from the viewer users the
    "-pipeinput cmd" option was added to indicate a helper program to
@@ -5583,7 +5659,7 @@ EndSection
    keystrokes into the Linux console (e.g. the virtual consoles:
    /dev/tty1, /dev/tty2, etc) in x11vnc/misc/vcinject.pl. It is based on
    the vncterm/LinuxVNC.c program also in the libvncserver CVS. So to
-   view and interact with VC #2 (assuming it is the [634]active VC) one
+   view and interact with VC #2 (assuming it is the [637]active VC) one
    can run something like:
   x11vnc -rawfb map:/dev/fb0@1024x768x16 -pipeinput './vcinject.pl 2'
 
@@ -5638,7 +5714,7 @@ EndSection
    better to use the more accurate and faster LinuxVNC program. The
    advantage x11vnc -rawfb might have is that it can allow interaction
    with a non-text application, e.g. one based on SVGAlib or
-   [635]Qt-embedded Also, for example the [636]VMWare Fullscreen mode is
+   [638]Qt-embedded Also, for example the [639]VMWare Fullscreen mode is
    actually viewable under -rawfb and can be interacted with if uinput is
    enabled.
 
@@ -5655,12 +5731,12 @@ EndSection
    program that passes the framebuffer to libvncserver.
 
 
-   Q-98: Can I export via VNC a Webcam or TV tuner framebuffer using
+   Q-99: Can I export via VNC a Webcam or TV tuner framebuffer using
    x11vnc?
 
-   Yes, this is possible to some degree with the [637]-rawfb option.
+   Yes, this is possible to some degree with the [640]-rawfb option.
    There is no X11 involved: snapshots from the video capture device are
-   used for the screen image data. See the [638]previous FAQ on -rawfb
+   used for the screen image data. See the [641]previous FAQ on -rawfb
    for background. For best results, use x11vnc version 0.8.1 or later.
 
    Roughly, one would do something like this:
@@ -5672,7 +5748,7 @@ EndSection
    snapshot to a file that you point -rawfb to; ask me if it is not clear
    what to do).
 
-   The "snap:" enforces [639]-snapfb mode which appears to be necessary.
+   The "snap:" enforces [642]-snapfb mode which appears to be necessary.
    The read pointer for video capture devices cannot be repositioned
    (which would be needed for scanline polling), but you can read a full
    frame of data from the device.
@@ -5694,7 +5770,7 @@ EndSection
 
    Many video4linux drivers tend to set the framebuffer to be 24bpp (as
    opposed to 32bpp). Since this can cause problems with VNC viewers,
-   etc, the [640]-24to32 option will be automatically imposed when in
+   etc, the [643]-24to32 option will be automatically imposed when in
    24bpp.
 
    Note that by its very nature, video capture involves rapid change in
@@ -5702,7 +5778,7 @@ EndSection
    wavering in brightness is always happening. This can lead to much
    network bandwidth consumption for the VNC traffic and also local CPU
    and I/O resource usage. You may want to experiment with "dialing down"
-   the framerate via the [641]-wait, [642]-slow_fb, or [643]-defer
+   the framerate via the [644]-wait, [645]-slow_fb, or [646]-defer
    options. Decreasing the window size and bpp also helps.
 
 
@@ -5791,16 +5867,16 @@ EndSection
          format to HI240, RGB565, RGB24, RGB32, RGB555, and
          GREY respectively. See -rawfb video for details.
 
-   See also the [644]-freqtab option to supply your own xawtv channel to
+   See also the [647]-freqtab option to supply your own xawtv channel to
    frequency mappings for your country (only ntsc-cable-us is built into
    x11vnc).
 
 
-   Q-99: Can I connect via VNC to a Qt-embedded/Qtopia application
+   Q-100: Can I connect via VNC to a Qt-embedded/Qtopia application
    running on my handheld or PC using the Linux console framebuffer (i.e.
    not X11)?
 
-   Yes, the basic method for this is the [645]-rawfb scheme where the
+   Yes, the basic method for this is the [648]-rawfb scheme where the
    Linux console framebuffer (usually /dev/fb0) is polled and the uinput
    driver is used to inject keystrokes and mouse input. Often you will
    just have to type:
@@ -5813,7 +5889,7 @@ EndSection
   x11vnc -rawfb /dev/fb0@640x480x16
 
    Also, to force usage of the uinput injection method use "-pipeinput
-   UINPUT". See the [646]-pipeinput description for tunable parameters,
+   UINPUT". See the [649]-pipeinput description for tunable parameters,
    etc.
 
    One problem with the x11vnc uinput scheme is that it cannot guess the
@@ -5829,7 +5905,7 @@ EndSection
    Even with the correct acceleration setting there is stil some drift
    (probably because of the mouse threshold where the acceleration kicks
    in) and so x11vnc needs to reposition the cursor from 0,0 about 5
-   times a second. See the [647]-pipeinput UINPUT option for tuning
+   times a second. See the [650]-pipeinput UINPUT option for tuning
    parameters that can be set (there are some experimental thresh=N
    tuning parameters as well)
 
@@ -5860,10 +5936,10 @@ EndSection
    x11vnc on your device and letting us know what does and does not work.
 
 
-   Q-100: Now that non-X11 devices can be exported via VNC using x11vnc,
+   Q-101: Now that non-X11 devices can be exported via VNC using x11vnc,
    can I build it with no dependencies on X11 header files and libraries?
 
-   Yes, as of Jul/2006 x11vnc enables building for [648]-rawfb only
+   Yes, as of Jul/2006 x11vnc enables building for [651]-rawfb only
    support. Just do something like when building:
   ./configure --without-x    (plus any other flags)
   make
@@ -5874,16 +5950,16 @@ EndSection
    know what you did.
 
 
-   Q-101: Does x11vnc support Mac OS X Aqua/Quartz displays natively
+   Q-102: Does x11vnc support Mac OS X Aqua/Quartz displays natively
    (i.e. no X11 involved)?
 
    Yes, since Nov/2006 in the development tree (x11vnc-0.8.4 tarball)
    there is support for native Mac OS X Aqua/Quartz displays using the
-   [649]-rawfb mechanism described above. The mouse and keyboard input is
+   [652]-rawfb mechanism described above. The mouse and keyboard input is
    acheived via Mac OS X API's.
 
-   So you can use x11vnc as an alternative to [650]OSXvnc (aka Vine
-   Server), or [651]Apple Remote Desktop (ARD). Perhaps there is some
+   So you can use x11vnc as an alternative to [653]OSXvnc (aka Vine
+   Server), or [654]Apple Remote Desktop (ARD). Perhaps there is some
    x11vnc feature you'd like to use on Mac OS X, etc.
 
    Notes:
@@ -5892,7 +5968,7 @@ EndSection
    (XDarwin) running on Mac OS X (people often install this software to
    display remote X11 apps on their Mac OS X system, or use some old
    favorites locally such as xterm). However in this case x11vnc will
-   only work reasonably in single window [652]-id windowid mode (and the
+   only work reasonably in single window [655]-id windowid mode (and the
    window may need to have mouse focus).
 
    If you do not have the DISPLAY env. variable set, x11vnc will assume
@@ -5906,9 +5982,9 @@ EndSection
    ./configure --without-x
    make
 
-   Win2VNC/x2vnc:  One handy use is to use the [653]-nofb mode to
+   Win2VNC/x2vnc:  One handy use is to use the [656]-nofb mode to
    redirect mouse and keyboard input to a nearby Mac (i.e. one to the
-   side of your desk) via [654]x2vnc or Win2VNC. See [655]this FAQ for
+   side of your desk) via [657]x2vnc or Win2VNC. See [658]this FAQ for
    more info.
 
    Options:  Here are the Mac OS X specific x11vnc options:
@@ -5972,36 +6048,36 @@ rm -f $tmp
    [Misc: Clipboard, File Transfer/Sharing, Printing, Sound, Beeps,
    Thanks, etc.]
 
-   Q-102: Does the Clipboard/Selection get transferred between the
+   Q-103: Does the Clipboard/Selection get transferred between the
    vncviewer and the X display?
 
    As of Jan/2004 x11vnc supports the "CutText" part of the rfb protocol.
    Furthermore, x11vnc is able to hold the PRIMARY and CLIPBOARD
    selection (Xvnc does not seem to do this). If you don't want the
-   Clipboard/Selection exchanged use the [656]-nosel option. If you don't
+   Clipboard/Selection exchanged use the [659]-nosel option. If you don't
    want the PRIMARY selection to be polled for changes use the
-   [657]-noprimary option. (with a similar thing for CLIPBOARD). You can
-   also fine-tune it a bit with the [658]-seldir dir option and also
-   [659]-input.
+   [660]-noprimary option. (with a similar thing for CLIPBOARD). You can
+   also fine-tune it a bit with the [661]-seldir dir option and also
+   [662]-input.
 
    You may need to watch out for desktop utilities such as KDE's
    "Klipper" that do odd things with the selection, clipboard, and
    cutbuffers.
 
 
-   Q-103: Can I use x11vnc to record a Shock Wave Flash (or other format)
+   Q-104: Can I use x11vnc to record a Shock Wave Flash (or other format)
    video of my desktop, e.g. to record a tutorial or demo?
 
    Yes, it is possible with a number of tools that record VNC and
    transform it to swf format or others. One such popular tool is
-   [660]pyvnc2swf. There are a number of [661]tutorials on how to do
+   [663]pyvnc2swf. There are a number of [664]tutorials on how to do
    this. Another option is to use the vnc2mpg that comes in the
    LibVNCServer package.
    An important thing to remember when doing this is that tuning
    parameters should be applied to x11vnc to speed up its polling for
    this sort of application, e.g. "-wait 10 -defer 10".
 
-   Q-104: Can I transfer files back and forth with x11vnc?
+   Q-105: Can I transfer files back and forth with x11vnc?
 
    As of Oct/2005 and May/2006 x11vnc enables, respectively, the TightVNC
    and UltraVNC file transfer implementations that were added to
@@ -6009,7 +6085,7 @@ rm -f $tmp
    (and Windows viewers only support filetransfer it appears).
 
    TightVNC file transfer is on by default, if you want to disable it use
-   the [662]-nofilexfer option. UltraVNC file transfer is currently off
+   the [665]-nofilexfer option. UltraVNC file transfer is currently off
    by default, to enable it use something like "-rfbversion 3.6
    -permitfiletransfer"
    options (UltraVNC incorrectly uses the RFB protocol version to
@@ -6019,13 +6095,13 @@ rm -f $tmp
    VNC Viewers.
 
 
-   Q-105: Can I (temporarily) mount my local (viewer-side) Windows/Samba
+   Q-106: Can I (temporarily) mount my local (viewer-side) Windows/Samba
    File share on the machine where x11vnc is running?
 
    You will have to use an external network redirection for this.
    Filesystem mounting is not part of the VNC protocol.
 
-   We show a simple [663]Samba example here.
+   We show a simple [666]Samba example here.
 
    First you will need a tunnel to redirect the SMB requests from the
    remote machine to the one you sitting at. We use an ssh tunnel:
@@ -6062,17 +6138,17 @@ d,ip=127.0.0.1,port=1139
   far-away> smbumount /home/fred/smb-haystack-pub
 
    At some point we hope to fold some automation for SMB ssh redir setup
-   into the [664]Enhanced TightVNC Viewer (ssvnc) package we provide (as
+   into the [667]Enhanced TightVNC Viewer (ssvnc) package we provide (as
    of Sep 2006 it is there for testing).
 
 
-   Q-106: Can I redirect CUPS print jobs from the remote desktop where
+   Q-107: Can I redirect CUPS print jobs from the remote desktop where
    x11vnc is running to a printer on my local (viewer-side) machine?
 
    You will have to use an external network redirection for this.
    Printing is not part of the VNC protocol.
 
-   We show a simple Unix to Unix [665]CUPS example here. Non-CUPS port
+   We show a simple Unix to Unix [668]CUPS example here. Non-CUPS port
    redirections (e.g. LPD) should also be possible, but may be a bit more
    tricky. If you are viewing on Windows SMB and don't have a local cups
    server it may be trickier still (see below).
@@ -6144,11 +6220,11 @@ d,ip=127.0.0.1,port=1139
    "localhost".
 
    At some point we hope to fold some automation for CUPS ssh redir setup
-   into the [666]Enhanced TightVNC Viewer (ssvnc) package we provide (as
+   into the [669]Enhanced TightVNC Viewer (ssvnc) package we provide (as
    of Sep 2006 it is there for testing).
 
 
-   Q-107: How can I hear the sound (audio) from the remote applications
+   Q-108: How can I hear the sound (audio) from the remote applications
    on the desktop I am viewing via x11vnc?
 
    You will have to use an external network audio mechanism for this.
@@ -6245,11 +6321,11 @@ or:
        the applications will fail to run because LD_PRELOAD will point to
        libraries of the wrong wordsize.
      * At some point we hope to fold some automation for esd or artsd ssh
-       redir setup into the [667]Enhanced TightVNC Viewer (ssvnc) package
+       redir setup into the [670]Enhanced TightVNC Viewer (ssvnc) package
        we provide (as of Sep/2006 it is there for testing).
 
 
-   Q-108: Why don't I hear the "Beeps" in my X session (e.g. when typing
+   Q-109: Why don't I hear the "Beeps" in my X session (e.g. when typing
    tput bel in an xterm)?
 
    As of Dec/2003 "Beep" XBell events are tracked by default. The X
@@ -6257,16 +6333,16 @@ or:
    in Solaris, see Xserver(1) for how to turn it on via +kb), and so you
    won't hear them if the extension is not present.
 
-   If you don't want to hear the beeps use the [668]-nobell option. If
+   If you don't want to hear the beeps use the [671]-nobell option. If
    you want to hear the audio from the remote applications, consider
-   trying a [669]redirector such as esd.
+   trying a [672]redirector such as esd.
 
 
 
 
     Contributions:
 
-   Q-109: Thanks for your program and for your help! Can I make a
+   Q-110: 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!
@@ -6479,472 +6555,475 @@ References
  201. http://www.karlrunge.com/x11vnc/index.html#faq-pointer-mode
  202. http://www.karlrunge.com/x11vnc/index.html#faq-wireframe
  203. http://www.karlrunge.com/x11vnc/index.html#faq-scrollcopyrect
- 204. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-shape
- 205. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha
- 206. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha-hacks
- 207. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-arrow
- 208. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-positions
- 209. http://www.karlrunge.com/x11vnc/index.html#faq-buttonmap-opt
- 210. http://www.karlrunge.com/x11vnc/index.html#faq-altgr
- 211. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
- 212. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless-sloppy
- 213. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
- 214. http://www.karlrunge.com/x11vnc/index.html#faq-repeated-keys
- 215. http://www.karlrunge.com/x11vnc/index.html#faq-repeated-keys-still
- 216. http://www.karlrunge.com/x11vnc/index.html#faq-remap-opt
- 217. http://www.karlrunge.com/x11vnc/index.html#faq-sun-alt-meta
- 218. http://www.karlrunge.com/x11vnc/index.html#faq-remap-button-click
- 219. http://www.karlrunge.com/x11vnc/index.html#faq-remap-capslock
- 220. http://www.karlrunge.com/x11vnc/index.html#faq-scrollbars
- 221. http://www.karlrunge.com/x11vnc/index.html#faq-scaling
- 222. http://www.karlrunge.com/x11vnc/index.html#faq-xinerama
- 223. http://www.karlrunge.com/x11vnc/index.html#faq-multi-screen
- 224. http://www.karlrunge.com/x11vnc/index.html#faq-clip-screen
- 225. http://www.karlrunge.com/x11vnc/index.html#faq-xrandr
- 226. http://www.karlrunge.com/x11vnc/index.html#faq-rotate
- 227. http://www.karlrunge.com/x11vnc/index.html#faq-black-screen
- 228. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
- 229. http://www.karlrunge.com/x11vnc/index.html#faq-hidden-taskbars
- 230. http://www.karlrunge.com/x11vnc/index.html#faq-kde-screensaver
- 231. http://www.karlrunge.com/x11vnc/index.html#faq-vmware
- 232. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
- 233. http://www.karlrunge.com/x11vnc/index.html#faq-video
- 234. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
- 235. http://www.karlrunge.com/x11vnc/index.html#faq-no-x11
- 236. http://www.karlrunge.com/x11vnc/index.html#faq-macosx
- 237. http://www.karlrunge.com/x11vnc/index.html#faq-clipboard
- 238. http://www.karlrunge.com/x11vnc/index.html#faq-record-swf
- 239. http://www.karlrunge.com/x11vnc/index.html#faq-filexfer
- 240. http://www.karlrunge.com/x11vnc/index.html#faq-smb-shares
- 241. http://www.karlrunge.com/x11vnc/index.html#faq-cups
- 242. http://www.karlrunge.com/x11vnc/index.html#faq-sound
- 243. http://www.karlrunge.com/x11vnc/index.html#faq-beeps
- 244. http://www.karlrunge.com/x11vnc/index.html#faq-thanks
- 245. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display
- 246. http://www.tldp.org/HOWTO/Remote-X-Apps.html
- 247. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
- 248. http://www.karlrunge.com/x11vnc/index.html#faq-display-manager
- 249. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
- 250. http://www.karlrunge.com/x11vnc/index.html#solarisbuilding
- 251. http://www.karlrunge.com/x11vnc/x11vnc_sunos4.html
- 252. http://www.karlrunge.com/x11vnc/index.html#building
- 253. http://www.karlrunge.com/x11vnc/index.html#faq-build
- 254. http://packages.debian.org/x11vnc
- 255. http://www.linuxpackages.net/search_view.php?by=name&name=x11vnc
- 256. http://dag.wieers.com/packages/x11vnc/
- 257. http://dries.ulyssis.org/rpm/packages/x11vnc/info.html
- 258. http://linux01.gwdg.de/~pbleser/rpm-navigation.php?cat=Network/x11vnc/
- 259. http://www.sunfreeware.com/
- 260. http://www.freebsd.org/cgi/ports.cgi?query=x11vnc&stype=all
- 261. http://www.freshports.org/net/x11vnc
- 262. http://www.openbsd.org/3.9_packages/i386/x11vnc-0.6.2.tgz-long.html
- 263. http://pkgsrc.se/x11/x11vnc
- 264. http://mike.saunby.net/770/x11vnc/
- 265. http://www.pdaxrom.org/ipk_feed.php?menuid=11&showfeed=unstable#x11vnc
- 266. http://www.focv.com/ipkg/
- 267. http://www.karlrunge.com/x11vnc/bins
- 268. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
- 269. http://www.tightvnc.com/download.html
- 270. http://www.realvnc.com/download-free.html
- 271. http://sourceforge.net/projects/cotvnc/
- 272. http://www.ultravnc.com/
- 273. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 274. http://www.karlrunge.com/x11vnc/x11vnc_opts.html
- 275. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
- 276. http://www.karlrunge.com/x11vnc/index.html#faq-gui-tray
- 277. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-q
- 278. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-bg
- 279. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-o
- 280. http://www.karlrunge.com/x11vnc/index.html#solarisbuilding
- 281. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nofb
- 282. http://fredrik.hubbe.net/x2vnc.html
- 283. http://www.hubbe.net/~hubbe/win2vnc.html
- 284. http://www.deboer.gmxhome.de/
- 285. http://sourceforge.net/projects/win2vnc/
- 286. http://fredrik.hubbe.net/x2vnc.html
- 287. http://freshmeat.net/projects/x2x/
- 288. http://ftp.digital.com/pub/Digital/SRC/x2x/
- 289. http://zapek.com/software/zvnc/
- 290. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-visual
- 291. http://www.karlrunge.com/x11vnc/index.html#faq-macosx
- 292. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flashcmap
- 293. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
- 294. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-notruecolor
- 295. http://www.karlrunge.com/x11vnc/index.html#faq-8bpp
- 296. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
- 297. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
- 298. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
- 299. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
- 300. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flashcmap
- 301. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
- 302. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
- 303. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 304. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
- 305. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
- 306. http://www.karlrunge.com/x11vnc/index.html#faq-overlays
- 307. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 308. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sid
- 309. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-24to32
- 310. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display
- 311. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
- 312. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flipbyteorder
- 313. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
- 314. http://www.karlrunge.com/x11vnc/index.html#xauth_pain
- 315. http://www.karlrunge.com/x11vnc/index.html#faq-noshm
- 316. http://wwws.sun.com/sunray/index.html
- 317. http://www.karlrunge.com/x11vnc/sunray.html
- 318. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
- 319. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-query
- 320. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-forever
- 321. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-bg
- 322. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clear_mods
- 323. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clear_keys
- 324. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
- 325. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-query
- 326. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
- 327. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-storepasswd
- 328. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
- 329. http://www.karlrunge.com/x11vnc/index.html#faq-passwdfile
- 330. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-usepw
- 331. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-viewpasswd
- 332. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwd
- 333. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
- 334. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
- 335. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
- 336. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
- 337. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_nis
- 338. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 339. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
- 340. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 204. http://www.karlrunge.com/x11vnc/index.html#faq-client-caching
+ 205. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-shape
+ 206. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha
+ 207. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha-hacks
+ 208. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-arrow
+ 209. http://www.karlrunge.com/x11vnc/index.html#faq-cursor-positions
+ 210. http://www.karlrunge.com/x11vnc/index.html#faq-buttonmap-opt
+ 211. http://www.karlrunge.com/x11vnc/index.html#faq-altgr
+ 212. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
+ 213. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless-sloppy
+ 214. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
+ 215. http://www.karlrunge.com/x11vnc/index.html#faq-repeated-keys
+ 216. http://www.karlrunge.com/x11vnc/index.html#faq-repeated-keys-still
+ 217. http://www.karlrunge.com/x11vnc/index.html#faq-remap-opt
+ 218. http://www.karlrunge.com/x11vnc/index.html#faq-sun-alt-meta
+ 219. http://www.karlrunge.com/x11vnc/index.html#faq-remap-button-click
+ 220. http://www.karlrunge.com/x11vnc/index.html#faq-remap-capslock
+ 221. http://www.karlrunge.com/x11vnc/index.html#faq-scrollbars
+ 222. http://www.karlrunge.com/x11vnc/index.html#faq-scaling
+ 223. http://www.karlrunge.com/x11vnc/index.html#faq-xinerama
+ 224. http://www.karlrunge.com/x11vnc/index.html#faq-multi-screen
+ 225. http://www.karlrunge.com/x11vnc/index.html#faq-clip-screen
+ 226. http://www.karlrunge.com/x11vnc/index.html#faq-xrandr
+ 227. http://www.karlrunge.com/x11vnc/index.html#faq-rotate
+ 228. http://www.karlrunge.com/x11vnc/index.html#faq-black-screen
+ 229. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
+ 230. http://www.karlrunge.com/x11vnc/index.html#faq-hidden-taskbars
+ 231. http://www.karlrunge.com/x11vnc/index.html#faq-kde-screensaver
+ 232. http://www.karlrunge.com/x11vnc/index.html#faq-vmware
+ 233. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
+ 234. http://www.karlrunge.com/x11vnc/index.html#faq-video
+ 235. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
+ 236. http://www.karlrunge.com/x11vnc/index.html#faq-no-x11
+ 237. http://www.karlrunge.com/x11vnc/index.html#faq-macosx
+ 238. http://www.karlrunge.com/x11vnc/index.html#faq-clipboard
+ 239. http://www.karlrunge.com/x11vnc/index.html#faq-record-swf
+ 240. http://www.karlrunge.com/x11vnc/index.html#faq-filexfer
+ 241. http://www.karlrunge.com/x11vnc/index.html#faq-smb-shares
+ 242. http://www.karlrunge.com/x11vnc/index.html#faq-cups
+ 243. http://www.karlrunge.com/x11vnc/index.html#faq-sound
+ 244. http://www.karlrunge.com/x11vnc/index.html#faq-beeps
+ 245. http://www.karlrunge.com/x11vnc/index.html#faq-thanks
+ 246. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display
+ 247. http://www.tldp.org/HOWTO/Remote-X-Apps.html
+ 248. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
+ 249. http://www.karlrunge.com/x11vnc/index.html#faq-display-manager
+ 250. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
+ 251. http://www.karlrunge.com/x11vnc/index.html#solarisbuilding
+ 252. http://www.karlrunge.com/x11vnc/x11vnc_sunos4.html
+ 253. http://www.karlrunge.com/x11vnc/index.html#building
+ 254. http://www.karlrunge.com/x11vnc/index.html#faq-build
+ 255. http://packages.debian.org/x11vnc
+ 256. http://www.linuxpackages.net/search_view.php?by=name&name=x11vnc
+ 257. http://dag.wieers.com/packages/x11vnc/
+ 258. http://dries.ulyssis.org/rpm/packages/x11vnc/info.html
+ 259. http://linux01.gwdg.de/~pbleser/rpm-navigation.php?cat=Network/x11vnc/
+ 260. http://www.sunfreeware.com/
+ 261. http://www.freebsd.org/cgi/ports.cgi?query=x11vnc&stype=all
+ 262. http://www.freshports.org/net/x11vnc
+ 263. http://www.openbsd.org/3.9_packages/i386/x11vnc-0.6.2.tgz-long.html
+ 264. http://pkgsrc.se/x11/x11vnc
+ 265. http://mike.saunby.net/770/x11vnc/
+ 266. http://www.pdaxrom.org/ipk_feed.php?menuid=11&showfeed=unstable#x11vnc
+ 267. http://www.focv.com/ipkg/
+ 268. http://www.karlrunge.com/x11vnc/bins
+ 269. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
+ 270. http://www.tightvnc.com/download.html
+ 271. http://www.realvnc.com/download-free.html
+ 272. http://sourceforge.net/projects/cotvnc/
+ 273. http://www.ultravnc.com/
+ 274. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 275. http://www.karlrunge.com/x11vnc/x11vnc_opts.html
+ 276. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
+ 277. http://www.karlrunge.com/x11vnc/index.html#faq-gui-tray
+ 278. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-q
+ 279. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-bg
+ 280. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-o
+ 281. http://www.karlrunge.com/x11vnc/index.html#solarisbuilding
+ 282. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nofb
+ 283. http://fredrik.hubbe.net/x2vnc.html
+ 284. http://www.hubbe.net/~hubbe/win2vnc.html
+ 285. http://www.deboer.gmxhome.de/
+ 286. http://sourceforge.net/projects/win2vnc/
+ 287. http://fredrik.hubbe.net/x2vnc.html
+ 288. http://freshmeat.net/projects/x2x/
+ 289. http://ftp.digital.com/pub/Digital/SRC/x2x/
+ 290. http://zapek.com/software/zvnc/
+ 291. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-visual
+ 292. http://www.karlrunge.com/x11vnc/index.html#faq-macosx
+ 293. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flashcmap
+ 294. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
+ 295. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-notruecolor
+ 296. http://www.karlrunge.com/x11vnc/index.html#faq-8bpp
+ 297. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
+ 298. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
+ 299. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
+ 300. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
+ 301. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flashcmap
+ 302. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
+ 303. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
+ 304. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 305. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-8to24
+ 306. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
+ 307. http://www.karlrunge.com/x11vnc/index.html#faq-overlays
+ 308. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 309. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sid
+ 310. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-24to32
+ 311. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display
+ 312. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
+ 313. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-flipbyteorder
+ 314. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
+ 315. http://www.karlrunge.com/x11vnc/index.html#xauth_pain
+ 316. http://www.karlrunge.com/x11vnc/index.html#faq-noshm
+ 317. http://wwws.sun.com/sunray/index.html
+ 318. http://www.karlrunge.com/x11vnc/sunray.html
+ 319. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
+ 320. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-query
+ 321. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-forever
+ 322. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-bg
+ 323. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clear_mods
+ 324. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clear_keys
+ 325. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
+ 326. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-query
+ 327. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
+ 328. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-storepasswd
+ 329. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
+ 330. http://www.karlrunge.com/x11vnc/index.html#faq-passwdfile
+ 331. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-usepw
+ 332. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-viewpasswd
+ 333. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwd
+ 334. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 335. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
+ 336. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 337. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
+ 338. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_nis
+ 339. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 340. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
  341. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 342. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 343. http://www.karlrunge.com/x11vnc/index.html#tunnelling
- 344. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel
- 345. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
- 346. http://www.karlrunge.com/x11vnc/index.html#faq-accept-opt
- 347. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_cmd
- 348. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 342. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 343. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 344. http://www.karlrunge.com/x11vnc/index.html#tunnelling
+ 345. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel
+ 346. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
+ 347. http://www.karlrunge.com/x11vnc/index.html#faq-accept-opt
+ 348. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_cmd
  349. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
- 350. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_cmd
- 351. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
- 352. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 350. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 351. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw_cmd
+ 352. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
  353. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
  354. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
- 355. http://www.karlrunge.com/x11vnc/index.html#faq-accept-opt
- 356. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-forever
- 357. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-shared
- 358. http://www.karlrunge.com/x11vnc/index.html#tunnelling
- 359. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 360. http://www.karlrunge.com/x11vnc/index.html#faq-passwd
- 361. http://www.karlrunge.com/x11vnc/index.html#faq-passwdfile
- 362. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
- 363. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 364. http://www.karlrunge.com/x11vnc/index.html#faq-tcp_wrappers
- 365. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
- 366. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-listen
- 367. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
- 368. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 369. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
- 370. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 371. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-input
- 372. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
- 373. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-viewonly
- 374. ftp://ftp.x.org/
- 375. http://www.karlrunge.com/x11vnc/dtVncPopup
- 376. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gone
- 377. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-afteraccept
- 378. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
- 379. http://www.karlrunge.com/x11vnc/blockdpy.c
- 380. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
- 381. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gone
+ 355. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 356. http://www.karlrunge.com/x11vnc/index.html#faq-accept-opt
+ 357. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-forever
+ 358. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-shared
+ 359. http://www.karlrunge.com/x11vnc/index.html#tunnelling
+ 360. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 361. http://www.karlrunge.com/x11vnc/index.html#faq-passwd
+ 362. http://www.karlrunge.com/x11vnc/index.html#faq-passwdfile
+ 363. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
+ 364. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 365. http://www.karlrunge.com/x11vnc/index.html#faq-tcp_wrappers
+ 366. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
+ 367. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-listen
+ 368. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
+ 369. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 370. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-allow
+ 371. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 372. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-input
+ 373. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
+ 374. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-viewonly
+ 375. ftp://ftp.x.org/
+ 376. http://www.karlrunge.com/x11vnc/dtVncPopup
+ 377. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gone
+ 378. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-afteraccept
+ 379. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
+ 380. http://www.karlrunge.com/x11vnc/blockdpy.c
+ 381. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-accept
  382. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gone
- 383. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-afteraccept
- 384. http://www.karlrunge.com/x11vnc/index.html#tunnelling
- 385. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 386. http://www.karlrunge.com/x11vnc/index.html#tunnelling
- 387. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 388. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
- 389. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
- 390. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
- 391. http://www.karlrunge.com/x11vnc/index.html#gateway_double_ssh
- 392. http://www.karlrunge.com/x11vnc/index.html#tunnelling
- 393. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
- 394. http://www.stunnel.org/
- 395. http://stunnel.mirt.net/
- 396. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 397. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
- 398. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sslverify
- 399. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-int
- 400. http://www.stunnel.org/
- 401. http://www.karlrunge.com/x11vnc/ssl.html
- 402. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
- 403. http://www.karlrunge.com/x11vnc/ssl.html
- 404. http://www.securityfocus.com/infocus/1677
- 405. http://www.karlrunge.com/x11vnc/ssl.html
- 406. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-inetd
- 407. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
- 408. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
- 409. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
- 410. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 411. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
- 412. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
- 413. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 414. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
- 415. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 416. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-ext
- 417. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 418. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
- 419. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
- 420. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
- 421. http://www.openssl.org/
- 422. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
- 423. http://www.stunnel.org/
- 424. http://www.karlrunge.com/x11vnc/ssl.html
- 425. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
- 426. http://www.karlrunge.com/x11vnc/ssl.html
- 427. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
- 428. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
- 429. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
- 430. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
- 431. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-portal
- 432. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
- 433. http://www.karlrunge.com/x11vnc/ssl-output.html
- 434. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-ext
- 435. http://www.karlrunge.com/x11vnc/ss_vncviewer
- 436. http://www.karlrunge.com/x11vnc/ssl-portal.html
- 437. http://www.karlrunge.com/x11vnc/ssl.html
- 438. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 439. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
- 440. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
- 441. http://www.karlrunge.com/x11vnc/ssl-portal.html
- 442. http://www.karlrunge.com/x11vnc/ssl.html
- 443. http://www.karlrunge.com/x11vnc/index.html#display-manager-continuously
- 444. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
- 445. http://www.karlrunge.com/x11vnc/index.html#faq-userlogin
- 446. http://www.karlrunge.com/x11vnc/index.html#x11vnc_loop
- 447. http://club.mandriva.com/xwiki/bin/view/KB/XwinXset
- 448. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
- 449. http://www.karlrunge.com/x11vnc/index.html#dtlogin_solaris
- 450. http://www.jirka.org/gdm-documentation/x241.html
- 451. http://www.karlrunge.com/x11vnc/x11vnc_loop
- 452. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-loop
- 453. http://www.karlrunge.com/x11vnc/index.html#faq-xterminal-xauth
- 454. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-inetd
- 455. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-q
- 456. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
- 457. http://www.karlrunge.com/x11vnc/index.html#faq-userlogin
- 458. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
- 459. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
- 460. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
- 461. http://www.karlrunge.com/x11vnc/index.html#stunnel-inetd
- 462. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
- 463. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
- 464. http://www.karlrunge.com/x11vnc/index.html#faq-unix-passwords
- 465. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
- 466. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-int
- 467. http://www.karlrunge.com/x11vnc/index.html#faq-xvfb
- 468. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
- 469. http://www.karlrunge.com/x11vnc/faq-linuxvc
- 470. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-loop
- 471. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
- 472. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
- 473. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
- 474. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
- 475. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-vncconnect
- 476. http://www.karlrunge.com/x11vnc/index.html#findcreatedisplay
- 477. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
- 478. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-add_keysyms
- 479. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
- 480. http://www.karlrunge.com/x11vnc/Xdummy
- 481. http://www.karlrunge.com/x11vnc/index.html#display-manager-continuously
- 482. http://www.karlrunge.com/x11vnc/index.html#findcreatedisplay
- 483. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
- 484. http://www.karlrunge.com/x11vnc/shm_clear
- 485. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
- 486. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
- 487. http://www.karlrunge.com/x11vnc/index.html#faq-noshm
- 488. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nap
- 489. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
- 490. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sb
- 491. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
- 492. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fs
- 493. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-threads
- 494. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
- 495. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 496. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-solid
- 497. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
- 498. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
- 499. http://www.tightvnc.com/
- 500. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
- 501. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
- 502. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-solid
- 503. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-speeds
- 504. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodragging
- 505. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fs
- 506. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
- 507. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
- 508. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-progressive
- 509. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 510. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nosel
- 511. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursor
- 512. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorpos
- 513. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-readtimeout
- 514. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
- 515. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
- 516. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xd_area
- 517. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xd_mem
- 518. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noxdamage
+ 383. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gone
+ 384. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-afteraccept
+ 385. http://www.karlrunge.com/x11vnc/index.html#tunnelling
+ 386. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 387. http://www.karlrunge.com/x11vnc/index.html#tunnelling
+ 388. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 389. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-localhost
+ 390. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbauth
+ 391. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-passwdfile
+ 392. http://www.karlrunge.com/x11vnc/index.html#gateway_double_ssh
+ 393. http://www.karlrunge.com/x11vnc/index.html#tunnelling
+ 394. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
+ 395. http://www.stunnel.org/
+ 396. http://stunnel.mirt.net/
+ 397. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 398. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
+ 399. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sslverify
+ 400. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-int
+ 401. http://www.stunnel.org/
+ 402. http://www.karlrunge.com/x11vnc/ssl.html
+ 403. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
+ 404. http://www.karlrunge.com/x11vnc/ssl.html
+ 405. http://www.securityfocus.com/infocus/1677
+ 406. http://www.karlrunge.com/x11vnc/ssl.html
+ 407. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-inetd
+ 408. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
+ 409. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
+ 410. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
+ 411. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 412. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
+ 413. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
+ 414. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 415. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
+ 416. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 417. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-ext
+ 418. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 419. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
+ 420. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
+ 421. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ssl
+ 422. http://www.openssl.org/
+ 423. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-stunnel
+ 424. http://www.stunnel.org/
+ 425. http://www.karlrunge.com/x11vnc/ssl.html
+ 426. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
+ 427. http://www.karlrunge.com/x11vnc/ssl.html
+ 428. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
+ 429. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
+ 430. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
+ 431. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
+ 432. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-portal
+ 433. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-https
+ 434. http://www.karlrunge.com/x11vnc/ssl-output.html
+ 435. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-ext
+ 436. http://www.karlrunge.com/x11vnc/ss_vncviewer
+ 437. http://www.karlrunge.com/x11vnc/ssl-portal.html
+ 438. http://www.karlrunge.com/x11vnc/ssl.html
+ 439. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 440. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
+ 441. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-viewers
+ 442. http://www.karlrunge.com/x11vnc/ssl-portal.html
+ 443. http://www.karlrunge.com/x11vnc/ssl.html
+ 444. http://www.karlrunge.com/x11vnc/index.html#display-manager-continuously
+ 445. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
+ 446. http://www.karlrunge.com/x11vnc/index.html#faq-userlogin
+ 447. http://www.karlrunge.com/x11vnc/index.html#x11vnc_loop
+ 448. http://club.mandriva.com/xwiki/bin/view/KB/XwinXset
+ 449. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
+ 450. http://www.karlrunge.com/x11vnc/index.html#dtlogin_solaris
+ 451. http://www.jirka.org/gdm-documentation/x241.html
+ 452. http://www.karlrunge.com/x11vnc/x11vnc_loop
+ 453. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-loop
+ 454. http://www.karlrunge.com/x11vnc/index.html#faq-xterminal-xauth
+ 455. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-inetd
+ 456. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-q
+ 457. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-auth
+ 458. http://www.karlrunge.com/x11vnc/index.html#faq-userlogin
+ 459. http://www.karlrunge.com/x11vnc/index.html#faq-inetd
+ 460. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
+ 461. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
+ 462. http://www.karlrunge.com/x11vnc/index.html#stunnel-inetd
+ 463. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
+ 464. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-unixpw
+ 465. http://www.karlrunge.com/x11vnc/index.html#faq-unix-passwords
+ 466. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-users
+ 467. http://www.karlrunge.com/x11vnc/index.html#faq-ssl-tunnel-int
+ 468. http://www.karlrunge.com/x11vnc/index.html#faq-xvfb
+ 469. http://www.karlrunge.com/x11vnc/index.html#ss_vncviewer
+ 470. http://www.karlrunge.com/x11vnc/faq-linuxvc
+ 471. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-loop
+ 472. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-httpdir
+ 473. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-http
+ 474. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
+ 475. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remote
+ 476. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-vncconnect
+ 477. http://www.karlrunge.com/x11vnc/index.html#findcreatedisplay
+ 478. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
+ 479. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-add_keysyms
+ 480. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
+ 481. http://www.karlrunge.com/x11vnc/Xdummy
+ 482. http://www.karlrunge.com/x11vnc/index.html#display-manager-continuously
+ 483. http://www.karlrunge.com/x11vnc/index.html#findcreatedisplay
+ 484. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-display_WAIT
+ 485. http://www.karlrunge.com/x11vnc/shm_clear
+ 486. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
+ 487. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
+ 488. http://www.karlrunge.com/x11vnc/index.html#faq-noshm
+ 489. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nap
+ 490. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
+ 491. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sb
+ 492. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
+ 493. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fs
+ 494. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-threads
+ 495. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
+ 496. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 497. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-solid
+ 498. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
+ 499. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
+ 500. http://www.tightvnc.com/
+ 501. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
+ 502. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
+ 503. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-solid
+ 504. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-speeds
+ 505. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodragging
+ 506. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fs
+ 507. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
+ 508. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
+ 509. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-progressive
+ 510. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 511. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nosel
+ 512. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursor
+ 513. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorpos
+ 514. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-readtimeout
+ 515. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
+ 516. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
+ 517. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xd_area
+ 518. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xd_mem
  519. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noxdamage
- 520. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
- 521. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pointer_mode
+ 520. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noxdamage
+ 521. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
  522. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pointer_mode
- 523. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodragging
- 524. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pointer_mode
- 525. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-threads
- 526. http://www.karlrunge.com/x11vnc/index.html#faq-wireframe
- 527. http://www.karlrunge.com/x11vnc/index.html#faq-scrollcopyrect
- 528. http://www.karlrunge.com/x11vnc/index.html#faq-pointer-mode
- 529. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
- 530. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
+ 523. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pointer_mode
+ 524. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodragging
+ 525. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pointer_mode
+ 526. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-threads
+ 527. http://www.karlrunge.com/x11vnc/index.html#faq-wireframe
+ 528. http://www.karlrunge.com/x11vnc/index.html#faq-scrollcopyrect
+ 529. http://www.karlrunge.com/x11vnc/index.html#faq-pointer-mode
+ 530. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
  531. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
  532. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
- 533. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
- 534. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
- 535. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
- 536. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wirecopyrect
- 537. http://www.karlrunge.com/x11vnc/index.html#faq-wireframe
- 538. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
- 539. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scr_skip
- 540. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale
- 541. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
- 542. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursor
- 543. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursor
- 544. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
- 545. http://www.karlrunge.com/x11vnc/index.html#the-overlay-mode
- 546. http://www.karlrunge.com/x11vnc/index.html#solaris10-build
- 547. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha-hacks
- 548. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alphacut
- 549. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alphafrac
- 550. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alpharemove
- 551. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorshape
- 552. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noalphablend
- 553. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 554. http://www.tightvnc.com/
- 555. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursor
- 556. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursorpos
- 557. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorpos
- 558. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorshape
- 559. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-buttonmap
- 560. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_pointer
- 561. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-buttonmap
- 562. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
- 563. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
- 564. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
- 565. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_keyboard
- 566. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
- 567. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sloppy_keys
- 568. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
- 569. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
- 570. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 571. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
- 572. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_keyboard
- 573. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
- 574. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
- 575. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sloppy_keys
- 576. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
+ 533. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
+ 534. http://www.karlrunge.com/x11vnc/index.html#fb_read_slow
+ 535. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
+ 536. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wireframe
+ 537. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wirecopyrect
+ 538. http://www.karlrunge.com/x11vnc/index.html#faq-wireframe
+ 539. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-fixscreen
+ 540. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scr_skip
+ 541. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale
+ 542. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scrollcopyrect
+ 543. http://www.karlrunge.com/x11vnc/index.html#beta-test
+ 544. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-ncache
+ 545. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursor
+ 546. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursor
+ 547. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-overlay
+ 548. http://www.karlrunge.com/x11vnc/index.html#the-overlay-mode
+ 549. http://www.karlrunge.com/x11vnc/index.html#solaris10-build
+ 550. http://www.karlrunge.com/x11vnc/index.html#faq-xfixes-alpha-hacks
+ 551. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alphacut
+ 552. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alphafrac
+ 553. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-alpharemove
+ 554. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorshape
+ 555. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noalphablend
+ 556. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 557. http://www.tightvnc.com/
+ 558. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursor
+ 559. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-cursorpos
+ 560. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorpos
+ 561. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nocursorshape
+ 562. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-buttonmap
+ 563. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_pointer
+ 564. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-buttonmap
+ 565. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
+ 566. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
+ 567. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
+ 568. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_keyboard
+ 569. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
+ 570. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sloppy_keys
+ 571. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
+ 572. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
+ 573. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 574. http://www.karlrunge.com/x11vnc/index.html#faq-xkbmodtweak
+ 575. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-debug_keyboard
+ 576. http://www.karlrunge.com/x11vnc/index.html#faq-greaterless
  577. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
- 578. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
- 579. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-skip_keycodes
- 580. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 581. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-add_keysyms
- 582. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 578. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-sloppy_keys
+ 579. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-modtweak
+ 580. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
+ 581. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xkb
+ 582. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-skip_keycodes
  583. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
  584. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-add_keysyms
- 585. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-norepeat
- 586. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-norepeat
- 587. http://www.karlrunge.com/x11vnc/index.html#faq-display-manager
- 588. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 589. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 590. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 585. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 586. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 587. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-add_keysyms
+ 588. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-norepeat
+ 589. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-norepeat
+ 590. http://www.karlrunge.com/x11vnc/index.html#faq-display-manager
  591. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 592. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-skip_lockkeys
+ 592. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
  593. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
- 594. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nomodtweak
- 595. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-capslock
- 596. http://www.karlrunge.com/x11vnc/index.html#faq-scaling
- 597. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale
- 598. http://www.cus.cam.ac.uk/~ssb22/source/vnc-magnification.html
- 599. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbport
- 600. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
- 601. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
- 602. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale_cursor
- 603. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-blackout
- 604. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xinerama
- 605. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xinerama
- 606. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xwarppointer
- 607. http://www.karlrunge.com/x11vnc/index.html#faq-solshm
- 608. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
- 609. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
- 610. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clip
- 611. http://www.karlrunge.com/x11vnc/index.html#faq-xinerama
- 612. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 613. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 614. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xrandr
- 615. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-padgeom
- 616. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 617. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rotate
- 618. http://www.jwz.org/xscreensaver/man1.html
- 619. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodpms
- 620. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
- 621. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
- 622. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
- 623. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 624. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
- 625. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
- 626. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
- 627. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-snapfb
- 628. http://www.karlrunge.com/x11vnc/index.html#faq-video
- 629. http://www.karlrunge.com/x11vnc/index.html#faq-xvfb
- 630. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
+ 594. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 595. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-skip_lockkeys
+ 596. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-remap
+ 597. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nomodtweak
+ 598. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-capslock
+ 599. http://www.karlrunge.com/x11vnc/index.html#faq-scaling
+ 600. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale
+ 601. http://www.cus.cam.ac.uk/~ssb22/source/vnc-magnification.html
+ 602. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rfbport
+ 603. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-gui
+ 604. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-connect
+ 605. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-scale_cursor
+ 606. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-blackout
+ 607. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xinerama
+ 608. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xinerama
+ 609. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xwarppointer
+ 610. http://www.karlrunge.com/x11vnc/index.html#faq-solshm
+ 611. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-onetile
+ 612. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noshm
+ 613. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-clip
+ 614. http://www.karlrunge.com/x11vnc/index.html#faq-xinerama
+ 615. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 616. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 617. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-xrandr
+ 618. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-padgeom
+ 619. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 620. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rotate
+ 621. http://www.jwz.org/xscreensaver/man1.html
+ 622. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nodpms
+ 623. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
+ 624. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
+ 625. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
+ 626. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 627. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
+ 628. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
+ 629. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
+ 630. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-snapfb
  631. http://www.karlrunge.com/x11vnc/index.html#faq-video
- 632. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
- 633. http://www.karlrunge.com/x11vnc/index.html#faq-video
- 634. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
- 635. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
- 636. http://www.karlrunge.com/x11vnc/index.html#faq-vmware
- 637. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
- 638. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
- 639. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-snapfb
- 640. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-24to32
- 641. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
- 642. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-slow_fb
- 643. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
- 644. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-freqtab
- 645. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
- 646. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
- 647. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
- 648. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
- 649. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
- 650. http://www.redstonesoftware.com/vnc.html
- 651. http://www.apple.com/remotedesktop/
- 652. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 653. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
- 654. http://fredrik.hubbe.net/x2vnc.html
- 655. http://www.karlrunge.com/x11vnc/index.html#faq-win2vnc
- 656. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nosel
- 657. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noprimary
- 658. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-seldir
- 659. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-input
- 660. http://www.unixuser.org/~euske/vnc2swf/
- 661. http://wolphination.com/linux/2006/06/30/how-to-record-videos-of-your-desktop/
- 662. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nofilexfer
- 663. http://www.samba.org/
- 664. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 665. http://www.cups.org/
- 666. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 632. http://www.karlrunge.com/x11vnc/index.html#faq-xvfb
+ 633. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
+ 634. http://www.karlrunge.com/x11vnc/index.html#faq-video
+ 635. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
+ 636. http://www.karlrunge.com/x11vnc/index.html#faq-video
+ 637. http://www.karlrunge.com/x11vnc/index.html#faq-linuxvc
+ 638. http://www.karlrunge.com/x11vnc/index.html#faq-qt-embedded
+ 639. http://www.karlrunge.com/x11vnc/index.html#faq-vmware
+ 640. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
+ 641. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
+ 642. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-snapfb
+ 643. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-24to32
+ 644. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-wait
+ 645. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-slow_fb
+ 646. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-defer
+ 647. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-freqtab
+ 648. http://www.karlrunge.com/x11vnc/index.html#faq-rawfb
+ 649. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
+ 650. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-pipeinput
+ 651. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
+ 652. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-rawfb
+ 653. http://www.redstonesoftware.com/vnc.html
+ 654. http://www.apple.com/remotedesktop/
+ 655. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 656. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-id
+ 657. http://fredrik.hubbe.net/x2vnc.html
+ 658. http://www.karlrunge.com/x11vnc/index.html#faq-win2vnc
+ 659. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nosel
+ 660. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-noprimary
+ 661. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-seldir
+ 662. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-input
+ 663. http://www.unixuser.org/~euske/vnc2swf/
+ 664. http://wolphination.com/linux/2006/06/30/how-to-record-videos-of-your-desktop/
+ 665. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nofilexfer
+ 666. http://www.samba.org/
  667. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
- 668. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nobell
- 669. http://www.karlrunge.com/x11vnc/index.html#faq-sound
+ 668. http://www.cups.org/
+ 669. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 670. http://www.karlrunge.com/x11vnc/enhanced_tightvnc_viewer.html
+ 671. http://www.karlrunge.com/x11vnc/x11vnc_opts.html#opt-nobell
+ 672. http://www.karlrunge.com/x11vnc/index.html#faq-sound
 	
 =======================================================================
 http://www.karlrunge.com/x11vnc/chainingssh.html:
@@ -9183,7 +9262,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.8.4 lastmod: 2006-12-17
+x11vnc: allow VNC connections to real X11 displays. 0.8.4 lastmod: 2006-12-28
 
 x11vnc options:
   -display disp            -auth file               -id windowid           
@@ -9229,32 +9308,34 @@ x11vnc options:
   -noalphablend            -nocursorshape           -cursorpos             
   -nocursorpos             -xwarppointer            -noxwarppointer        
   -buttonmap string        -nodragging              -ncache n              
-  -wireframe [str]         -nowireframe             -nowireframelocal      
-  -wirecopyrect mode       -nowirecopyrect          -debug_wireframe       
-  -scrollcopyrect mode     -noscrollcopyrect        -scr_area n            
-  -scr_skip list           -scr_inc list            -scr_keys list         
-  -scr_term list           -scr_keyrepeat lo-hi     -scr_parms string      
-  -fixscreen string        -debug_scroll            -noxrecord             
-  -grab_buster             -nograb_buster           -debug_grabs           
-  -debug_sel               -pointer_mode n          -input_skip n          
-  -allinput                -speeds rd,bw,lat        -wmdt string           
-  -debug_pointer           -debug_keyboard          -defer time            
-  -wait time               -wait_ui factor          -nowait_bog            
-  -slow_fb time            -readtimeout n           -nap                   
-  -nonap                   -sb time                 -nofbpm                
-  -fbpm                    -nodpms                  -dpms                  
-  -noxdamage               -xd_area A               -xd_mem f              
-  -sigpipe string          -threads                 -nothreads             
-  -fs f                    -gaps n                  -grow n                
-  -fuzz n                  -debug_tiles             -snapfb                
-  -rawfb string            -freqtab file            -pipeinput cmd         
-  -macnodim                -macnosleep              -macnosaver            
-  -macnowait               -macwheel n              -macnoswap             
-  -macnoresize             -gui [gui-opts]          -remote command        
-  -query variable          -QD variable             -sync                  
-  -noremote                -yesremote               -unsafe                
-  -safer                   -privremote              -nocmds                
-  -allowedcmds list        -deny_all              
+  -ncache_cr               -ncache_pad n            -wireframe [str]       
+  -nowireframe             -nowireframelocal        -wirecopyrect mode     
+  -nowirecopyrect          -debug_wireframe         -scrollcopyrect mode   
+  -noscrollcopyrect        -scr_area n              -scr_skip list         
+  -scr_inc list            -scr_keys list           -scr_term list         
+  -scr_keyrepeat lo-hi     -scr_parms string        -fixscreen string      
+  -debug_scroll            -noxrecord               -grab_buster           
+  -nograb_buster           -debug_grabs             -debug_sel             
+  -pointer_mode n          -input_skip n            -allinput              
+  -speeds rd,bw,lat        -wmdt string             -debug_pointer         
+  -debug_keyboard          -defer time              -wait time             
+  -wait_ui factor          -nowait_bog              -slow_fb time          
+  -readtimeout n           -nap                     -nonap                 
+  -sb time                 -nofbpm                  -fbpm                  
+  -nodpms                  -dpms                    -noxdamage             
+  -xd_area A               -xd_mem f                -sigpipe string        
+  -threads                 -nothreads               -fs f                  
+  -gaps n                  -grow n                  -fuzz n                
+  -debug_tiles             -snapfb                  -rawfb string          
+  -freqtab file            -pipeinput cmd           -macnodim              
+  -macnosleep              -macnosaver              -macnowait             
+  -macwheel n              -macnoswap               -macnoresize           
+  -maciconanim n           -macmenu                 -gui [gui-opts]        
+  -remote command          -query variable          -QD variable           
+  -sync                    -noremote                -yesremote             
+  -unsafe                  -safer                   -privremote            
+  -nocmds                  -allowedcmds list        -deny_all              
+
 
 libvncserver options:
 -rfbport port          TCP port for RFB protocol
@@ -9288,7 +9369,7 @@ libvncserver-tight-extension options:
 
 % x11vnc -help
 
-x11vnc: allow VNC connections to real X11 displays. 0.8.4 lastmod: 2006-12-17
+x11vnc: allow VNC connections to real X11 displays. 0.8.4 lastmod: 2006-12-28
 
 (type "x11vnc -opts" to just list the options.)
 
@@ -11282,17 +11363,49 @@ Options:
                        If this method is successful, the changes required for
                        clients to do this less awkwardly will be investigated.
 
-                       Note that this mode consumes a lot of memory, both
-                       on the x11vnc server side and on the VNC Viewer side.
-                       If n=2 then the amount of RAM used is roughly tripled
-                       for both x11vnc and the VNC Viewer.  As a rule of
-                       thumb, note that 1280x1024 at depth 24 is about 5MB of
-                       pixel data.
+                       Note that this mode consumes a huge amount of memory,
+                       both on the x11vnc server side and on the VNC Viewer
+                       side.  If n=2 then the amount of RAM used is roughly
+                       tripled for both x11vnc and the VNC Viewer.  As a rule
+                       of thumb, note that 1280x1024 at depth 24 is about 5MB
+                       of pixel data.
+
+                       For reasonable response when cycling through 4 to 6
+                       large (e.g. web browser) windows a value n of 6 to 12
+                       is recommended. (that's right: ~10X more memory...)
 
                        Because of the way window backingstore and saveunders
                        are implemented, n must be even.  It will be incremented
                        by 1 if it is not.
 
+                       This mode also works for native MacOS X, but may not
+                       be as effective as the X version.  This is due to a
+                       number of things, one is the drop-shadow compositing
+                       that leaves extra areas that need to be repaired (see
+                       -ncache_pad).  Another is the window iconification
+                       animations need to be avoided (see -macicontime).
+                       It appears the that the 'Scale' animation mode gives
+                       better results than the 'Genie' one.  Also, window event
+                       detection not as accurate as the X version.
+
+-ncache_cr             In -nache mode, try do to copyrect opaque window
+                       moves/drags instead of wireframes (this can induce
+                       painting errors).  The wireframe will still be used when
+                       moving a window whose save-unders has not yet been set
+                       or has been invalidated.
+
+                       Some VNC Viewers provide better response than others
+                       with this option.  On Unix, realvnc viewer gives
+                       smoother drags than tightvnc viewer.  Response may also
+                       be choppy if the server side machine is too slow.
+
+-ncache_pad n          In -nache mode, pad each window with n pixels for the
+                       caching rectangles.  This can be used to try to improve
+                       the situation with dropshadows or other compositing
+                       (e.g. MacOS X window manager), although it could make
+                       things worse.  The default is 0 on Unix and 24 on
+                       MacOS X.
+
 -wireframe [str]       Try to detect window moves or resizes when a mouse
 -nowireframe           button is held down and show a wireframe instead of
                        the full opaque window.  This is based completely on
@@ -12229,6 +12342,13 @@ t
 -macnoresize           For the native Mac OS X server, do not resize or reset
                        the framebuffer even if it is detected that the screen
                        resolution or depth has changed.
+-maciconanim n         For the native Mac OS X server, set n to the number
+                       of milliseconds that the window iconify/deiconify
+                       animation takes.  In -ncache mode this value will be
+                       used to skip the animation if possible. (default 400)
+-macmenu               For the native Mac OS X server, in -ncache client-side
+                       caching mode, try to cache pull down menus (not perfect
+                       because they have animated fades, etc.)
 
 -gui [gui-opts]        Start up a simple tcl/tk gui based on the the remote
                        control options -remote/-query described below.
@@ -12531,6 +12651,11 @@ n
                        buttonmap:str   set -buttonmap "str", empty to disable
                        dragging        disable -nodragging mode.
                        nodragging      enable  -nodragging mode.
+                       ncache          reenable -ncache mode.
+                       noncache        disable  -ncache mode.
+                       ncache_size:n   set -ncache size to n.
+                       ncache_cr       enable  -ncache_cr mode.
+                       noncache_cr     disable -ncache_cr mode.
                        wireframe       enable  -wireframe mode. same as "wf"
                        nowireframe     disable -wireframe mode. same as "nowf"
                        wireframe:str   enable  -wireframe mode string.
@@ -12599,6 +12724,16 @@ n
                        rfbport:n       set -rfbport to n.
                        macnosaver      enable  -macnosaver mode.
                        macsaver        disable -macnosaver mode.
+                       macnowait       enable  -macnowait  mode.
+                       macwait         disable -macnowait  mode.
+                       macwheel:n      set -macwheel to n.
+                       macnoswap       enable  -macnoswap mouse button mode.
+                       macswap         disable -macnoswap mouse button mode.
+                       macnoresize     enable  -macnoresize mode.
+                       macresize       disable -macnoresize mode.
+                       maciconanim:n   set -maciconanim to n.
+                       macmenu         enable  -macmenu  mode.
+                       macnomenu       disable -macnmenu mode.
                        httpport:n      set -httpport to n.
                        httpdir:dir     set -httpdir to dir (and enable http).
                        enablehttpproxy   enable  -enablehttpproxy mode.
@@ -12687,7 +12822,8 @@ n
                        xdamage noxdamage xd_area xd_mem alphacut alphafrac
                        alpharemove noalpharemove alphablend noalphablend
                        xwarppointer xwarp noxwarppointer noxwarp buttonmap
-                       dragging nodragging wireframe_mode wireframe wf
+                       dragging nodragging ncache_cr noncache_cr ncache
+                       noncache ncache_size wireframe_mode wireframe wf
                        nowireframe nowf wireframelocal wfl nowireframelocal
                        nowfl wirecopyrect wcr nowirecopyrect nowcr scr_area
                        scr_skip scr_inc scr_keys scr_term scr_keyrepeat
@@ -12710,7 +12846,10 @@ n
                        debug_wireframe debug_scroll nodebug_scroll debug_scroll
                        debug_tiles dbt nodebug_tiles nodbt debug_tiles
                        debug_grabs nodebug_grabs debug_sel nodebug_sel dbg
-                       nodbg macnosaver macsaver noremote
+                       nodbg macnosaver macsaver nomacnosaver macnowait macwait
+                       nomacnowait macwheel macnoswap macswap nomacnoswap
+                       macnoresize macresize nomacnoresize maciconanim macmenu
+                       macnomenu nomacmenu noremote
 
                        aro=  noop display vncdisplay desktopname guess_desktop
                        http_url auth xauth users rootshift clipshift
@@ -12727,6 +12866,8 @@ n
                        mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y
                        wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y
                        rfbauth passwd viewpasswd
+
+
 -QD variable           Just like -query variable, but returns the default
                        value for that parameter (no running x11vnc server
                        is consulted)
diff --git a/x11vnc/cleanup.c b/x11vnc/cleanup.c
index 199220d7bc6f2b0af59c349d6d9a84e22dfec88d..1134a0fceace69af999e883d509952a28d2a25fa 100644
--- a/x11vnc/cleanup.c
+++ b/x11vnc/cleanup.c
@@ -359,6 +359,7 @@ crash_prompt:
 static void interrupted (int sig) {
 	exit_sig = sig;
 	if (exit_flag) {
+		fprintf(stderr, "extra[%d] signal: %d\n", exit_flag, sig);
 		exit_flag++;
 		if (use_threads) {
 			usleep2(250 * 1000);
@@ -370,6 +371,7 @@ static void interrupted (int sig) {
 	exit_flag++;
 	if (sig == 0) {
 		fprintf(stderr, "caught X11 error:\n");
+		if (crash_debug) { crash_shell(); }
 	} else if (sig == -1) {
 		fprintf(stderr, "caught XIO error:\n");
 	} else {
@@ -380,6 +382,10 @@ static void interrupted (int sig) {
 		return;
 	}
 
+	if (crash_debug) {
+		crash_shell();
+	}
+
 	X_UNLOCK;
 
 	if (icon_mode) {
diff --git a/x11vnc/connections.c b/x11vnc/connections.c
index 006b81929e0f0ac48ff1817587e615ea73ddfa41..fd44018a463fe9b90bf3c6d714394351f1342d1a 100644
--- a/x11vnc/connections.c
+++ b/x11vnc/connections.c
@@ -1033,7 +1033,7 @@ static unsigned char t2x2_bits[] = {
 	XSetStandardProperties(dpy, awin, sprop, "x11vnc query", ico, NULL,
 	    0, &hints);
 
-	XSelectInput(dpy, awin, evmask);
+	XSelectInput_wr(dpy, awin, evmask);
 
 	if (! font_info && (font_info = XLoadQueryFont(dpy, "fixed")) == NULL) {
 		rfbLogEnable(1);
@@ -1209,7 +1209,7 @@ static unsigned char t2x2_bits[] = {
 		}
 		if (out != -1) {
 			ret = out;
-			XSelectInput(dpy, awin, 0);
+			XSelectInput_wr(dpy, awin, 0);
 			XUnmapWindow(dpy, awin);
 			XFree_wr(gc);
 			XDestroyWindow(dpy, awin);
@@ -1554,7 +1554,7 @@ static void check_connect_file(char *file) {
 					rfbLog("read connect file: %s\n", str);
 				}
 				if (!strcmp(str, "cmd=stop") &&
-				    dnow() - x11vnc_start < 3.0) {
+				    dnowx() < 3.0) {
 					rfbLog("ignoring stale cmd=stop\n");
 				} else {
 					client_connect = str;
@@ -2131,6 +2131,10 @@ enum rfbNewClientAction new_client(rfbClientPtr client) {
 	accepted_client = 1;
 	last_client = time(NULL);
 
+	if (ncache) {
+		check_ncache(1, 0);
+	}
+
 	if (unixpw) {
 		unixpw_in_progress = 1;
 		unixpw_client = client;
diff --git a/x11vnc/cursor.c b/x11vnc/cursor.c
index ded74ca6c2c68b68d4cd4a51c4e91eeb871bc4a6..0f3b2c64ebc130e22967d235b9d9236b18f166d3 100644
--- a/x11vnc/cursor.c
+++ b/x11vnc/cursor.c
@@ -1705,6 +1705,24 @@ int cursor_shape_updates_clients(rfbScreenInfoPtr s) {
 	return count;
 }
 
+int cursor_noshape_updates_clients(rfbScreenInfoPtr s) {
+	rfbClientIteratorPtr iter;
+	rfbClientPtr cl;
+	int count = 0;
+
+	if (! s) {
+		return 0;
+	}
+	iter = rfbGetClientIterator(s);
+	while( (cl = rfbClientIteratorNext(iter)) ) {
+		if (!cl->enableCursorShapeUpdates) {
+			count++;
+		}
+	}
+	rfbReleaseClientIterator(iter);
+	return count;
+}
+
 int cursor_pos_updates_clients(rfbScreenInfoPtr s) {
 	rfbClientIteratorPtr iter;
 	rfbClientPtr cl;
diff --git a/x11vnc/cursor.h b/x11vnc/cursor.h
index 8dbe9dcf3de2a52deab73514df2bfbfab3636bcb..0bf328741bcf8fa04bcb923105e85fc9bb651b2c 100644
--- a/x11vnc/cursor.h
+++ b/x11vnc/cursor.h
@@ -24,6 +24,7 @@ extern int get_which_cursor(void);
 extern void restore_cursor_shape_updates(rfbScreenInfoPtr s);
 extern void disable_cursor_shape_updates(rfbScreenInfoPtr s);
 extern int cursor_shape_updates_clients(rfbScreenInfoPtr s);
+extern int cursor_noshape_updates_clients(rfbScreenInfoPtr s);
 extern int cursor_pos_updates_clients(rfbScreenInfoPtr s);
 extern void cursor_position(int x, int y);
 extern void set_no_cursor(void);
diff --git a/x11vnc/help.c b/x11vnc/help.c
index 73d5c86a0fc5f6412420ece2bf09f8ca40960452..65924077ff555e6836a03325611725853981634d 100644
--- a/x11vnc/help.c
+++ b/x11vnc/help.c
@@ -2028,17 +2028,49 @@ void print_help(int mode) {
 "                       If this method is successful, the changes required for\n"
 "                       clients to do this less awkwardly will be investigated.\n"
 "\n"
-"                       Note that this mode consumes a lot of memory, both\n"
-"                       on the x11vnc server side and on the VNC Viewer side.\n"
-"                       If n=2 then the amount of RAM used is roughly tripled\n"
-"                       for both x11vnc and the VNC Viewer.  As a rule of\n"
-"                       thumb, note that 1280x1024 at depth 24 is about 5MB of\n"
-"                       pixel data.\n"
+"                       Note that this mode consumes a huge amount of memory,\n"
+"                       both on the x11vnc server side and on the VNC Viewer\n"
+"                       side.  If n=2 then the amount of RAM used is roughly\n"
+"                       tripled for both x11vnc and the VNC Viewer.  As a rule\n"
+"                       of thumb, note that 1280x1024 at depth 24 is about 5MB\n"
+"                       of pixel data.\n"
+"\n"
+"                       For reasonable response when cycling through 4 to 6\n"
+"                       large (e.g. web browser) windows a value n of 6 to 12\n"
+"                       is recommended. (that's right: ~10X more memory...)\n"
 "\n"
 "                       Because of the way window backingstore and saveunders\n"
 "                       are implemented, n must be even.  It will be incremented\n"
 "                       by 1 if it is not.\n"
 "\n"
+"                       This mode also works for native MacOS X, but may not\n"
+"                       be as effective as the X version.  This is due to a\n"
+"                       number of things, one is the drop-shadow compositing\n"
+"                       that leaves extra areas that need to be repaired (see\n"
+"                       -ncache_pad).  Another is the window iconification\n"
+"                       animations need to be avoided (see -macicontime).\n"
+"                       It appears the that the 'Scale' animation mode gives\n"
+"                       better results than the 'Genie' one.  Also, window event\n"
+"                       detection not as accurate as the X version.\n"
+"\n"
+"-ncache_cr             In -nache mode, try do to copyrect opaque window\n"
+"                       moves/drags instead of wireframes (this can induce\n"
+"                       painting errors).  The wireframe will still be used when\n"
+"                       moving a window whose save-unders has not yet been set\n"
+"                       or has been invalidated.\n"
+"\n"
+"                       Some VNC Viewers provide better response than others\n"
+"                       with this option.  On Unix, realvnc viewer gives\n"
+"                       smoother drags than tightvnc viewer.  Response may also\n"
+"                       be choppy if the server side machine is too slow.\n"
+"\n"
+"-ncache_pad n          In -nache mode, pad each window with n pixels for the\n"
+"                       caching rectangles.  This can be used to try to improve\n"
+"                       the situation with dropshadows or other compositing\n"
+"                       (e.g. MacOS X window manager), although it could make\n"
+"                       things worse.  The default is 0 on Unix and 24 on\n"
+"                       MacOS X.\n"
+"\n"
 #endif
 "-wireframe [str]       Try to detect window moves or resizes when a mouse\n"
 "-nowireframe           button is held down and show a wireframe instead of\n"
@@ -2975,6 +3007,13 @@ void print_help(int mode) {
 "-macnoresize           For the native Mac OS X server, do not resize or reset\n"
 "                       the framebuffer even if it is detected that the screen\n"
 "                       resolution or depth has changed.\n"
+"-maciconanim n         For the native Mac OS X server, set n to the number\n"
+"                       of milliseconds that the window iconify/deiconify\n"
+"                       animation takes.  In -ncache mode this value will be\n"
+"                       used to skip the animation if possible. (default 400)\n"
+"-macmenu               For the native Mac OS X server, in -ncache client-side\n"
+"                       caching mode, try to cache pull down menus (not perfect\n"
+"                       because they have animated fades, etc.)\n"
 "\n"
 "-gui [gui-opts]        Start up a simple tcl/tk gui based on the the remote\n"
 "                       control options -remote/-query described below.\n"
@@ -3285,6 +3324,11 @@ void print_help(int mode) {
 "                       buttonmap:str   set -buttonmap \"str\", empty to disable\n"
 "                       dragging        disable -nodragging mode.\n"
 "                       nodragging      enable  -nodragging mode.\n"
+"                       ncache          reenable -ncache mode.\n"
+"                       noncache        disable  -ncache mode.\n"
+"                       ncache_size:n   set -ncache size to n.\n"
+"                       ncache_cr       enable  -ncache_cr mode.\n"
+"                       noncache_cr     disable -ncache_cr mode.\n"
 "                       wireframe       enable  -wireframe mode. same as \"wf\"\n"
 "                       nowireframe     disable -wireframe mode. same as \"nowf\"\n"
 "                       wireframe:str   enable  -wireframe mode string.\n"
@@ -3350,6 +3394,16 @@ void print_help(int mode) {
 "                       rfbport:n       set -rfbport to n.\n"
 "                       macnosaver      enable  -macnosaver mode.\n"
 "                       macsaver        disable -macnosaver mode.\n"
+"                       macnowait       enable  -macnowait  mode.\n"
+"                       macwait         disable -macnowait  mode.\n"
+"                       macwheel:n      set -macwheel to n.\n"
+"                       macnoswap       enable  -macnoswap mouse button mode.\n"
+"                       macswap         disable -macnoswap mouse button mode.\n"
+"                       macnoresize     enable  -macnoresize mode.\n"
+"                       macresize       disable -macnoresize mode.\n"
+"                       maciconanim:n   set -maciconanim to n.\n"
+"                       macmenu         enable  -macmenu  mode.\n"
+"                       macnomenu       disable -macnmenu mode.\n"
 /* access */
 "                       httpport:n      set -httpport to n.\n"
 "                       httpdir:dir     set -httpdir to dir (and enable http).\n"
@@ -3439,7 +3493,8 @@ void print_help(int mode) {
 "                       xdamage noxdamage xd_area xd_mem alphacut alphafrac\n"
 "                       alpharemove noalpharemove alphablend noalphablend\n"
 "                       xwarppointer xwarp noxwarppointer noxwarp buttonmap\n"
-"                       dragging nodragging wireframe_mode wireframe wf\n"
+"                       dragging nodragging ncache_cr noncache_cr ncache\n"
+"                       noncache ncache_size wireframe_mode wireframe wf\n"
 "                       nowireframe nowf wireframelocal wfl nowireframelocal\n"
 "                       nowfl wirecopyrect wcr nowirecopyrect nowcr scr_area\n"
 "                       scr_skip scr_inc scr_keys scr_term scr_keyrepeat\n"
@@ -3462,7 +3517,10 @@ void print_help(int mode) {
 "                       debug_wireframe debug_scroll nodebug_scroll debug_scroll\n"
 "                       debug_tiles dbt nodebug_tiles nodbt debug_tiles\n"
 "                       debug_grabs nodebug_grabs debug_sel nodebug_sel dbg\n"
-"                       nodbg macnosaver macsaver noremote\n"
+"                       nodbg macnosaver macsaver nomacnosaver macnowait macwait\n"
+"                       nomacnowait macwheel macnoswap macswap nomacnoswap\n"
+"                       macnoresize macresize nomacnoresize maciconanim macmenu\n"
+"                       macnomenu nomacmenu noremote\n"
 "\n"
 "                       aro=  noop display vncdisplay desktopname guess_desktop\n"
 "                       http_url auth xauth users rootshift clipshift\n"
@@ -3479,6 +3537,8 @@ void print_help(int mode) {
 "                       mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y\n"
 "                       wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y\n"
 "                       rfbauth passwd viewpasswd\n"
+"\n"
+"\n"
 "-QD variable           Just like -query variable, but returns the default\n"
 "                       value for that parameter (no running x11vnc server\n"
 "                       is consulted)\n"
diff --git a/x11vnc/keyboard.c b/x11vnc/keyboard.c
index 69ac71d3d4ef29a41545398928b80c139de5d08a..aedc021201628df32d70cb07f5f267fbe5e36806 100644
--- a/x11vnc/keyboard.c
+++ b/x11vnc/keyboard.c
@@ -997,15 +997,13 @@ void switch_to_xkb_if_better(void) {
 	XFree_wr(keymap);
 	if (missing_noxkb == 0 && syms_gt_4 >= 8) {
 		if (! raw_fb_str) {
-			rfbLog("XKEYBOARD: number of keysyms per keycode %d "
-			    "is greater\n", syms_per_keycode);
-			rfbLog("  than 4 and %d keysyms are mapped above 4.\n",
-			    syms_gt_4);
+			rfbLog("\n");
+			rfbLog("XKEYBOARD: number of keysyms per keycode %d is greater\n", syms_per_keycode);
+			rfbLog("  than 4 and %d keysyms are mapped above 4.\n", syms_gt_4);
 			rfbLog("  Automatically switching to -xkb mode.\n");
 			rfbLog("  If this makes the key mapping worse you can\n");
 			rfbLog("  disable it with the \"-noxkb\" option.\n");
-			rfbLog("  Also, remember \"-remap DEAD\" for accenting"
-			    " characters.\n");
+			rfbLog("  Also, remember \"-remap DEAD\" for accenting characters.\n");
 		}
 
 		use_xkb_modtweak = 1;
@@ -1013,13 +1011,11 @@ void switch_to_xkb_if_better(void) {
 
 	} else if (missing_noxkb == 0) {
 		if (! raw_fb_str) {
-			rfbLog("XKEYBOARD: all %d \"must have\" keysyms accounted"
-			    " for.\n", n);
+			rfbLog("\n");
+			rfbLog("XKEYBOARD: all %d \"must have\" keysyms accounted for.\n", n);
 			rfbLog("  Not automatically switching to -xkb mode.\n");
-			rfbLog("  If some keys still cannot be typed, try using"
-			    " -xkb.\n");
-			rfbLog("  Also, remember \"-remap DEAD\" for accenting"
-			    " characters.\n");
+			rfbLog("  If some keys still cannot be typed, try using -xkb.\n");
+			rfbLog("  Also, remember \"-remap DEAD\" for accenting characters.\n");
 		}
 		return;
 	}
diff --git a/x11vnc/macosx.c b/x11vnc/macosx.c
index 647e62c489af328912ebc1d3c19cdcdb47ccfc77..86833b904e9be4155194be87f0457848cf6b6a34 100644
--- a/x11vnc/macosx.c
+++ b/x11vnc/macosx.c
@@ -36,6 +36,12 @@ int macosx_valid_window(Window, XWindowAttributes*);
 Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return,
     Window **children_return, unsigned int *nchildren_return);
 
+void macosx_add_mapnotify(Window win, int level, int map);
+void macosx_add_create(Window win, int level);
+void macosx_add_destroy(Window win, int level);
+void macosx_add_visnotify(Window win, int level, int obscured);
+int macosx_checkevent(XEvent *ev);
+
 #if (! DOMAC)
 
 void macosx_event_loop(void) {
@@ -72,6 +78,22 @@ Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return,
     Window **children_return, unsigned int *nchildren_return) {
 	return (Status) 0;
 }
+void macosx_add_mapnotify(Window win, int level, int map) {
+	return;
+}
+void macosx_add_create(Window win, int level) {
+	return;
+}
+void macosx_add_destroy(Window win, int level) {
+	return;
+}
+void macosx_add_visnotify(Window win, int level, int obscured) {
+	return;
+}
+
+int macosx_checkevent(XEvent *ev) {
+	return 0;
+}
 
 
 int dragum(void) {return 1;}
@@ -169,6 +191,8 @@ char *macosx_console_guess(char *str, int *fd) {
 	return q;
 }
 
+Window macosx_click_frame = None;
+
 void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
 	allowed_input_t input;
 	static int last_mask = 0;
@@ -197,6 +221,16 @@ void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
 		last_pointer_client = client;
 		last_pointer_time = time(NULL);
 	}
+	if (last_mask != mask) {
+		fprintf(stderr, "about to inject mask change %d -> %d: %.4f\n", last_mask, mask, dnowx());
+		if (mask) {
+			int px, py, x, y, w, h;
+			macosx_click_frame = None;
+			if (!macosx_get_wm_frame_pos(&px, &py, &x, &y, &w, &h, &macosx_click_frame, NULL)) {
+				macosx_click_frame = None;
+			}
+		}
+	}
 
 	macosxCG_pointer_inject(mask, x, y);
 
@@ -209,6 +243,19 @@ void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
 
 	if (last_mask != mask) {
 		last_pointer_click_time = dnow();
+		if (ncache > 0) {
+			/* XXX Y */
+			int i;
+fprintf(stderr, "about to get all windows:           %.4f\n", dnowx());
+			for (i=0; i < 2; i++) {
+				macosxCGS_get_all_windows();
+				fprintf(stderr, "!");
+				if (macosx_checkevent(NULL)) {
+					break;
+				}
+			}
+fprintf(stderr, "\ndone:                               %.4f\n", dnowx());
+		}
 	}
 	last_mask = mask;
 
@@ -299,11 +346,130 @@ int macosx_get_cursor(void) {
 	return macosxCG_get_cursor();
 }
 
+typedef struct evdat {
+	int win;
+	int map;
+	int level;
+	int vis;
+	int type;
+} evdat_t;
+
+#define MAX_EVENTS 1024
+evdat_t mac_events[MAX_EVENTS];
+int mac_events_ptr = 0;
+int mac_events_last = 0;
+
+void macosx_add_mapnotify(Window win, int level, int map) {
+	int i = mac_events_last++;
+	mac_events[i].win = win;
+	mac_events[i].level = level;
+
+	if (map) {
+		mac_events[i].type = MapNotify;
+	} else {
+		mac_events[i].type = UnmapNotify;
+	}
+	mac_events[i].map = map;
+	mac_events[i].vis = -1;
+
+	mac_events_last = mac_events_last % MAX_EVENTS;
+
+	return;
+}
+
+void macosx_add_create(Window win, int level) {
+	int i = mac_events_last++;
+	mac_events[i].win = win;
+	mac_events[i].level = level;
+
+	mac_events[i].type = CreateNotify;
+	mac_events[i].map = -1;
+	mac_events[i].vis = -1;
+
+	mac_events_last = mac_events_last % MAX_EVENTS;
+
+	return;
+}
+
+void macosx_add_destroy(Window win, int level) {
+	int i = mac_events_last++;
+	mac_events[i].win = win;
+	mac_events[i].level = level;
+
+	mac_events[i].type = DestroyNotify;
+	mac_events[i].map = -1;
+	mac_events[i].vis = -1;
+
+	mac_events_last = mac_events_last % MAX_EVENTS;
+
+	return;
+}
+
+void macosx_add_visnotify(Window win, int level, int obscured) {
+	int i = mac_events_last++;
+	mac_events[i].win = win;
+	mac_events[i].level = level;
+
+	mac_events[i].type = VisibilityNotify;
+	mac_events[i].map = -1;
+
+	mac_events[i].vis = 1;
+	if (obscured == 0) {
+		mac_events[i].vis = VisibilityUnobscured;
+	} else if (obscured == 1) {
+		mac_events[i].vis = VisibilityPartiallyObscured;
+	} else if (obscured == 2) {
+		mac_events[i].vis = VisibilityFullyObscured; 	/* NI */
+	}
+
+	mac_events_last = mac_events_last % MAX_EVENTS;
+
+	return;
+}
+
+int macosx_checkevent(XEvent *ev) {
+	int i = mac_events_ptr;
+
+	if (mac_events_ptr == mac_events_last) {
+		return 0;
+	}
+	if (ev == NULL) {
+		return mac_events[i].type;
+	}
+
+	ev->xany.window = mac_events[i].win;
+
+	if (mac_events[i].type == CreateNotify) {
+		ev->type = CreateNotify;
+		ev->xany.window = rootwin;
+		ev->xcreatewindow.window = mac_events[i].win;
+	} else if (mac_events[i].type == DestroyNotify) {
+		ev->type = DestroyNotify;
+		ev->xdestroywindow.window = mac_events[i].win;
+	} else if (mac_events[i].type == VisibilityNotify) {
+		ev->type = VisibilityNotify;
+		ev->xvisibility.state = mac_events[i].vis;
+	} else if (mac_events[i].type == MapNotify) {
+		ev->type = MapNotify;
+	} else if (mac_events[i].type == UnmapNotify) {
+		ev->type = UnmapNotify;
+	} else {
+		fprintf(stderr, "unknown macosx_checkevent: %d\n", mac_events[i].type);
+	}
+	mac_events_ptr++;
+	mac_events_ptr = mac_events_ptr % MAX_EVENTS;
+
+	return mac_events[i].type;
+}
+
 typedef struct windat {
 	int win;
 	int x, y;
 	int width, height;
 	int level;
+	int mapped;
+	int clipped;
+	int ncache_only;
 } windat_t;
 
 extern int macwinmax; 
@@ -313,19 +479,13 @@ int macosx_get_wm_frame_pos(int *px, int *py, int *x, int *y, int *w, int *h,
     Window *frame, Window *win) {
 	static int last_idx = -1;
 	int x1, x2, y1, y2;
-	int idx = -1, i, k;
+	int idx = -1, k;
 	macosxCGS_get_all_windows();
 	macosxCG_get_cursor_pos(px, py);
 
-	for (i = -1; i<macwinmax; i++) {
-		k = i;
-		if (i == -1)  {
-			if (last_idx >= 0 && last_idx < macwinmax) {
-				k = last_idx;
-			} else {
-				last_idx = -1;
-				continue;
-			}
+	for (k = 0; k<macwinmax; k++) {
+		if (! macwins[k].mapped) {
+			continue;
 		}
 		x1 = macwins[k].x;
 		x2 = macwins[k].x + macwins[k].width;
@@ -362,19 +522,38 @@ int macosx_valid_window(Window w, XWindowAttributes* a) {
 	int win = (int) w;
 	int i, k, idx = -1;
 
-	for (i = -1; i<macwinmax; i++) {
-		k = i;
-		if (i == -1)  {
-			if (last_idx >= 0 && last_idx < macwinmax) {
-				k = last_idx;
-			} else {
-				last_idx = -1;
-				continue;
+	if (last_idx >= 0 && last_idx < macwinmax) {
+		if (macwins[last_idx].win == win) {
+			idx = last_idx;
+		}
+	}
+
+	if (idx < 0) {
+		idx = macosxCGS_get_qlook(w);
+		if (idx >= 0 && idx < macwinmax) {
+			if (macwins[idx].win != win) {
+				idx = -1;
 			}
+		} else {
+			idx = -1;
 		}
-		if (macwins[k].win == win) {
-			idx = k;
-			break;
+	}
+
+	if (idx < 0) {
+		for (i = 0; i<macwinmax; i++) {
+			k = i;
+			if (i == -1)  {
+				if (last_idx >= 0 && last_idx < macwinmax) {
+					k = last_idx;
+				} else {
+					last_idx = -1;
+					continue;
+				}
+			}
+			if (macwins[k].win == win) {
+				idx = k;
+				break;
+			}
 		}
 	}
 	if (idx < 0) {
@@ -388,7 +567,11 @@ int macosx_valid_window(Window w, XWindowAttributes* a) {
 	a->depth = depth;
 	a->border_width = 0;
 	a->backing_store = 0;
-	a->map_state = IsViewable;
+	if (macwins[idx].mapped) {
+		a->map_state = IsViewable;
+	} else {
+		a->map_state = IsUnmapped;
+	}
 
 	last_idx = idx;
 	
@@ -415,6 +598,7 @@ Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return,
 	n = 0;
 	for (k = CGS_levelmax - 1; k >= 0; k--) {
 		for (i = macwinmax - 1; i >= 0; i--) {
+			if (n >= QTMAX) break;
 			if (macwins[i].level == CGS_levels[k]) {
 if (0) fprintf(stderr, "k=%d i=%d n=%d\n", k, i, n);
 				cret[n++] = (Window) macwins[i].win;
@@ -427,5 +611,81 @@ if (0) fprintf(stderr, "k=%d i=%d n=%d\n", k, i, n);
 	return (Status) 1;
 }
 
+int macosx_check_offscreen(int win) {
+	sraRegionPtr r0, r1;
+	int x1, y1, x2, y2;
+	int ret;
+	int i = macosxCGS_find_index(win);
+
+	if (i < 0) {
+		return 0;
+	}
+
+	x1 = macwins[i].x;
+	y1 = macwins[i].y;
+	x2 = macwins[i].x + macwins[i].width;
+	y2 = macwins[i].y + macwins[i].height;
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r1 = sraRgnCreateRect(x1, y1, x2, y2);
+
+	if (sraRgnAnd(r1, r0)) {
+		ret = 0;
+	} else {
+		ret = 1;
+	}
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r1);
+
+	return ret;
+}
+
+int macosx_check_clipped(int win, int *list, int n) {
+	sraRegionPtr r0, r1, r2;
+	int x1, y1, x2, y2;
+	int ret = 0;
+	int k, j, i = macosxCGS_find_index(win);
+
+	if (i < 0) {
+		return 0;
+	}
+
+	x1 = macwins[i].x;
+	y1 = macwins[i].y;
+	x2 = macwins[i].x + macwins[i].width;
+	y2 = macwins[i].y + macwins[i].height;
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r1 = sraRgnCreateRect(x1, y1, x2, y2);
+	sraRgnAnd(r1, r0);
+
+	for (k = 0; k < n; k++) {
+		j = macosxCGS_find_index(list[k]);	/* XXX slow? */
+		if (j < 0) {
+			continue;
+		}
+		x1 = macwins[j].x;
+		y1 = macwins[j].y;
+		x2 = macwins[j].x + macwins[j].width;
+		y2 = macwins[j].y + macwins[j].height;
+		r2 = sraRgnCreateRect(x1, y1, x2, y2);
+		if (sraRgnAnd(r2, r1)) {
+			ret = 1;
+			sraRgnDestroy(r2);
+//fprintf(stderr, "macosx_check_clipped: %4d %4d -- CLIP\n", win, list[k]);
+			break;
+		}
+//fprintf(stderr, "macosx_check_clipped: %4d %4d -- -no-\n", win, list[k]);
+		sraRgnDestroy(r2);
+	}
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r1);
+
+//fprintf(stderr, "macosx_check_clipped: %4d      -- CLIP: %s\n", win, ret ? "yes" : "no");
+
+	return ret;
+}
+
+
 #endif 	/* LIBVNCSERVER_HAVE_MACOSX_NATIVE_DISPLAY */
 
diff --git a/x11vnc/macosx.h b/x11vnc/macosx.h
index 42470d74ca5f74eb6533beb9a65a893bbe9be2a0..1ff0b692c8d7bf3e6c1acfd7e9f864025419f344 100644
--- a/x11vnc/macosx.h
+++ b/x11vnc/macosx.h
@@ -16,6 +16,13 @@ extern Status macosx_xquerytree(Window w, Window *root_return, Window *parent_re
 extern void macosx_send_sel(char *, int);
 extern void macosx_set_sel(char *, int);
 
+extern void macosx_add_mapnotify(Window win, int level, int map);
+extern void macosx_add_create(Window win, int level);
+extern void macosx_add_destroy(Window win, int level);
+extern void macosx_add_visnotify(Window win, int level, int obscured);
+extern int macosx_checkevent(XEvent *ev);
+
+extern Window macosx_click_frame;
 
 
 #endif /* _X11VNC_MACOSX_H */
diff --git a/x11vnc/macosxCGS.c b/x11vnc/macosxCGS.c
index 0bc5f1b26346108038ee1025afd6e0f2202b61d3..a7232425dfcd665e27e2ecafba643fc58598b06e 100644
--- a/x11vnc/macosxCGS.c
+++ b/x11vnc/macosxCGS.c
@@ -15,6 +15,7 @@
 extern CGDirectDisplayID displayID;
 
 void macosxCGS_get_all_windows(void);
+int macosxCGS_get_qlook(int);
 void macosxGCS_set_pasteboard(char *str, int len);
 
 typedef CGError       CGSError;
@@ -31,6 +32,10 @@ extern CGSError CGSGetOnScreenWindowList (CGSConnectionID cid,
     CGSConnectionID owner, CGSWindowCount listCapacity,
     CGSWindowIDList list, CGSWindowCount *listCount);
 
+extern CGSError CGSGetWindowList (CGSConnectionID cid,
+    CGSConnectionID owner, CGSWindowCount listCapacity,
+    CGSWindowIDList list, CGSWindowCount *listCount);
+
 extern CGSError CGSGetScreenRectForWindow (CGSConnectionID cid,
     CGSWindowID wid, CGSRect *rect);
 
@@ -54,40 +59,181 @@ typedef struct windat {
 	int x, y;
 	int width, height;
 	int level;
+	int mapped;
+	int clipped;
+	int ncache_only;
 } windat_t;
 
-#define MAXWINDAT 2048
+extern int ncache;
+
+#define MAXWINDAT 4096
 windat_t macwins[MAXWINDAT]; 
-static CGSWindowID _wins[MAXWINDAT]; 
+static CGSWindowID _wins_all[MAXWINDAT]; 
+static CGSWindowID _wins_mapped[MAXWINDAT]; 
+static CGSWindowCount _wins_all_cnt, _wins_mapped_cnt; 
+static int _wins_int[MAXWINDAT]; 
+
+#define WINHISTNUM 32768
+#define WINHISTMAX 4
+char whist[WINHISTMAX][WINHISTNUM];
+int whist_idx = -1;
+int qlook[WINHISTNUM];
+
+char is_exist     = 0x1;
+char is_mapped    = 0x2;
+char is_clipped   = 0x4;
+char is_offscreen = 0x8;
 
 extern double dnow(void);
+extern double dnowx(void);
 
 extern int dpy_x, dpy_y;
+extern int macosx_icon_anim_time;
 
+extern void macosx_add_mapnotify(int, int, int);
+extern void macosx_add_create(int, int);
+extern void macosx_add_destroy(int, int);
+extern void macosx_add_visnotify(int, int, int);
 
 int CGS_levelmax;
 int CGS_levels[16];
 
+int macosxCGS_get_qlook(int w) {
+	if (w >= WINHISTNUM) {
+		return -1;
+	}
+	return qlook[w];
+}
+
+int macosxCGS_find_index(int w) {
+	static int last_index = -1;
+	int idx;
+
+	if (last_index >= 0) {
+		if (macwins[last_index].win == w) {
+			return last_index;
+		}
+	}
+
+	idx = macosxCGS_get_qlook(w);
+	if (idx >= 0) {
+		if (macwins[idx].win == w) {
+			last_index = idx;
+			return idx;
+		}
+	}
+
+	for (idx=0; idx < macwinmax; idx++) {
+		if (macwins[idx].win == w) {
+			last_index = idx;
+			return idx;
+		}
+	}
+	return -1;
+}
+
+int macosxCGS_follow_animation_win(int win, int idx, int grow) {
+	double t = dnow();
+	int diffs = 0;
+	int x, y, w, h;
+	int xp, yp, wp, hp;
+	CGSRect rect;
+	CGSError err; 
+
+	int reps = 0;
+
+	if (cid == NULL) {
+		cid = _CGSDefaultConnection();
+		if (cid == NULL) {
+			return 0;
+		}
+	}
+
+	if (idx < 0) {
+		idx = macosxCGS_find_index(win); 
+	}
+	if (idx < 0) {
+		return 0;
+	}
+
+	while (dnow() < t + 0.001 * macosx_icon_anim_time)  {
+		err = CGSGetScreenRectForWindow(cid, win, &rect);
+		if (err != 0) {
+			break;
+		}
+		x = (int) rect.origin.x;
+		y = (int) rect.origin.y;
+		w = (int) rect.size.width;
+		h = (int) rect.size.height;
+
+		if (grow) {
+			macwins[idx].x      = x;
+			macwins[idx].y      = y;
+			macwins[idx].width  = w;
+			macwins[idx].height = h;
+		}
+	
+		fprintf(stderr, " chase: %03dx%03d+%03d+%03d  %d\n", w, h, x, y, win);
+		if (x == xp && y == yp && w == wp && h == hp)  {
+			reps++;
+			if (reps >= 2) {
+				break;
+			}
+		} else {
+			diffs++;
+			reps = 0;
+		}
+		xp = x;
+		yp = y;
+		wp = w;
+		hp = h;
+		usleep(50 * 1000);
+	}
+	if (diffs >= 2) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
+extern int macosx_check_clipped(int win, int *list, int n);
+extern int macosx_check_offscreen(int win);
+
+static int check_clipped(int win) {
+	int i, n = 0, win2;
+	for (i = 0; i < (int) _wins_mapped_cnt; i++) {
+		win2 = (int) _wins_mapped[i];
+		if (win2 == win) {
+			break;
+		}
+		_wins_int[n++] = win2;
+	}
+	return macosx_check_clipped(win, _wins_int, n);
+}
+
+static int check_offscreen(int win) {
+	return macosx_check_offscreen(win);
+}
+
+extern int macosx_ncache_macmenu;
+
 void macosxCGS_get_all_windows(void) {
 	static double last = 0.0;
-	static int first = 1;
+	static int totcnt = 0;
 	double dt = 0.0, now = dnow();
-	int i, db = 0;
+	int i, db = 0, whist_prv, maxwin = 0, whist_skip = 0;
 	CGSWindowCount cap = (CGSWindowCount) MAXWINDAT;
 	CGSWindowCount cnt = 0;
 	CGSError err; 
 
-	if (first) {
-		first = 0;
-		CGS_levelmax = 0;
-		CGS_levels[CGS_levelmax++] = (int) kCGDraggingWindowLevel;	/* 500 ? */
-		if (0) CGS_levels[CGS_levelmax++] = (int) kCGHelpWindowLevel;		/* 102 ? */
-		if (0) CGS_levels[CGS_levelmax++] = (int) kCGPopUpMenuWindowLevel;	/* 101 pulldown menu */
-		CGS_levels[CGS_levelmax++] = (int) kCGMainMenuWindowLevelKey;	/*  24 ? */
-		CGS_levels[CGS_levelmax++] = (int) kCGModalPanelWindowLevel;	/*   8 open dialog box */
-		CGS_levels[CGS_levelmax++] = (int) kCGFloatingWindowLevel;	/*   3 ? */
-		CGS_levels[CGS_levelmax++] = (int) kCGNormalWindowLevel;	/*   0 regular window */
-	}
+	CGS_levelmax = 0;
+	CGS_levels[CGS_levelmax++] = (int) kCGDraggingWindowLevel;	/* 500 ? */
+	if (0) CGS_levels[CGS_levelmax++] = (int) kCGHelpWindowLevel;		/* 102 ? */
+	if (macosx_ncache_macmenu) CGS_levels[CGS_levelmax++] = (int) kCGPopUpMenuWindowLevel;	/* 101 pulldown menu */
+	CGS_levels[CGS_levelmax++] = (int) kCGMainMenuWindowLevelKey;	/*  24 ? */
+	CGS_levels[CGS_levelmax++] = (int) kCGModalPanelWindowLevel;	/*   8 open dialog box */
+	CGS_levels[CGS_levelmax++] = (int) kCGFloatingWindowLevel;	/*   3 ? */
+	CGS_levels[CGS_levelmax++] = (int) kCGNormalWindowLevel;	/*   0 regular window */
 
 	if (cid == NULL) {
 		cid = _CGSDefaultConnection();
@@ -100,23 +246,38 @@ void macosxCGS_get_all_windows(void) {
 		return;
 	}
 
-	err = CGSGetOnScreenWindowList(cid, NULL, cap, _wins, &cnt);
+	last = now;
+
+	macwinmax = 0; 
 
-if (db) fprintf(stderr, "cnt: %d err: %d\n", cnt, err);
+	totcnt++;
+
+	if (ncache > 0) {
+		whist_prv = whist_idx++;
+		if (whist_prv < 0) {
+			whist_skip = 1;
+			whist_prv = 0;
+		}
+		whist_idx = whist_idx % WINHISTMAX;
+		for (i=0; i < WINHISTNUM; i++) {
+			whist[whist_idx][i] = 0;
+			qlook[i] = -1;
+		}
+	}
+
+	err = CGSGetWindowList(cid, NULL, cap, _wins_all, &_wins_all_cnt);
+
+if (db) fprintf(stderr, "cnt: %d err: %d\n", _wins_all_cnt, err);
 
 	if (err != 0) {
 		return;
 	}
 	
-	last = now;
-
-	macwinmax = 0; 
-
-	for (i=0; i < (int) cnt; i++) {
+	for (i=0; i < (int) _wins_all_cnt; i++) {
 		CGSRect rect;
 		CGSWindowLevel level;
 		int j, keepit = 0;
-		err = CGSGetScreenRectForWindow(cid, _wins[i], &rect);
+		err = CGSGetScreenRectForWindow(cid, _wins_all[i], &rect);
 		if (err != 0) {
 			continue;
 		}
@@ -127,7 +288,7 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", cnt, err);
 				}
 			}
 		}
-		err = CGSGetWindowLevel(cid, _wins[i], &level);
+		err = CGSGetWindowLevel(cid, _wins_all[i], &level);
 		if (err != 0) {
 			continue;
 		}
@@ -142,16 +303,180 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", cnt, err);
 		}
 
 		macwins[macwinmax].level  = (int) level;
-		macwins[macwinmax].win    = (int) _wins[i];
+		macwins[macwinmax].win    = (int) _wins_all[i];
 		macwins[macwinmax].x      = (int) rect.origin.x;
 		macwins[macwinmax].y      = (int) rect.origin.y;
 		macwins[macwinmax].width  = (int) rect.size.width;
 		macwins[macwinmax].height = (int) rect.size.height;
-if (db) fprintf(stderr, "i=%03d ID: %06d  x: %03d  y: %03d  w: %03d h: %03d level: %d\n", i, _wins[i],
+		macwins[macwinmax].mapped = 0;
+		macwins[macwinmax].clipped = 0;
+		macwins[macwinmax].ncache_only = 0;
+		if (level == kCGPopUpMenuWindowLevel) {
+			macwins[macwinmax].ncache_only = 1;
+		}
+
+if (0 || db) fprintf(stderr, "i=%03d ID: %06d  x: %03d  y: %03d  w: %03d h: %03d level: %d\n", i, _wins_all[i],
     (int) rect.origin.x, (int) rect.origin.y,(int) rect.size.width, (int) rect.size.height, (int) level);
 
+		if (macwins[macwinmax].win < WINHISTNUM) {
+			qlook[macwins[macwinmax].win] = macwinmax;
+			if (macwins[macwinmax].win > maxwin) {
+				maxwin = macwins[macwinmax].win;
+			}
+		}
+
 		macwinmax++;
 	}
+
+	err = CGSGetOnScreenWindowList(cid, NULL, cap, _wins_mapped, &_wins_mapped_cnt);
+
+if (db) fprintf(stderr, "cnt: %d err: %d\n", _wins_mapped_cnt, err);
+
+	if (err != 0) {
+		return;
+	}
+	
+	for (i=0; i < (int) _wins_mapped_cnt; i++) {
+		int j, idx = -1;
+		int win = (int) _wins_mapped[i];
+
+		if (0 <= win && win < WINHISTNUM) {
+			j = qlook[win];
+			if (j >= 0 && macwins[j].win == win) {
+				idx = j; 
+			}
+		}
+		if (idx < 0) {
+			for (j=0; j < macwinmax; j++) {
+				if (macwins[j].win == win) {
+					idx = j; 
+					break;
+				}
+			}
+		}
+		if (idx >= 0) {
+			macwins[idx].mapped = 1;
+		}
+	}
+
+	if (ncache > 0) {
+		int nv= 0, NBMAX = 64;
+		int nv_win[64];
+		int nv_lvl[64];
+		int nv_vis[64];
+
+		for (i=0; i < macwinmax; i++) {
+			int win = macwins[i].win;
+			char prev, curr;
+
+			if (win >= WINHISTNUM) {
+				continue;
+			}
+
+			whist[whist_idx][win] |= is_exist;
+			if (macwins[i].mapped) {
+				whist[whist_idx][win] |= is_mapped;
+				if (check_clipped(win)) {
+					whist[whist_idx][win] |= is_clipped;
+					macwins[i].clipped = 1;
+				}
+				if (check_offscreen(win)) {
+					whist[whist_idx][win] |= is_offscreen;
+				}
+			} else {
+				whist[whist_idx][win] |= is_offscreen;
+			}
+
+			curr = whist[whist_idx][win];
+			prev = whist[whist_prv][win];
+
+			if (whist_skip) {
+				;
+			} else if ( !(prev & is_mapped) && (curr & is_mapped)) {
+				/* MapNotify */
+				fprintf(stderr, "MapNotify:   %d/%d  %d               %.4f %d tot=%d\n", prev, curr, win, dnowx(), totcnt); 
+				macosx_add_mapnotify(win, macwins[i].level, 1);
+				//macosxCGS_follow_animation_win(win, i, 1);
+
+			} else if ( !(curr & is_mapped) && (prev & is_mapped)) {
+				/* UnmapNotify */
+				fprintf(stderr, "UnmapNotify: %d/%d  %d               %.4f A tot=%d\n", prev, curr, win, dnowx(), totcnt); 
+				macosx_add_mapnotify(win, macwins[i].level, 0);
+			} else if ( !(prev & is_exist) && (curr & is_exist)) {
+				/* CreateNotify */
+				fprintf(stderr, "CreateNotify:%d/%d  %d               %.4f whist: %d/%d 0x%x tot=%d\n", prev, curr, win, dnowx(), whist_prv, whist_idx, win, totcnt); 
+				macosx_add_create(win, macwins[i].level);
+				if (curr & is_mapped) {
+					fprintf(stderr, "MapNotify:   %d/%d  %d               %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt); 
+					macosx_add_mapnotify(win, macwins[i].level, 1);
+				}
+			}
+			if (whist_skip) {
+				;
+			} else if (nv >= NBMAX) {
+				;
+			} else if (!(curr & is_mapped)) {
+				;
+			} else if (!(prev & is_mapped)) {
+				if (1) {
+					;
+				} else if (curr & is_clipped) {
+					fprintf(stderr, "VisibNotify: %d/%d  %d               OBS tot=%d\n", prev, curr, win, totcnt); 
+					nv_win[nv] = win;
+					nv_lvl[nv] = macwins[i].level;
+					nv_vis[nv++] = 1;
+				} else {
+					fprintf(stderr, "VisibNotify: %d/%d  %d               UNOBS tot=%d\n", prev, curr, win, totcnt); 
+					nv_win[nv] = win;
+					nv_lvl[nv] = macwins[i].level;
+					nv_vis[nv++] = 0;
+				}
+			} else {
+				if        ( !(prev & is_clipped) &&  (curr & is_clipped) ) {
+					fprintf(stderr, "VisibNotify: %d/%d  %d               OBS tot=%d\n", prev, curr, win, totcnt); 
+					nv_win[nv] = win;
+					nv_lvl[nv] = macwins[i].level;
+					nv_vis[nv++] = 1;
+				} else if (  (prev & is_clipped) && !(curr & is_clipped) ) {
+					fprintf(stderr, "VisibNotify: %d/%d  %d               UNOBS tot=%d\n", prev, curr, win, totcnt); 
+					nv_win[nv] = win;
+					nv_lvl[nv] = macwins[i].level;
+					nv_vis[nv++] = 0;
+				}
+			}
+		}
+		for (i=0; i < maxwin; i++) {
+			char prev, curr;
+			int win = i;
+			int q = qlook[i];
+			int lvl = 0;
+
+			if (whist_skip) {
+				break;
+			}
+
+			if (q >= 0) {
+				lvl = macwins[q].level;	
+			}
+			curr = whist[whist_idx][win];
+			prev = whist[whist_prv][win];
+			if (!(curr & is_exist) && (prev & is_exist)) {
+				if (prev & is_mapped) {
+					fprintf(stderr, "UnmapNotify: %d/%d  %d               %.4f B tot=%d\n", prev, curr, win, dnowx(), totcnt); 
+					macosx_add_mapnotify(win, lvl, 0);
+				}
+				/* DestroyNotify */
+				fprintf(stderr, "DestroNotify:%d/%d  %d               %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt); 
+				macosx_add_destroy(win, lvl);
+			}
+		}
+		if (nv) {
+			int k;
+			for (k = 0; k < nv; k++) {
+				macosx_add_visnotify(nv_win[k], nv_lvl[k], nv_vis[k]);
+			}
+		}
+	}
 }
 
 #if 1
diff --git a/x11vnc/macosxCGS.h b/x11vnc/macosxCGS.h
index d53593f37c4bf80a9b2310de8d8f28c630cc24f2..b6b7bb26919a269deba5f880095276cc6e188b40 100644
--- a/x11vnc/macosxCGS.h
+++ b/x11vnc/macosxCGS.h
@@ -4,7 +4,9 @@
 /* -- macosxCGS.h -- */
 
 extern void macosxCGS_get_all_windows(void);
+extern int macosxCGS_get_qlook(int);
 extern void macosxGCS_set_pasteboard(char *str, int len);
+extern int macosxCGS_follow_animation_win(int win, int idx, int grow);
 
 
 #endif /* _X11VNC_MACOSXCGS_H */
diff --git a/x11vnc/options.c b/x11vnc/options.c
index 10dd78902e7cea09dbe2ec126a03ea72b6db9781..a1d597c52034224ba1a6c226e2cdce4b792464f4 100644
--- a/x11vnc/options.c
+++ b/x11vnc/options.c
@@ -137,6 +137,7 @@ int macosx_mouse_wheel_speed = 5;
 int macosx_console = 0;
 int macosx_swap23 = 1;
 int macosx_resize = 1;
+int macosx_icon_anim_time = 450;
 
 unsigned long subwin = 0x0;	/* -id, -sid */
 int subwin_wait_mapped = 0;
@@ -195,6 +196,13 @@ int wireframe_local = 1;
 
 int ncache = 0;
 int ncache0 = 0;
+int ncache_copyrect = 0;
+int macosx_ncache_macmenu = 0;
+#ifdef MACOSX
+int ncache_pad = 24;
+#else
+int ncache_pad = 0;
+#endif
 
 /* T+B+L+R,tkey+presist_key,tmouse+persist_mouse */
 char *scroll_copyrect_str = NULL;
diff --git a/x11vnc/options.h b/x11vnc/options.h
index 016822842c93c344d115877a22e0b61feb999d36..6cd9f704d201c65996ceab29fe2997f3b4e7a139 100644
--- a/x11vnc/options.h
+++ b/x11vnc/options.h
@@ -112,6 +112,7 @@ extern int macosx_mouse_wheel_speed;
 extern int macosx_console;
 extern int macosx_swap23;
 extern int macosx_resize;
+extern int macosx_icon_anim_time;
 
 extern unsigned long subwin;
 extern int subwin_wait_mapped;
@@ -157,6 +158,9 @@ extern int wireframe_in_progress;
 
 extern int ncache;
 extern int ncache0;
+extern int ncache_copyrect;
+extern int ncache_pad;
+extern int macosx_ncache_macmenu;
 
 extern char *scroll_copyrect_str;
 extern char *scroll_copyrect;
diff --git a/x11vnc/pointer.c b/x11vnc/pointer.c
index 83e49d8bcc61a3f305bd0cda922bd6d01e4c356f..df7064b865c0a2d9df6df9244f8fcd999af95162 100644
--- a/x11vnc/pointer.c
+++ b/x11vnc/pointer.c
@@ -816,7 +816,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) {
 			}
 			if (debug_pointer) {
 				rfbLog("pointer(): sending event %d %.4f\n",
-				    i+1, dnow() - x11vnc_start);
+				    i+1, dnowx());
 			}
 			if (ev[i][1] >= 0) {
 				update_x11_pointer_position(ev[i][1], ev[i][2]);
@@ -836,7 +836,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) {
 			if (mask < 0) {
 				if (debug_pointer) {
 					rfbLog("pointer(): calling XFlush "
-					    "%.4f\n", dnow() - x11vnc_start);
+					    "%.4f\n", dnowx());
 				}
 				X_LOCK;
 				XFlush_wr(dpy);	
@@ -853,7 +853,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) {
 	if (mask < 0) {		/* -1 just means flush the event queue */
 		if (debug_pointer) {
 			rfbLog("pointer(): flush only.  %.4f\n",
-			    dnow() - x11vnc_start);
+			    dnowx());
 		}
 		return;
 	}
@@ -885,7 +885,7 @@ void pointer(int mask, int x, int y, rfbClientPtr client) {
 	} else if (buffer_it) {
 		if (debug_pointer) {
 			rfbLog("pointer(): calling XFlush+"
-			    "%.4f\n", dnow() - x11vnc_start);
+			    "%.4f\n", dnowx());
 		}
 		X_LOCK;
 		XFlush_wr(dpy);	
diff --git a/x11vnc/remote.c b/x11vnc/remote.c
index df3b86db57035daca7f7e353b9bd3c8f3d543950..03016d681880f8e3808216fef96c814357622a91 100644
--- a/x11vnc/remote.c
+++ b/x11vnc/remote.c
@@ -765,26 +765,13 @@ char *process_remote_cmd(char *cmd, int stringonly) {
 			sraRegionPtr r;
 			rfbLog("rfbDoCopyRect(screen, %d, %d, %d, %d, %d, %d)\n", x, y, x+w, y+h, dx, dy);
 			r = sraRgnCreateRect(x, y, x+w, y+h);
-			do_copyregion(r, dx, dy);
+			do_copyregion(r, dx, dy, 0);
 			fb_push();
 			sraRgnDestroy(r);
 			rfbLog("did\n");
 		} else {
 			rfbLog("remote_cmd: bad CR string: %s\n", p);
 		}
-	} else if (strstr(p, "ncache") == p) {	/* skip-cmd-list */
-		COLON_CHECK("ncache:")
-		if (query) {
-			snprintf(buf, bufn, "ans=%s%s%d", p, co, ncache);
-			goto qry;
-		}
-		p += strlen("ncache:");
-		ncache = atoi(p);
-		if (ncache % 2 != 0) {
-			ncache++;
-		}
-		rfbLog("remote_cmd: set -ncache %d\n", ncache);
-
 	} else if (!strcmp(p, "stop") || !strcmp(p, "quit") ||
 	    !strcmp(p, "exit") || !strcmp(p, "shutdown")) {
 		NOTAPP
@@ -2746,6 +2733,54 @@ char *process_remote_cmd(char *cmd, int stringonly) {
 		rfbLog("remote_cmd: enabling mouse nodragging mode.\n");
 		show_dragging = 0;
 
+	} else if (!strcmp(p, "ncache_cr")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, ncache_copyrect);
+			goto qry;
+		}
+		ncache_copyrect = 1;
+		rfbLog("remote_cmd: set -ncache_cr %d\n", ncache_copyrect);
+	} else if (!strcmp(p, "noncache_cr")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !ncache_copyrect);
+			goto qry;
+		}
+		ncache_copyrect = 0;
+		rfbLog("remote_cmd: disabled -ncache_cr %d\n", ncache_copyrect);
+
+	} else if (!strcmp(p, "ncache")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !!ncache);
+			goto qry;
+		}
+		ncache = ncache0;
+		rfbLog("remote_cmd: set ncache %d\n", ncache);
+	} else if (!strcmp(p, "noncache")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !ncache);
+			goto qry;
+		}
+		ncache = 0;
+		rfbLog("remote_cmd: disabled ncache %d\n", ncache);
+	} else if (strstr(p, "ncache_size") == p) {
+		int orig = ncache, n;
+		COLON_CHECK("ncache_size:")
+		if (query) {
+			snprintf(buf, bufn, "ans=%s%s%d", p, co, ncache);
+			goto qry;
+		}
+		p += strlen("ncache_size:");
+		n = atoi(p);
+
+		if (n >= 0 && n != ncache) {
+			rfbLog("remote_cmd: setting ncache %d to: %d\n", orig, ncache);
+			ncache = n;
+			do_new_fb(1);
+			if (client_count) {
+				check_ncache(1,0);
+			}
+		}
+
 	} else if (strstr(p, "wireframe_mode") == p) {
 		COLON_CHECK("wireframe_mode:")
 		if (query) {
@@ -3960,13 +3995,84 @@ char *process_remote_cmd(char *cmd, int stringonly) {
 		}
 		rfbLog("remote_cmd: turn on macnosaver.\n");
 		macosx_noscreensaver = 1;
-	} else if (!strcmp(p, "macsaver")) {
+	} else if (!strcmp(p, "macsaver") || !strcmp(p, "nomacnosaver")) {
 		if (query) {
 			snprintf(buf, bufn, "ans=%s:%d", p, !macosx_noscreensaver); goto qry;
 		}
 		rfbLog("remote_cmd: turn off macnosaver.\n");
 		macosx_noscreensaver = 0;
 
+	} else if (!strcmp(p, "macnowait")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !macosx_wait_for_switch); goto qry;
+		}
+		rfbLog("remote_cmd: disable macosx_wait_for_switch.\n");
+		macosx_wait_for_switch = 0;
+	} else if (!strcmp(p, "macwait") || !strcmp(p, "nomacnowait")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, macosx_wait_for_switch); goto qry;
+		}
+		rfbLog("remote_cmd: enable macosx_wait_for_switch.\n");
+		macosx_wait_for_switch = 1;
+
+	} else if (strstr(p, "macwheel") == p) {
+		COLON_CHECK("macwheel:")
+		if (query) {
+			snprintf(buf, bufn, "ans=%s%s%d", p, co, macosx_mouse_wheel_speed);
+			goto qry;
+		}
+		p += strlen("macwheel:");
+		macosx_mouse_wheel_speed = atoi(p);
+		rfbLog("set macosx_mouse_wheel_speed to: %d\n", macosx_mouse_wheel_speed);
+
+	} else if (!strcmp(p, "macnoswap")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !macosx_swap23); goto qry;
+		}
+		rfbLog("remote_cmd: disable macosx_swap23.\n");
+		macosx_swap23 = 0;
+	} else if (!strcmp(p, "macswap") || !strcmp(p, "nomacnoswap")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, macosx_swap23); goto qry;
+		}
+		rfbLog("remote_cmd: enable macosx_swap23.\n");
+		macosx_swap23 = 1;
+
+	} else if (!strcmp(p, "macnoresize")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !macosx_resize); goto qry;
+		}
+		rfbLog("remote_cmd: disable macosx_resize.\n");
+		macosx_resize = 0;
+	} else if (!strcmp(p, "macresize") || !strcmp(p, "nomacnoresize")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, macosx_resize); goto qry;
+		}
+		rfbLog("remote_cmd: enable macosx_resize.\n");
+		macosx_resize = 1;
+
+	} else if (strstr(p, "maciconanim") == p) {
+		COLON_CHECK("maciconanim:")
+		if (query) {
+			snprintf(buf, bufn, "ans=%s%s%d", p, co, macosx_icon_anim_time);
+			goto qry;
+		}
+		p += strlen("maciconanim:");
+		macosx_icon_anim_time = atoi(p);
+		rfbLog("set macosx_icon_anim_time to: %d\n", macosx_icon_anim_time);
+
+	} else if (!strcmp(p, "macmenu")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, macosx_ncache_macmenu); goto qry;
+		}
+		rfbLog("remote_cmd: enable macosx_ncache_macmenu.\n");
+		macosx_ncache_macmenu = 1;
+	} else if (!strcmp(p, "macnomenu") || !strcmp(p, "nomacmenu")) {
+		if (query) {
+			snprintf(buf, bufn, "ans=%s:%d", p, !macosx_ncache_macmenu); goto qry;
+		}
+		rfbLog("remote_cmd: disable macosx_ncache_macmenu.\n");
+		macosx_ncache_macmenu = 0;
 
 	} else if (strstr(p, "hack") == p) { /* skip-cmd-list */
 		COLON_CHECK("hack:")
diff --git a/x11vnc/scan.c b/x11vnc/scan.c
index 6ad24024d1c86f88867b4f8d99737bce877b4323..1251742a65798046f1f2f3423a5aa70f6c4a9b69 100644
--- a/x11vnc/scan.c
+++ b/x11vnc/scan.c
@@ -26,7 +26,7 @@ void initialize_polling_images(void);
 void scale_rect(double factor, int blend, int interpolate, int Bpp,
     char *src_fb, int src_bytes_per_line, char *dst_fb, int dst_bytes_per_line,
     int Nx, int Ny, int nx, int ny, int X1, int Y1, int X2, int Y2, int mark);
-void scale_and_mark_rect(int X1, int Y1, int X2, int Y2);
+void scale_and_mark_rect(int X1, int Y1, int X2, int Y2, int mark);
 void mark_rect_as_modified(int x1, int y1, int x2, int y2, int force);
 int copy_screen(void);
 int copy_snap(void);
@@ -1253,7 +1253,7 @@ some aliases:
 	-90:	+270, 270
  */
 
-void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) {
+void scale_and_mark_rect(int X1, int Y1, int X2, int Y2, int mark) {
 	char *dst_fb, *src_fb = main_fb;
 	int dst_bpl, Bpp = bpp/8, fac = 1;
 
@@ -1290,7 +1290,7 @@ void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) {
 
 	scale_rect(scale_fac, scaling_blend, scaling_interpolate, fac * Bpp,
 	    src_fb, fac * main_bytes_per_line, dst_fb, dst_bpl, dpy_x, dpy_y,
-	    scaled_x, scaled_y, X1, Y1, X2, Y2, 1);
+	    scaled_x, scaled_y, X1, Y1, X2, Y2, mark);
 }
 
 void rotate_coords(int x, int y, int *xo, int *yo, int dxi, int dyi) {
@@ -1308,6 +1308,8 @@ void rotate_coords(int x, int y, int *xo, int *yo, int dxi, int dyi) {
 		Dy = dpy_y;
 	}
 
+	/* ncache?? */
+
 	if (rotating == ROTATE_NONE) {
 		*xo = xi;
 		*yo = yi;
@@ -1625,7 +1627,7 @@ void mark_rect_as_modified(int x1, int y1, int x2, int y2, int force) {
 	}
 
 	if (scaling) {
-		scale_and_mark_rect(x1, y1, x2, y2);
+		scale_and_mark_rect(x1, y1, x2, y2, 1);
 	} else {
 		mark_wrapper(x1, y1, x2, y2);
 	}
@@ -2537,6 +2539,48 @@ if (db && snapcnt++ < 5) rfbLog("rawfb copy_snap took: %.5f secs\n", dnow() - st
 }
 
 
+/* 
+ * debugging: print out a picture of the tiles.
+ */
+static void print_tiles(void) {
+	/* hack for viewing tile diffs on the screen. */
+	static char *prev = NULL;
+	int n, x, y, ms = 1500;
+
+	ms = 1;
+
+	if (! prev) {
+		prev = (char *) malloc((size_t) ntiles);
+		for (n=0; n < ntiles; n++) {
+			prev[n] = 0;
+		}
+	}
+	fprintf(stderr, "   ");
+	for (x=0; x < ntiles_x; x++) {
+		fprintf(stderr, "%1d", x % 10);
+	}
+	fprintf(stderr, "\n");
+	n = 0;
+	for (y=0; y < ntiles_y; y++) {
+		fprintf(stderr, "%2d ", y);
+		for (x=0; x < ntiles_x; x++) {
+			if (tile_has_diff[n]) {
+				fprintf(stderr, "X");
+			} else if (prev[n]) {
+				fprintf(stderr, "o");
+			} else {
+				fprintf(stderr, ".");
+			}
+			n++;
+		}
+		fprintf(stderr, "\n");
+	}
+	for (n=0; n < ntiles; n++) {
+		prev[n] = tile_has_diff[n];
+	}
+	usleep(ms * 1000);
+}
+
 /*
  * Utilities for managing the "naps" to cut down on amount of polling.
  */
@@ -2818,27 +2862,42 @@ static int scan_display(int ystart, int rescan) {
 		X_LOCK;
 
 #ifndef NO_NCACHE
-#if !NO_X11
-if (ncache > 0 && dpy) {
-	/* XXX watch for problems. */
+/* XXX Y test */
+if (ncache > 0) {
 	XEvent ev;
 	int gotone = 0;
-	if (XCheckTypedEvent(dpy, MapNotify, &ev)) {
-		gotone = 1;
-	} else if (XCheckTypedEvent(dpy, UnmapNotify, &ev)) {
-		gotone = 2;
-	} else if (XCheckTypedEvent(dpy, CreateNotify, &ev)) {
-		gotone = 3;
+	if (macosx_console) {
+		if (macosx_checkevent(NULL)) {
+			gotone = 1;
+		}
+	} else {
+#if !NO_X11
+		if (XCheckTypedEvent(dpy, MapNotify, &ev)) {
+			gotone = 1;
+		} else if (XCheckTypedEvent(dpy, UnmapNotify, &ev)) {
+			gotone = 2;
+		} else if (XCheckTypedEvent(dpy, CreateNotify, &ev)) {
+			gotone = 3;
+		}
+		if (gotone) {
+			XPutBackEvent(dpy, &ev);
+		}
+#endif
 	}
 	if (gotone) {
-		XPutBackEvent(dpy, &ev);
+		static int nomsg = 1;
+		if (nomsg) {
+			if (dnowx() > 20) {
+				nomsg = 0;
+			}
+		} else {
+fprintf(stderr, "*** SCAN_DISPLAY CHECK_NCACHE/%d *** %d rescan=%d\n", gotone, y, rescan);
+		}
 		X_UNLOCK;
-fprintf(stderr, "*** SCAN_DISPLAY CHECK_NCACHE/%d *** %d\n", gotone, y);
-		check_ncache(0);
+		check_ncache(0, 1);
 		X_LOCK;
 	}
 }
-#endif
 #endif
 
 		XRANDR_SET_TRAP_RET(-1, "scan_display-set");
@@ -2936,6 +2995,7 @@ int scan_for_updates(int count_only) {
 	double frac2 = 0.35;  /* or 3rd */
 	double frac3 = 0.02;  /* do scan_display() again after copy_tiles() */
 	static double last_poll = 0.0;
+	double dtmp;
 
 	if (unixpw_in_progress) return 0;
  
@@ -3007,6 +3067,7 @@ int scan_for_updates(int count_only) {
 	/* scan with the initial y to the jitter value from scanlines: */
 	scan_in_progress = 1;
 	tile_count = scan_display(scanlines[scan_count], 0);
+//if (tile_count) fprintf(stderr, "XX tile_countA: %d\n", tile_count);
 	SCAN_FATAL(tile_count);
 
 	/*
@@ -3069,12 +3130,14 @@ int scan_for_updates(int count_only) {
 			cp = (NSCAN - scan_count) % NSCAN;
 
 			tile_count = scan_display(scanlines[cp], 1);
+//fprintf(stderr, "XX tile_countB: %d\n", tile_count);
 			SCAN_FATAL(tile_count);
 
 			if (tile_count >= (1 + frac2) * tile_count_old) {
 				/* on a roll... do a 3rd scan */
 				cp = (NSCAN - scan_count + 7) % NSCAN;
 				tile_count = scan_display(scanlines[cp], 1);
+//fprintf(stderr, "XX tile_countC: %d\n", tile_count);
 				SCAN_FATAL(tile_count);
 			}
 		}
@@ -3127,6 +3190,9 @@ int scan_for_updates(int count_only) {
 	}
 
 	if (unixpw_in_progress) return 0;
+/* XXX Y */
+if (0 && tile_count > 20) print_tiles();
+//dtmp = dnow();
 
 	if (old_copy_tile) {
 		tile_diffs = copy_all_tiles();
@@ -3134,6 +3200,7 @@ int scan_for_updates(int count_only) {
 		tile_diffs = copy_all_tile_runs();
 	}
 	SCAN_FATAL(tile_diffs);
+//if (tile_count) fprintf(stderr, "XX copytile: %.4f  tile_count: %d\n", dnow() - dtmp, tile_count);
 
 	/*
 	 * This backward pass for upward and left tiles complements what
diff --git a/x11vnc/scan.h b/x11vnc/scan.h
index 98bd14808ba94f3e6d81b927cbe0f6036db265b3..c0b17cbb52323b7d7a330839483e01d677a0469e 100644
--- a/x11vnc/scan.h
+++ b/x11vnc/scan.h
@@ -14,7 +14,7 @@ extern void initialize_polling_images(void);
 extern void scale_rect(double factor, int blend, int interpolate, int Bpp,
     char *src_fb, int src_bytes_per_line, char *dst_fb, int dst_bytes_per_line,
     int Nx, int Ny, int nx, int ny, int X1, int Y1, int X2, int Y2, int mark);
-extern void scale_and_mark_rect(int X1, int Y1, int X2, int Y2);
+extern void scale_and_mark_rect(int X1, int Y1, int X2, int Y2, int mark);
 extern void mark_rect_as_modified(int x1, int y1, int x2, int y2, int force);
 extern int copy_screen(void);
 extern int copy_snap(void);
diff --git a/x11vnc/screen.c b/x11vnc/screen.c
index 57244a50cf49bf89d366fcc74e13d2ad815b0754..7b583faffdcf61813fe47e2484015237eeee038e 100644
--- a/x11vnc/screen.c
+++ b/x11vnc/screen.c
@@ -701,6 +701,7 @@ void free_old_fb(void) {
 
 void do_new_fb(int reset_mem) {
 	XImage *fb;
+	int i;
 
 	/* for threaded we really should lock libvncserver out. */
 	if (use_threads) {
@@ -725,7 +726,6 @@ void do_new_fb(int reset_mem) {
 		initialize_blackouts_and_xinerama();
 		initialize_polling_images();
 	}
-
 }
 
 static void remove_fake_fb(void) {
@@ -2035,18 +2035,25 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
 
 #ifndef NO_NCACHE
 	if (ncache > 0) {
-		char *new_fb;
-		int sz = fb->height * fb->bytes_per_line;
-
-		new_fb = (char *) calloc((size_t) (sz * (1+ncache)), 1);
-		if (fb->data) {
-			memcpy(new_fb, fb->data, sz);
-			free(fb->data);
-		}
-		fb->data = new_fb;
-		fb->height *= (1+ncache);
-		height *= (1+ncache);
-		ncache0 = ncache;
+#ifdef MACOSX
+		if (! raw_fb_str || macosx_console) {
+#else
+		if (! raw_fb_str) {
+#endif
+			
+			char *new_fb;
+			int sz = fb->height * fb->bytes_per_line;
+
+			new_fb = (char *) calloc((size_t) (sz * (1+ncache)), 1);
+			if (fb->data) {
+				memcpy(new_fb, fb->data, sz);
+				free(fb->data);
+			}
+			fb->data = new_fb;
+			fb->height *= (1+ncache);
+			height *= (1+ncache);
+			ncache0 = ncache;
+		}
 	}
 #endif
 
diff --git a/x11vnc/tkx11vnc b/x11vnc/tkx11vnc
index d81bb375c5eda8ae44e158812e3ff8c972cda2e4..6974778b7cecab644adc49f850b3e04264052940 100755
--- a/x11vnc/tkx11vnc
+++ b/x11vnc/tkx11vnc
@@ -240,6 +240,15 @@ Misc
 	xrecord
 	=RQA reset_record
 	=GAL LOFF
+	=GAL MacOSX::
+	macnosaver
+	macnowait
+	macwheel:
+	macnoswap
+	macnoresize
+	maciconanim:
+	macmenu
+	=GAL LOFF
 	--
 	nofb
 	=D nobell
@@ -370,7 +379,12 @@ Tuning
 	threads
 	wmdt:
 	rfbwait:
+	nodpms
 	nofbpm
+	--
+	ncache
+	ncache_size:
+	ncache_cr
 	=GAL LOFF
 "
 }
diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h
index 3bf4e03488369e6e62e07a084afea6392bcf3fc6..593637e974c35eb6d13aa6dc4349fa77a093c223 100644
--- a/x11vnc/tkx11vnc.h
+++ b/x11vnc/tkx11vnc.h
@@ -251,6 +251,15 @@ char gui_code[] = "";
 "	xrecord\n"
 "	=RQA reset_record\n"
 "	=GAL LOFF\n"
+"	=GAL MacOSX::\n"
+"	macnosaver\n"
+"	macnowait\n"
+"	macwheel:\n"
+"	macnoswap\n"
+"	macnoresize\n"
+"	maciconanim:\n"
+"	macmenu\n"
+"	=GAL LOFF\n"
 "	--\n"
 "	nofb\n"
 "	=D nobell\n"
@@ -381,7 +390,12 @@ char gui_code[] = "";
 "	threads\n"
 "	wmdt:\n"
 "	rfbwait:\n"
+"	nodpms\n"
 "	nofbpm\n"
+"	--\n"
+"	ncache\n"
+"	ncache_size:\n"
+"	ncache_cr\n"
 "	=GAL LOFF\n"
 "\"\n"
 "}\n"
diff --git a/x11vnc/userinput.c b/x11vnc/userinput.c
index 60fa75daedb3c21ce72003df354ab51c58bbdcb7..31f186447c74da12b5b444360028d7ec4d1e559e 100644
--- a/x11vnc/userinput.c
+++ b/x11vnc/userinput.c
@@ -16,6 +16,8 @@
 #include "xrandr.h"
 #include "8to24.h"
 #include "unixpw.h"
+#include "macosx.h"
+#include "macosxCGS.h"
 
 /*
  * user input handling heuristics
@@ -39,7 +41,7 @@ void initialize_max_keyrepeat(void);
 
 int direct_fb_copy(int x1, int y1, int x2, int y2, int mark);
 void fb_push(void);
-void fb_push_wait(double max_wait, int flags);
+int fb_push_wait(double max_wait, int flags);
 void eat_viewonly_input(int max_eat, int keep);
 
 void mark_for_xdamage(int x, int y, int w, int h);
@@ -53,7 +55,7 @@ int check_xrecord(void);
 int check_wireframe(void);
 int fb_update_sent(int *count);
 int check_user_input(double dt, double dtr, int tile_diffs, int *cnt);
-void do_copyregion(sraRegionPtr region, int dx, int dy);
+void do_copyregion(sraRegionPtr region, int dx, int dy, int mode);
 
 static void get_client_regions(int *req, int *mod, int *cpy, int *num) ;
 static void parse_scroll_copyrect_str(char *scr);
@@ -63,9 +65,9 @@ static void draw_box(int x, int y, int w, int h, int restore);
 static int do_bdpush(Window wm_win, int x0, int y0, int w0, int h0, int bdx,
     int bdy, int bdskinny);
 static int set_ypad(void);
-static void scale_mark(int x1, int y1, int x2, int y2);
+static void scale_mark(int x1, int y1, int x2, int y2, int mark);
 static int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy,
-    int bdskinny);
+    int bdskinny, int first_push);
 static int crfix(int x, int dx, int Lx);
 static int scrollability(Window win, int set);
 static int eat_pointer(int max_ptr_eat, int keep);
@@ -74,7 +76,7 @@ static int repeat_check(double last_key_scroll);
 static int check_xrecord_keys(void);
 static int check_xrecord_mouse(void);
 static int try_copyrect(Window frame, int x, int y, int w, int h, int dx, int dy,
-    int *obscured, sraRegionPtr extra_clip, double max_wait);
+    int *obscured, sraRegionPtr extra_clip, double max_wait, int *nbatch);
 static int wireframe_mod_state();
 static void check_user_input2(double dt);
 static void check_user_input3(double dt, double dtr, int tile_diffs);
@@ -1336,13 +1338,13 @@ static int set_ypad(void) {
 	return y_accum;
 }
 
-static void scale_mark(int x1, int y1, int x2, int y2) {
+static void scale_mark(int x1, int y1, int x2, int y2, int mark) {
 	int s = 2;
 	x1 = nfix(x1 - s, dpy_x);
 	y1 = nfix(y1 - s, dpy_y);
 	x2 = nfix(x2 + s, dpy_x+1);
 	y2 = nfix(y2 + s, dpy_y+1);
-	scale_and_mark_rect(x1, y1, x2, y2);
+	scale_and_mark_rect(x1, y1, x2, y2, mark);
 }
 
 #define PUSH_TEST(n)  \
@@ -1353,8 +1355,12 @@ if (n) { \
 	fprintf(stderr, "---PUSH\n"); \
 }
 
+int batch_dxs[], batch_dys[];
+sraRegionPtr batch_reg[];
+void batch_copyregion(sraRegionPtr* region, int *dx, int *dy, int ncr, double delay);
+
 static int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy,
-    int bdskinny) {
+    int bdskinny, int first_push) {
 	Window frame, win, win0;
 	int x, y, w, h, wx, wy, ww, wh, dx, dy;
 	int x0, y0, w0, h0;
@@ -1368,6 +1374,7 @@ static int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy,
 	int link, latency, netrate;
 	int ypad = 0;
 	double last_scroll_event_save = last_scroll_event;
+	int fast_push = 0, rc;
 
 	/* we return the oldest one. */
 	*age = 0.0;
@@ -1403,7 +1410,7 @@ static int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy,
 
 	ypad = set_ypad();
 
-if (db) fprintf(stderr, "ypad: %d  dy[0]: %d\n", ypad, scr_ev[0].dy);
+if (db) fprintf(stderr, "ypad: %d  dy[0]: %d ev_tot: %d\n", ypad, scr_ev[0].dy, ev_tot);
 
 	for (ev=0; ev < ev_tot; ev++) {
 		double ag;
@@ -1545,19 +1552,39 @@ if (db > 1) fprintf(stderr, "------------ got: %d x: %4d y: %3d"
 				}
 			}
 		}
-		
-		if (try_copyrect(frame, x, y, w, h, dx, dy, &obscured,
-		    tmpregion, waittime)) {
-			last_scroll_type = type;
-			dtime0(&last_scroll_event);
 
-			do_fb_push++;
-			urgent_update = 1;
-			sraRgnDestroy(tmpregion);
-			
-PUSH_TEST(0);
+		if (fast_push) {
+			int k, nbatch = 0; 
+			double delay, d1 = 0.1, d2 = 0.02;
+			rc = try_copyrect(frame, x, y, w, h, dx, dy, &obscured,
+			    tmpregion, waittime, &nbatch);
+
+			if (first_push) {
+				delay = d1;
+			} else {
+				delay = d2;
+			}
 
+			batch_copyregion(batch_reg, batch_dxs, batch_dys, nbatch, delay);
+			for (k=0; k < nbatch; k++) {
+				sraRgnDestroy(batch_reg[k]);
+			}
+			fb_push();
 		} else {
+			rc = try_copyrect(frame, x, y, w, h, dx, dy, &obscured,
+			    tmpregion, waittime, NULL);
+			if (rc) {
+				last_scroll_type = type;
+				dtime0(&last_scroll_event);
+
+				do_fb_push++;
+				urgent_update = 1;
+				sraRgnDestroy(tmpregion);
+PUSH_TEST(0);
+			}
+		}
+
+		if (! rc) {
 			dret = 0;
 			sraRgnDestroy(tmpregion);
 			break;	
@@ -1661,6 +1688,10 @@ if (db) fprintf(stderr, "  EST_TOO_LARGE");
 				dtime(&tm);
 if (db) fprintf(stderr, "  DFC(%d,%d-%d,%d)", tx1, ty1, tx2, ty2);
 				direct_fb_copy(tx1, ty1, tx2, ty2, 1);
+				if (fast_push) {
+					fb_push();
+				}
+//fb_push();
 				do_fb_push++;
 PUSH_TEST(0);
 			}
@@ -1685,6 +1716,9 @@ if (db && bdpush) fprintf(stderr, "BDPUSH-TIME:  0x%lx\n", xrecord_wm_window);
 		h = scr_ev[0].h;
 		do_fb_push += do_bdpush(xrecord_wm_window, x, y, w, h,
 		    bdx, bdy, bdskinny); 
+		if (fast_push) {
+			fb_push();
+		}
 	}
 
 	if (do_fb_push) {
@@ -1721,7 +1755,7 @@ if (0) fprintf(stderr, "  fb_push dt: %.4f", dt);
 				 */
 			} else if (now > last_time + delay) {
 
-				scale_mark(x0, y0, x0 + w0, y0 + h0);
+				scale_mark(x0, y0, x0 + w0, y0 + h0, 1);
 				last_copyrect_fix = now;
 			}
 			last_time = now;
@@ -1758,7 +1792,11 @@ static void get_client_regions(int *req, int *mod, int *cpy, int *num)  {
  * is being done.  Note that copyrect under the scaling case is often
  * only approximate.
  */
-void do_copyregion(sraRegionPtr region, int dx, int dy)  {
+int DCR_Normal = 0;
+int DCR_FBOnly = 1;
+int DCR_Direct = 2;
+
+void do_copyregion(sraRegionPtr region, int dx, int dy, int mode)  {
 	sraRectangleIterator *iter;
 	sraRect rect;
 	int Bpp0 = bpp/8, Bpp;
@@ -1769,14 +1807,15 @@ void do_copyregion(sraRegionPtr region, int dx, int dy)  {
 
 	last_copyrect = dnow();
 
-	if (rfb_fb == main_fb && ! rotating) {
+	if (rfb_fb == main_fb && ! rotating && mode == DCR_Normal) {
 		/* normal case, no -scale or -8to24 */
 		get_client_regions(&req, &mod, &cpy, &ncli);
-if (debug_scroll > 1) fprintf(stderr, "<<<-rfbDoCopyRect req: %d mod: %d cpy: %d\n", req, mod, cpy); 
+if (debug_scroll > 1) fprintf(stderr, ">>>-rfbDoCopyRect req: %d mod: %d cpy: %d\n", req, mod, cpy); 
+
 		rfbDoCopyRegion(screen, region, dx, dy);
 
 		get_client_regions(&req, &mod, &cpy, &ncli);
-if (debug_scroll > 1) fprintf(stderr, ">>>-rfbDoCopyRect req: %d mod: %d cpy: %d\n", req, mod, cpy); 
+if (debug_scroll > 1) fprintf(stderr, "<<<-rfbDoCopyRect req: %d mod: %d cpy: %d\n", req, mod, cpy); 
 
 		return;
 	}
@@ -1786,14 +1825,13 @@ if (debug_scroll > 1) fprintf(stderr, ">>>-rfbDoCopyRect req: %d mod: %d cpy: %d
 
 	iter = sraRgnGetReverseIterator(region, dx < 0, dy < 0);
 	while(sraRgnIteratorNext(iter, &rect)) {
-		int j, c, t;
+		int j, c, t, Dx, Dy;
 
 		x1 = rect.x1;
 		y1 = rect.y1;
 		x2 = rect.x2;
 		y2 = rect.y2;
 
-
 		for (c= 0; c < 2; c++) {
 
 			Bpp = Bpp0;
@@ -1834,6 +1872,10 @@ if (debug_scroll > 1) fprintf(stderr, ">>>-rfbDoCopyRect req: %d mod: %d cpy: %d
 			}
 		}
 
+		if (mode == DCR_FBOnly) {
+			continue;
+		}
+
 
 		if (scaling) {
 			sx1 = ((double) x1 / dpy_x) * scaled_x;
@@ -1851,6 +1893,7 @@ if (debug_scroll > 1) fprintf(stderr, ">>>-rfbDoCopyRect req: %d mod: %d cpy: %d
 			sdy = dy;
 		}
 if (0) fprintf(stderr, "s... %d %d %d %d %d %d\n", sx1, sy1, sx2, sy2, sdx, sdy);
+
 		if (rotating) {
 			rotate_coords(sx1, sy1, &sx1, &sy1, -1, -1);
 			rotate_coords(sx2, sy2, &sx2, &sy2, -1, -1);
@@ -1879,6 +1922,11 @@ if (0) fprintf(stderr, "s... %d %d %d %d %d %d\n", sx1, sy1, sx2, sy2, sdx, sdy)
 				sdy = -t;
 			}
 		}
+
+		/* XXX -1? */
+		if (sx2 < 0) sx2 = 0;
+		if (sy2 < 0) sy2 = 0;
+		
 		if (sx2 < sx1) {
 			t = sx1;
 			sx1 = sx2;
@@ -1891,12 +1939,80 @@ if (0) fprintf(stderr, "s... %d %d %d %d %d %d\n", sx1, sy1, sx2, sy2, sdx, sdy)
 		}
 if (0) fprintf(stderr, "s... %d %d %d %d %d %d\n", sx1, sy1, sx2, sy2, sdx, sdy);
 
-		rfbDoCopyRect(screen, sx1, sy1, sx2, sy2, sdx, sdy);
+		if (mode == DCR_Direct) {
+			rfbClientIteratorPtr i;
+			rfbClientPtr cl;
+			sraRegionPtr r = sraRgnCreateRect(sx1, sy1, sx2, sy2);
+
+			i = rfbGetClientIterator(screen);
+			while( (cl = rfbClientIteratorNext(i)) ) {
+				rfbSendCopyRegion(cl, r, sdx, sdy);
+			}
+			rfbReleaseClientIterator(i);
+			sraRgnDestroy(r);
+			
+		} else {
+			rfbDoCopyRect(screen, sx1, sy1, sx2, sy2, sdx, sdy);
+		}
 	}
 	sraRgnReleaseIterator(iter);
 }
 
-void fb_push(void) {
+void batch_copyregion(sraRegionPtr* region, int *dx, int *dy, int ncr, double delay)  {
+	rfbClientIteratorPtr i;
+	rfbClientPtr cl;
+	int k, direct, mode, nrects = 0;
+	int hid_cursor = 0;
+
+/* XXX Y */
+
+	if (delay < 0.0) {
+		delay = 0.1;
+	}
+	fb_push_wait(delay, FB_COPY|FB_MOD);
+
+	for (k=0; k < ncr; k++) {
+		nrects += sraRgnCountRects(region[k]);
+	}
+
+	i = rfbGetClientIterator(screen);
+	while( (cl = rfbClientIteratorNext(i)) ) {
+		rfbFramebufferUpdateMsg *fu = (rfbFramebufferUpdateMsg *)cl->updateBuf;
+		fu->nRects = Swap16IfLE((uint16_t)(nrects));
+		fu->type = rfbFramebufferUpdate;
+
+		if (cl->ublen != 0) fprintf(stderr, "batch_copyregion: *** ublen != 0: %d\n", cl->ublen);
+
+		cl->ublen = sz_rfbFramebufferUpdateMsg;
+	}
+	rfbReleaseClientIterator(i);
+
+	if (rfb_fb == main_fb && !rotating) {
+		direct = 0;
+		mode = DCR_FBOnly;
+	} else {
+		direct = 1;
+		mode = DCR_Direct;
+	}
+	for (k=0; k < ncr; k++) {
+		do_copyregion(region[k], dx[k], dy[k], mode);
+	}
+	i = rfbGetClientIterator(screen);
+	while( (cl = rfbClientIteratorNext(i)) ) {
+		if (!direct)  {
+			for (k=0; k < ncr; k++) {
+				rfbSendCopyRegion(cl, region[k], dx[k], dy[k]);
+			}
+		}
+		rfbSendUpdateBuf(cl);
+	}
+	rfbReleaseClientIterator(i);
+
+fprintf(stderr, "batch_copyregion: nrects: %d nregions: %d\n", nrects, ncr);
+
+}
+
+void fb_push0(void) {
 	char *httpdir = screen->httpDir;
 	int defer = screen->deferUpdateTime;
 	int req0, mod0, cpy0, req1, mod1, cpy1, ncli;
@@ -1912,17 +2028,51 @@ if (db)	get_client_regions(&req0, &mod0, &cpy0, &ncli);
 	screen->httpDir = httpdir;
 	screen->deferUpdateTime = defer;
 
- if (db) {
+if (db) {
 	get_client_regions(&req1, &mod1, &cpy1, &ncli);
 	fprintf(stderr, "\nFB_push: req: %d/%d  mod: %d/%d  cpy: %d/%d  %.4f\n",
-	req0, req1, mod0, mod1, cpy0, cpy1, dnow() - x11vnc_start);
- }
+	req0, req1, mod0, mod1, cpy0, cpy1, dnowx());
+}
+
+}
+
+void fb_push(void) {
+	int req0, mod0, cpy0, req1, mod1, cpy1, ncli;
+	int db = (debug_scroll || debug_wireframe);
+	rfbClientIteratorPtr i;
+	rfbClientPtr cl;
+	
+/* XXX Y */
+db = 0;
+
+if (db)	get_client_regions(&req0, &mod0, &cpy0, &ncli);
+
+	i = rfbGetClientIterator(screen);
+	while( (cl = rfbClientIteratorNext(i)) ) {
+		if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) &&
+		    !sraRgnEmpty(cl->requestedRegion)) {
+			if (!rfbSendFramebufferUpdate(cl, cl->modifiedRegion)) {
+				fprintf(stderr, "*** rfbSendFramebufferUpdate FAILED #1\n");
+				if (cl->ublen) fprintf(stderr, "*** fb_push ublen not zero: %d\n", cl->ublen);
+				break;
+			}
+			if (cl->ublen) fprintf(stderr, "*** fb_push ublen not zero: %d\n", cl->ublen);
+		}
+	}
+	rfbReleaseClientIterator(i);
+
+if (db) {
+	get_client_regions(&req1, &mod1, &cpy1, &ncli);
+	fprintf(stderr, "\nFB_push: req: %d/%d  mod: %d/%d  cpy: %d/%d  %.4f\n",
+	req0, req1, mod0, mod1, cpy0, cpy1, dnowx());
+}
 
 }
 
-void fb_push_wait(double max_wait, int flags) {
+int fb_push_wait0(double max_wait, int flags) {
 	double tm, dt = 0.0;
 	int req, mod, cpy, ncli;
+	int ok = 0;
 
 	dtime0(&tm);	
 	while (dt < max_wait) {
@@ -1939,6 +2089,7 @@ void fb_push_wait(double max_wait, int flags) {
 			done = 0;
 		}
 		if (done) {
+			ok = 1;
 			break;
 		}
 
@@ -1946,6 +2097,42 @@ void fb_push_wait(double max_wait, int flags) {
 		fb_push();
 		dt += dtime(&tm);
 	}
+	return ok;
+}
+
+int fb_push_wait(double max_wait, int flags) {
+	double tm, dt = 0.0;
+	int req, mod, cpy, ncli;
+	int ok = 0, first = 1;
+
+	dtime0(&tm);	
+	while (dt < max_wait) {
+		int done = 1;
+		fb_push();
+		get_client_regions(&req, &mod, &cpy, &ncli);
+		if (flags & FB_COPY && cpy) {
+			done = 0;
+		}
+		if (flags & FB_MOD && mod) {
+			done = 0;
+		}
+		if (flags & FB_REQ && req) {
+			done = 0;
+		}
+		if (done) {
+			ok = 1;
+			break;
+		}
+		if (first) {
+			first = 0;
+			continue;	
+		}
+
+		rfbCFD(0);
+		usleep(1000);
+		dt += dtime(&tm);
+	}
+	return ok;
 }
 
 /* 
@@ -2359,7 +2546,7 @@ if (0 || db) fprintf(stderr, "check_xrecord: SPIN-OUT: %.3f/%.3f\n", spin,
 
 		dtime0(&tm);
 		age = max_age;
-		dret = push_scr_ev(&age, SCR_KEY, bdpush, bdx, bdy, bdskinny);
+		dret = push_scr_ev(&age, SCR_KEY, bdpush, bdx, bdy, bdskinny, 1);
 		dt = dtime(&tm);
 
 		ret = 1 + dret;
@@ -2441,6 +2628,7 @@ static int check_xrecord_mouse(void) {
 	int already_down = 0, max_ptr_eat = 20;
 	static int want_back_in = 0;
 	int came_back_in;
+	int first_push = 1;
 
 	int scroll_wheel = 0;
 	int btn4 = (1<<3);
@@ -2475,6 +2663,7 @@ if (0) fprintf(stderr, "check_xrecord_mouse: IN xrecording: %d\n", xrecording);
 	}
 	if (want_back_in) {
 		came_back_in = 1;
+		first_push = 0;
 	} else {
 		came_back_in = 0;
 	}
@@ -2576,7 +2765,8 @@ if (db) fprintf(stderr, "check_xrecord_mouse: BEGIN LOOP: scr_ev_cnt: "
 			dtime0(&tm);
 
 			dret = push_scr_ev(&age, SCR_MOUSE, bdpush, bdx,
-			    bdy, bdskinny);
+			    bdy, bdskinny, first_push);
+			if (first_push) first_push = 0;
 			ret = 1 + dret;
 
 			dt = dtime(&tm);
@@ -2837,8 +3027,12 @@ if (0) fprintf(stderr, "check_xrecord: button_mask: %d  mouse_wants_back_in: %d\
 		db2 = 1; \
 	}
 
+#define NBATCHMAX 1024
+int batch_dxs[NBATCHMAX], batch_dys[NBATCHMAX];
+sraRegionPtr batch_reg[NBATCHMAX];
+
 static int try_copyrect(Window frame, int x, int y, int w, int h, int dx, int dy,
-    int *obscured, sraRegionPtr extra_clip, double max_wait) {
+    int *obscured, sraRegionPtr extra_clip, double max_wait, int *nbatch) {
 
 	static int dt_bad = 0;
 	static time_t dt_bad_check = 0;
@@ -2847,15 +3041,19 @@ static int try_copyrect(Window frame, int x, int y, int w, int h, int dx, int dy
 	double tm, dt;
 	DB_SET
 
-	get_client_regions(&req, &mod, &cpy, &ncli);
-	if (cpy) {
-		/* one is still pending... try to force it out: */
-		fb_push_wait(max_wait, FB_COPY);
-
+	if (nbatch == NULL) {
 		get_client_regions(&req, &mod, &cpy, &ncli);
-	}
-	if (cpy) {
-		return 0;
+		if (cpy) {
+			/* one is still pending... try to force it out: */
+			if (!fb_push_wait(max_wait, FB_COPY)) {
+				fb_push_wait(max_wait/2, FB_COPY);
+			}
+
+			get_client_regions(&req, &mod, &cpy, &ncli);
+		}
+		if (cpy) {
+			return 0;
+		}
 	}
 
 	*obscured = 0;
@@ -2907,7 +3105,14 @@ if (db2) fprintf(stderr, "try_copyrect: 0x%lx  bad: %d stack_list_num: %d\n", fr
 				sraRgnDestroy(bo_rect);
 			}
 		}
-		do_copyregion(rect, dx, dy);
+		if (!nbatch) {
+			do_copyregion(rect, dx, dy, 0);
+		} else {
+			batch_dxs[*nbatch] = dx;
+			batch_dys[*nbatch] = dy;
+			batch_reg[*nbatch] = sraRgnCreateRgn(rect);
+			(*nbatch)++;
+		}
 		sraRgnDestroy(rect);
 
 		sent_copyrect = 1;
@@ -3136,7 +3341,15 @@ if (db2) fprintf(stderr, "  stack_work dt: %.4f\n", dt);
 			/* now send the CopyRegion: */
 			if (! sraRgnEmpty(shifted_region)) {
 				dtime0(&tm);
-				do_copyregion(shifted_region, dx, dy);
+				if (!nbatch) {
+					do_copyregion(shifted_region, dx, dy, 0);
+				} else {
+					batch_dxs[*nbatch] = dx;
+					batch_dys[*nbatch] = dy;
+					batch_reg[*nbatch] = sraRgnCreateRgn(shifted_region);
+					(*nbatch)++;
+					
+				}
 				dt = dtime(&tm);
 if (0 || db2) fprintf(stderr, "do_copyregion: %d %d %d %d  dx: %d  dy: %d dt: %.4f\n",
 	tx1, ty1, tx2, ty2, dx, dy, dt);
@@ -3255,7 +3468,7 @@ void check_fixscreen(void) {
 		double delay = 3.0;
 		if (now > last + delay) {
 			if (! didfull) {
-				scale_and_mark_rect(0, 0, dpy_x, dpy_y);
+				scale_and_mark_rect(0, 0, dpy_x, dpy_y, 1);
 				if (db) rfbLog("doing scale screen_fixup\n");
 			}
 			last_copyrect_fix = now;
@@ -3316,118 +3529,713 @@ static int wireframe_mod_state() {
 	return 0;
 }
 
-/*
- * Applied just before any check_user_input() modes.  Look for a
- * ButtonPress; find window it happened in; find the wm frame window
- * for it; watch for that window moving or resizing.  If it does, do the
- * wireframe animation.  Do this until ButtonRelease or timeouts occur.
- * Remove wireframe.
- *
- * Under -nowirecopyrect, return control to base scheme
- * (check_user_input() ...) that will repaint the screen with the window
- * in the new postion or size.  Under -wirecopyrect, apply rfbDoCopyRect
- * or rfbDoCopyRegion: this "pollutes" our framebuffer, but the normal
- * polling will quickly repair it. Under happy circumstances, this
- * reduces actual XShmGetImage work (i.e. if we correctly predicted how
- * the X fb has changed.
- *
- * -scale doesn't always work under -wirecopyrect, but the wireframe does.
- *
- * testing of this mode under -threads is incomplete.
- *
- * returns 1 if it did an animation, 0 if no move/resize triggers
- * went off.
- *
- * TBD: see if we can select StructureNotify ConfigureNotify events for
- * the toplevel windows to get better info on moves and resizes.
- */
-int check_wireframe(void) {
-	Window frame = None, orig_frame = None;
-	XWindowAttributes attr;
-	int dx, dy;
+static int NPP_nreg = 0;
+static sraRegionPtr NPP_roffscreen = NULL;
+static sraRegionPtr NPP_r_bs_tmp = NULL;
+static Window NPP_nwin = None;
 
-	int orig_px, orig_py, orig_x, orig_y, orig_w, orig_h;
-	int px, py, x, y, w, h;
-	int box_x, box_y, box_w, box_h;
-	int orig_cursor_x, orig_cursor_y, g, gd;
-	int already_down = 0, win_gone = 0, win_unmapped = 0;
-	double spin = 0.0, tm, last_ptr = 0.0, last_draw;
-	int frame_changed = 0, drew_box = 0, got_2nd_pointer = 0;
-	int special_t1 = 0, break_reason = 0;
-	static double first_dt_ave = 0.0;
-	static int first_dt_cnt = 0;
-	static time_t last_save_stacklist = 0;
-	int bdown0, bdown, gotui, cnt = 0;
-	
-	/* heuristics: */
-	double first_event_spin   = wireframe_t1;
-	double frame_changed_spin = wireframe_t2;
-	double max_spin = wireframe_t3;
-	double min_draw = wireframe_t4;
-	int try_it = 0;
-	Window desc[6];
-	DB_SET
+void clear_win_events(void) {
+#if !NO_X11
+		if (dpy && NPP_nwin != None) {
+			XEvent ev;
+			XErrorHandler old_handler;
+			old_handler = XSetErrorHandler(trap_xerror);
+			trapped_xerror = 0;
+			while (XCheckTypedWindowEvent(dpy, NPP_nwin, ConfigureNotify, &ev)) {
+				fprintf(stderr, ".");
+				if (trapped_xerror) {
+					break;
+				}
+				trapped_xerror = 0;
+			}
+			while (XCheckTypedWindowEvent(dpy, NPP_nwin, VisibilityNotify, &ev)) {
+				fprintf(stderr, "+");
+				if (trapped_xerror) {
+					break;
+				}
+				trapped_xerror = 0;
+			}
+			XSetErrorHandler(old_handler);
+			fprintf(stderr, " 0x%x\n", NPP_nwin);
+		}
+#endif
+}
 
-	if (unixpw_in_progress) return 0;
+void push_borders(sraRect *rects, int nrect) {
+		int i, s = 2;
+		sraRegionPtr r0, r1, r2;
+
+		r0 = sraRgnCreate(); 
+		r1 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+
+		for (i=0; i<nrect; i++) {
+			int x = rects[i].x1;
+			int y = rects[i].y1;
+			int w = rects[i].x2;
+			int h = rects[i].y2;
+
+			if (w > 0 && h > 0 && w * h > 64 * 64) {
+				r2 = sraRgnCreateRect(x - s, y , x , y + h); 
+				sraRgnOr(r0, r2); 
+				sraRgnDestroy(r2);
+				
+				r2 = sraRgnCreateRect(x + w, y , x + w + s, y + h); 
+				sraRgnOr(r0, r2); 
+				sraRgnDestroy(r2);
+
+				r2 = sraRgnCreateRect(x - s, y - s, x + w + s, y + s); 
+				sraRgnOr(r0, r2); 
+				sraRgnDestroy(r2);
+				
+				r2 = sraRgnCreateRect(x - s, y , x + w + s, y + h + s); 
+				sraRgnOr(r0, r2); 
+				sraRgnDestroy(r2);
+			}
+		}
 
-#ifdef MACOSX
-	if (macosx_console) {
-		;
-	} else {
-		RAWFB_RET(0)
-	}
-#else
-	RAWFB_RET(0)
-#endif
+		sraRgnAnd(r0, r1); 
 
-	if (nofb) {
-		return 0;
-	}
-	if (subwin) {
-		return 0;	/* don't even bother for -id case */
-	}
+		if (!sraRgnEmpty(r0)) {
+			double d = dnow();
+			sraRectangleIterator *iter;
+			sraRect rect;
+			int db = 0;
 
-if (db > 1 && button_mask) fprintf(stderr, "check_wireframe: bm: %d  gpi: %d\n", button_mask, got_pointer_input);
+			if (db) fprintf(stderr, "SCALE_BORDER\n");
+			fb_push_wait(0.05, FB_MOD|FB_COPY);
 
-	bdown0 = 0;
-	if (button_mask) {
-		bdown0 = 1;
-	} else if (wireframe_local && display_button_mask) {
-		bdown0 = 2;
-	}
-	if (! bdown0) {
-		return 0;	/* no button pressed down */
-	}
+			iter = sraRgnGetIterator(r0);
+			while (sraRgnIteratorNext(iter, &rect)) {
+				/* clip the window to the visible screen: */
+				int tx1 = rect.x1;
+				int ty1 = rect.y1;
+				int tx2 = rect.x2;
+				int ty2 = rect.y2;
+				scale_and_mark_rect(tx1, ty1, tx2, ty2, 1);
+			}
+			sraRgnReleaseIterator(iter);
 
-	gotui = 0;
-	if (got_pointer_input) {
-		gotui = 1;
-	} else if (wireframe_local && display_button_mask) {
-		gotui = 2;
-	}
-	if (!use_threads && !gotui) {
-		return 0;	/* need ptr input, e.g. button down, motion */
-	}
+			if (db) fprintf(stderr, "SCALE_BORDER %.4f\n", dnow() - d);
+			fb_push_wait(0.1, FB_MOD|FB_COPY);
+			if (db) fprintf(stderr, "SCALE_BORDER %.4f\n", dnow() - d);
+		}
+		sraRgnDestroy(r0);
+		sraRgnDestroy(r1);
+}
 
-if (db > 1) fprintf(stderr, "check_wireframe: %d\n", db);
+void ncache_pre_portions(Window orig_frame, Window frame, int *nidx_in, int try_batch, int *use_batch,
+    int orig_x, int orig_y, int orig_w, int orig_h, int x, int y, int w, int h, double ntim) {
+	int nidx, np = ncache_pad;
 
-if (db) fprintf(stderr, "\n*** button down!!  x: %d  y: %d\n", cursor_x, cursor_y);
+	*use_batch = 0;
+	*nidx_in = -1;
+	NPP_nreg = 0;
+	NPP_roffscreen = NULL;
+	NPP_r_bs_tmp = NULL;
+	NPP_nwin = None;
+	
+	if (ncache <= 0) {
+		return;
+	}
 
-	/*
-	 * Query where the pointer is and which child of the root
-	 * window.  We will assume this is the frame the window manager
-	 * makes when it reparents the toplevel window.
-	 */
-	X_LOCK;
-	if (! get_wm_frame_pos(&px, &py, &x, &y, &w, &h, &frame, NULL)) {
-if (db) fprintf(stderr, "NO get_wm_frame_pos-1: 0x%lx\n", frame);
-		X_UNLOCK;
-		return 0;
+	if (rotating) {
+		try_batch = 0;
 	}
-	X_UNLOCK;
-if (db) fprintf(stderr, "a: %d  wf: %.3f  A: %d  frm: 0x%lx\n", w*h, wireframe_frac, (dpy_x*dpy_y), frame);
 
-	/*
+	if (*nidx_in == -1) {
+		nidx = lookup_win_index(orig_frame);
+		NPP_nwin = orig_frame;
+		if (nidx < 0) {
+			nidx = lookup_win_index(frame);
+			NPP_nwin = frame;
+		}
+	} else {
+		nidx = *nidx_in;
+	}
+	if (nidx > 0) {
+		sraRegionPtr r0, r1, r2;
+		int dx, dy;
+		int bs_x = cache_list[nidx].bs_x;	
+		int bs_y = cache_list[nidx].bs_y;	
+		int bs_w = cache_list[nidx].bs_w;	
+		int bs_h = cache_list[nidx].bs_h;	
+
+		*nidx_in = nidx;
+
+		if (bs_x < 0) {
+			if (!find_rect(nidx, x, y, w, h)) {
+				nidx = -1;
+				return;
+			}
+			bs_x = cache_list[nidx].bs_x;
+			bs_y = cache_list[nidx].bs_y;
+			bs_w = cache_list[nidx].bs_w;
+			bs_h = cache_list[nidx].bs_h;
+		}
+		if (bs_x < 0) {
+			nidx = -1;
+			return;
+		}
+
+		if (try_batch) {
+			*use_batch = 1;
+		}
+
+		if (ncache_pad) {
+			orig_x -= np;	
+			orig_y -= np;	
+			orig_w += 2 * np;	
+			orig_h += 2 * np;	
+			x -= np;	
+			y -= np;	
+			w += 2 * np;	
+			h += 2 * np;	
+		}
+
+		if (clipshift) {
+			orig_x -= coff_x;
+			orig_y -= coff_y;
+			x -= coff_x;
+			y -= coff_y;
+		}
+
+		r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+
+		r2 = sraRgnCreateRect(orig_x, orig_y, orig_x + orig_w, orig_y + orig_h);
+		sraRgnSubtract(r2, r0);
+		if (! sraRgnEmpty(r2) && cache_list[nidx].bs_time > 0.0) {
+			/* some is initially offscreen */
+			dx = bs_x - orig_x;
+			dy = bs_y - orig_y;
+			sraRgnOffset(r2, dx, dy);
+			dx = 0;
+			dy = dpy_y;
+			sraRgnOffset(r2, dx, dy);
+//fprintf(stderr, "FB_COPY: %.4f 1) offscreen check:\n", dnow() - ntim);
+
+			/* 0) save it in the invalid (offscreen) SU portion */
+			if (! *use_batch) {
+				do_copyregion(r2, dx, dy, 0);
+				if (! fb_push_wait(0.2, FB_COPY)) {
+					fb_push_wait(0.1, FB_COPY);
+				}
+			} else {
+				batch_dxs[NPP_nreg] = dx;
+				batch_dys[NPP_nreg] = dy;
+				batch_reg[NPP_nreg++] = sraRgnCreateRgn(r2);
+			}
+			NPP_roffscreen = sraRgnCreateRgn(r2);
+		}
+		sraRgnDestroy(r2);
+
+		/* 1) use bs for temp storage of the new save under. */
+		r1 = sraRgnCreateRect(x, y, x + w, y + h);
+		sraRgnAnd(r1, r0);
+
+		dx = bs_x - x;
+		dy = bs_y - y;
+		sraRgnOffset(r1, dx, dy);
+
+//fprintf(stderr, "FB_COPY: %.4f 1) use tmp bs:\n", dnow() - ntim);
+		if (! *use_batch) {
+			do_copyregion(r1, dx, dy, 0);
+			if (! fb_push_wait(0.2, FB_COPY)) {
+//fprintf(stderr, "FB_COPY: %.4f 1) FAILED.\n", dnow() - ntim);
+				fb_push_wait(0.1, FB_COPY);
+			}
+		} else {
+			batch_dxs[NPP_nreg] = dx;
+			batch_dys[NPP_nreg] = dy;
+			batch_reg[NPP_nreg++] = sraRgnCreateRgn(r1);
+		}
+		NPP_r_bs_tmp = sraRgnCreateRgn(r1);
+		sraRgnDestroy(r0);
+		sraRgnDestroy(r1);
+	}
+}
+
+ncache_post_portions(int nidx, int use_batch, int orig_x, int orig_y, int orig_w, int orig_h,
+    int x, int y, int w, int h, double batch_delay, double ntim) {
+	int np = ncache_pad;
+
+	if (ncache > 0 && nidx >= 0) {
+		sraRegionPtr r0, r1, r2, r3;
+		int dx, dy;
+		int su_x = cache_list[nidx].su_x;
+		int su_y = cache_list[nidx].su_y;
+		int su_w = cache_list[nidx].su_w;
+		int su_h = cache_list[nidx].su_h;
+		int bs_x = cache_list[nidx].bs_x;
+		int bs_y = cache_list[nidx].bs_y;
+		int bs_w = cache_list[nidx].bs_w;
+		int bs_h = cache_list[nidx].bs_h;
+		int some_su = 0;
+
+//fprintf(stderr, "su: %dx%d+%d+%d  bs: %dx%d+%d+%d\n", su_w, su_h, su_x, su_y, bs_w, bs_h, bs_x, bs_y);
+
+		if (bs_x < 0) {
+			if (!find_rect(nidx, x, y, w, h)) {
+				return;
+			}
+			su_x = cache_list[nidx].su_x;
+			su_y = cache_list[nidx].su_y;
+			su_w = cache_list[nidx].su_w;
+			su_h = cache_list[nidx].su_h;
+			bs_x = cache_list[nidx].bs_x;
+			bs_y = cache_list[nidx].bs_y;
+			bs_w = cache_list[nidx].bs_w;
+			bs_h = cache_list[nidx].bs_h;
+		}
+		if (bs_x < 0) {
+			return;
+		}
+
+		if (ncache_pad) {
+			orig_x -= np;	
+			orig_y -= np;	
+			orig_w += 2 * np;	
+			orig_h += 2 * np;	
+			x -= np;	
+			y -= np;	
+			w += 2 * np;	
+			h += 2 * np;	
+		}
+
+		if (clipshift) {
+			orig_x -= coff_x;
+			orig_y -= coff_y;
+			x -= coff_x;
+			y -= coff_y;
+		}
+
+		r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+
+		/* 0b) copy this bs part stored in saveunder */
+		if (NPP_roffscreen != NULL) {
+			dx = x - su_x;
+			dy = y - su_y;
+			sraRgnOffset(NPP_roffscreen, dx, dy);
+			sraRgnAnd(NPP_roffscreen, r0);
+			
+			if (! use_batch) {
+				do_copyregion(NPP_roffscreen, dx, dy, 0);
+				if (!fb_push_wait(0.2, FB_COPY)) {
+					fb_push_wait(0.1, FB_COPY);
+				}
+			} else {
+				batch_dxs[NPP_nreg] = dx;
+				batch_dys[NPP_nreg] = dy;
+				batch_reg[NPP_nreg++] = sraRgnCreateRgn(NPP_roffscreen);
+			}
+			sraRgnDestroy(NPP_roffscreen);
+		}
+
+		/* 3) copy from the saveunder to where orig win was */
+		r1 = sraRgnCreateRect(orig_x, orig_y, orig_x + orig_w, orig_y + orig_h);
+		sraRgnAnd(r1, r0);
+		r2 = sraRgnCreateRect(x+np, y+np, x + w-np, y + h-np);
+		sraRgnAnd(r2, r0);
+		sraRgnSubtract(r1, r2);
+
+		dx = orig_x - su_x;
+		dy = orig_y - su_y;
+//fprintf(stderr, "FB_COPY: %.4f 3) sent_copyrect: su_restore: %d %d\n", dnow() - ntim, dx, dy);
+		if (cache_list[nidx].su_time == 0.0) {
+			;
+		} else if (! use_batch) {
+			do_copyregion(r1, dx, dy, 0);
+			if (!fb_push_wait(0.2, FB_COPY)) {
+//fprintf(stderr, "FB_COPY: %.4f 3) FAILED.\n", dnow() - ntim);
+				fb_push_wait(0.1, FB_COPY);
+			}
+		} else {
+			batch_dxs[NPP_nreg] = dx;
+			batch_dys[NPP_nreg] = dy;
+			batch_reg[NPP_nreg++] = sraRgnCreateRgn(r1);
+		}
+//fprintf(stderr, "sent_copyrect: %.4f su_restore: done.\n", dnow() - ntim);
+		sraRgnDestroy(r0);
+		sraRgnDestroy(r1);
+		sraRgnDestroy(r2);
+
+		/* 4) if overlap between orig and displaced, move the corner that will still be su: */
+		r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+
+		r1 = sraRgnCreateRect(orig_x, orig_y, orig_x + orig_w, orig_y + orig_h);
+		sraRgnAnd(r1, r0);
+		r2 = sraRgnCreateRect(x, y, x + w, y + h);
+		sraRgnAnd(r2, r0);
+		r3 = NULL;
+		if (sraRgnAnd(r2, r1) && cache_list[nidx].su_time > 0.0) {
+			int dx2 = su_x - orig_x;
+			int dy2 = su_y - orig_y;
+
+			r3 = sraRgnCreateRgn(r2);
+			sraRgnOffset(r2, dx2, dy2); 
+
+			dx = su_x - x;
+			dy = su_y - y;
+			sraRgnOffset(r3, dx, dy); 
+
+			dx = dx - dx2;
+			dy = dy - dy2;
+
+//fprintf(stderr, "FB_COPY: %.4f 4) move overlap inside su:\n", dnow() - ntim);
+			if (! use_batch) {
+				do_copyregion(r3, dx, dy, 0);
+				if (!fb_push_wait(0.2, FB_COPY)) {
+//fprintf(stderr, "FB_COPY: %.4f 4) FAILED.\n", dnow() - ntim);
+					fb_push_wait(0.1, FB_COPY);
+				}
+			} else {
+				batch_dxs[NPP_nreg] = dx;
+				batch_dys[NPP_nreg] = dy;
+				batch_reg[NPP_nreg++] = sraRgnCreateRgn(r3);
+			}
+		}
+		sraRgnDestroy(r0);
+		sraRgnDestroy(r1);
+		sraRgnDestroy(r2);
+
+		/* 5) copy our temporary stuff from bs to su: */
+		dx = su_x - bs_x;
+		dy = su_y - bs_y;
+		if (NPP_r_bs_tmp == NULL) {
+			r1 = sraRgnCreateRect(su_x, su_y, su_x + su_w, su_y + su_h); 
+		} else {
+			r1 = sraRgnCreateRgn(NPP_r_bs_tmp);
+			sraRgnOffset(r1, dx, dy);
+			sraRgnDestroy(NPP_r_bs_tmp);
+		}
+		if (r3 != NULL) {
+			sraRgnSubtract(r1, r3);
+			sraRgnDestroy(r3);
+		}
+//fprintf(stderr, "FB_COPY: %.4f 5) move tmp bs to su:\n", dnow() - ntim);
+		if (! use_batch) {
+			do_copyregion(r1, dx, dy, 0);
+			if (!fb_push_wait(0.2, FB_COPY)) {
+//fprintf(stderr, "FB_COPY: %.4f 5) FAILED.\n", dnow() - ntim);
+				fb_push_wait(0.1, FB_COPY);
+			}
+		} else {
+			batch_dxs[NPP_nreg] = dx;
+			batch_dys[NPP_nreg] = dy;
+			batch_reg[NPP_nreg++] = sraRgnCreateRgn(r1);
+		}
+		if (! sraRgnEmpty(r1)) {
+			some_su = 1;
+		}
+		sraRgnDestroy(r1);
+
+		/* 6) not really necessary, update bs with current view: */
+		r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+		r1 = sraRgnCreateRect(x, y, x + w, y + h);
+		sraRgnAnd(r1, r0);
+		dx = bs_x - x;
+		dy = bs_y - y;
+		sraRgnOffset(r1, dx, dy);
+//fprintf(stderr, "FB_COPY: %.4f 6) snapshot bs:\n", dnow() - ntim);
+		if (! use_batch) {
+			do_copyregion(r1, dx, dy, 0);
+			if (!fb_push_wait(0.2, FB_COPY)) {
+//fprintf(stderr, "FB_COPY: %.4f 6) FAILED.\n", dnow() - ntim);
+				fb_push_wait(0.1, FB_COPY);
+			}
+		} else {
+			batch_dxs[NPP_nreg] = dx;
+			batch_dys[NPP_nreg] = dy;
+			batch_reg[NPP_nreg++] = sraRgnCreateRgn(r1);
+		}
+		sraRgnDestroy(r0);
+		sraRgnDestroy(r1);
+
+		if (use_batch) {
+			int k;
+			batch_copyregion(batch_reg, batch_dxs, batch_dys, NPP_nreg, batch_delay);
+			for (k=0; k < NPP_nreg; k++) {
+				sraRgnDestroy(batch_reg[k]);
+			}
+fprintf(stderr, "FB_COPY: %.4f XX did batch 0x%x %3d su: %dx%d+%d+%d  bs: %dx%d+%d+%d\n", dnow() - ntim,
+	cache_list[nidx].win, nidx, su_w, su_h, su_x, su_y, bs_w, bs_h, bs_x, bs_y);
+		}
+		cache_list[nidx].x = x + np;
+		cache_list[nidx].y = y + np;
+		cache_list[nidx].bs_time = dnow();
+		if (some_su) {
+			cache_list[nidx].su_time = dnow();
+		}
+	} else {
+		if (use_batch) {
+			int k;
+			batch_copyregion(batch_reg, batch_dxs, batch_dys, NPP_nreg, batch_delay);
+			for (k=0; k < NPP_nreg; k++) {
+				sraRgnDestroy(batch_reg[k]);
+			}
+		}
+	}
+
+	if (scaling) {
+		sraRect rects[2];	
+
+		rects[0].x1 = orig_x;
+		rects[0].y1 = orig_y;
+		rects[0].x2 = orig_w;
+		rects[0].y2 = orig_h;
+
+		rects[1].x1 = x;
+		rects[1].y1 = y;
+		rects[1].x2 = w;
+		rects[1].y2 = h;
+		push_borders(rects, 2);
+	}
+}
+
+void do_copyrect_drag_move(Window orig_frame, Window frame, int *nidx, int try_batch,
+    int now_x, int now_y, int orig_w, int orig_h, int x, int y, int w, int h, double batch_delay) {
+
+	int sent_copyrect, obscured;
+	int dx, dy;
+	int use_batch = 0;
+	double ntim = dnow();
+	sraRegionPtr r0, r1;
+
+	dx = x - now_x;
+	dy = y - now_y;
+	if (dx == 0 && dy == 0) {
+		return;
+	}
+	
+	ncache_pre_portions(orig_frame, frame, nidx, try_batch, &use_batch,
+	    now_x, now_y, orig_w, orig_h, x, y, w, h, ntim);
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
+	r1 = sraRgnCreateRect(x, y, x + w, y + h);
+	sraRgnAnd(r1, r0);
+
+	dx = x - now_x;
+	dy = y - now_y;
+	if (! use_batch) {
+		do_copyregion(r1, dx, dy, 0);
+		if (!fb_push_wait(0.2, FB_COPY)) {
+fprintf(stderr, "FB_COPY: %.4f 3) FAILED.\n", dnow() - ntim);
+			fb_push_wait(0.1, FB_COPY);
+		}
+	} else {
+		batch_dxs[NPP_nreg] = dx;
+		batch_dys[NPP_nreg] = dy;
+		batch_reg[NPP_nreg++] = sraRgnCreateRgn(r1);
+	}
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r1);
+	sent_copyrect = 1;
+
+	if (sent_copyrect) {
+		if (use_batch) {
+			;
+		} else if (! obscured) {
+			fb_push_wait(0.1, FB_COPY);
+		} else {
+			/* no diff for now... */
+			fb_push_wait(0.1, FB_COPY);
+		}
+		ncache_post_portions(*nidx, use_batch,
+		    now_x, now_y, orig_w, orig_h, x, y, w, h, batch_delay, ntim);
+	}
+fprintf(stderr, "do_COPY: %.4f -- post_portion done.\n", dnow() - ntim);
+}
+
+void check_macosx_iconify(Window orig_frame, Window frame, int flush) {
+#ifdef MACOSX
+	static double last = 0.0;
+	double now;
+	int j, m = 5, idx = -1, ok = 0, unmapped = 0;
+
+	if (! macosx_console) {
+		return;
+	}
+
+	now = dnow();
+	if (now < last + 0.3) {
+		return;
+	}
+	last = now;
+
+	if (ncache > 0 && orig_frame != None) {
+		idx = lookup_win_index(orig_frame);
+		if (idx >= 0) {
+			if (cache_list[idx].map_state == IsUnmapped) {
+fprintf(stderr, "FAW orig_frame unmapped.\n");
+				unmapped = 1;
+				m = 3;
+			}
+		}
+	}
+
+	if (unmapped) {
+		;
+	} else if (orig_frame && macosxCGS_follow_animation_win(orig_frame, -1, 0)) {
+		fprintf(stderr, "FAW orig_frame %d\n", orig_frame);
+	} else if (0 && frame && macosxCGS_follow_animation_win(frame, -1, 0)) {
+		fprintf(stderr, "FAW frame      %d\n", frame);
+	}
+	for (j=0; j<m; j++) {
+		macosxCGS_get_all_windows();
+		if (macosx_checkevent(NULL)) {
+			ok = 1;
+			fprintf(stderr, "Check Event    1\n");
+		} else {
+			fprintf(stderr, "Check Event    0\n");
+		}
+		if (ok) {
+			break;
+		}
+		usleep(10 * 1000);
+	}
+	if (ok) {
+		if (flush) {
+			fb_push_wait(0.1, FB_COPY|FB_MOD);
+		}
+		check_ncache(0, 2);
+	}
+#endif
+}
+
+void check_macosx_click_frame(void) {
+#ifdef MACOSX
+	if (macosx_console) {
+//fprintf(stderr, "macosx_click_frame: 0x%x\n", macosx_click_frame);
+		check_macosx_iconify(macosx_click_frame, None, 0);
+		macosx_click_frame = None;
+		if (button_mask && !macosx_checkevent(NULL)) {
+			check_macosx_iconify(None, None, 0);
+		}
+	}
+#endif
+}
+
+/*
+ * Applied just before any check_user_input() modes.  Look for a
+ * ButtonPress; find window it happened in; find the wm frame window
+ * for it; watch for that window moving or resizing.  If it does, do the
+ * wireframe animation.  Do this until ButtonRelease or timeouts occur.
+ * Remove wireframe.
+ *
+ * Under -nowirecopyrect, return control to base scheme
+ * (check_user_input() ...) that will repaint the screen with the window
+ * in the new postion or size.  Under -wirecopyrect, apply rfbDoCopyRect
+ * or rfbDoCopyRegion: this "pollutes" our framebuffer, but the normal
+ * polling will quickly repair it. Under happy circumstances, this
+ * reduces actual XShmGetImage work (i.e. if we correctly predicted how
+ * the X fb has changed.
+ *
+ * -scale doesn't always work under -wirecopyrect, but the wireframe does.
+ *
+ * testing of this mode under -threads is incomplete.
+ *
+ * returns 1 if it did an animation, 0 if no move/resize triggers
+ * went off.
+ *
+ * TBD: see if we can select StructureNotify ConfigureNotify events for
+ * the toplevel windows to get better info on moves and resizes.
+ */
+int check_wireframe(void) {
+	Window frame = None, orig_frame = None;
+	XWindowAttributes attr;
+	int dx, dy;
+
+	int orig_px, orig_py, orig_x, orig_y, orig_w, orig_h;
+	int px, py, x, y, w, h;
+	int box_x, box_y, box_w, box_h;
+	int orig_cursor_x, orig_cursor_y, g, gd;
+	int already_down = 0, win_gone = 0, win_unmapped = 0;
+	double spin = 0.0, tm, last_ptr = 0.0, last_draw;
+
+	int frame_changed = 0, drew_box = 0, got_2nd_pointer = 0;
+	int try_copyrect_drag = 1, do_copyrect_drag = -1;
+	int now_x, now_y, nidx = -1;
+	double copyrect_drag_delay = -1.0;
+	int try_batch = 1;	/* XXX Y */
+	int mac_skip = 0;
+
+	int special_t1 = 0, break_reason = 0, last_draw_cnt = 0, gpi = 0;
+	static double first_dt_ave = 0.0;
+	static int first_dt_cnt = 0;
+	static time_t last_save_stacklist = 0;
+	int bdown0, bdown, gotui, cnt = 0;
+	
+	/* heuristics: */
+	double first_event_spin   = wireframe_t1;
+	double frame_changed_spin = wireframe_t2;
+	double max_spin = wireframe_t3;
+	double min_draw = wireframe_t4;
+	int try_it = 0;
+	Window desc[6];
+	DB_SET
+
+	if (unixpw_in_progress) return 0;
+
+#ifdef MACOSX
+	if (macosx_console) {
+		;
+	} else {
+		RAWFB_RET(0)
+	}
+#else
+	RAWFB_RET(0)
+#endif
+
+	if (nofb) {
+		return 0;
+	}
+	if (subwin) {
+		return 0;	/* don't even bother for -id case */
+	}
+
+if (db > 1 && button_mask) fprintf(stderr, "check_wireframe: bm: %d  gpi: %d\n", button_mask, got_pointer_input);
+
+	bdown0 = 0;
+	if (button_mask) {
+		bdown0 = 1;
+	} else if (wireframe_local && display_button_mask) {
+		bdown0 = 2;
+	}
+	if (! bdown0) {
+		return 0;	/* no button pressed down */
+	}
+
+	gotui = 0;
+	if (got_pointer_input) {
+		gotui = 1;
+	} else if (wireframe_local && display_button_mask) {
+		gotui = 2;
+	}
+	if (!use_threads && !gotui) {
+		return 0;	/* need ptr input, e.g. button down, motion */
+	}
+
+if (db > 1) fprintf(stderr, "check_wireframe: %d\n", db);
+
+if (db) fprintf(stderr, "\n*** button down!!  x: %d  y: %d\n", cursor_x, cursor_y);
+
+	/*
+	 * Query where the pointer is and which child of the root
+	 * window.  We will assume this is the frame the window manager
+	 * makes when it reparents the toplevel window.
+	 */
+	X_LOCK;
+	if (! get_wm_frame_pos(&px, &py, &x, &y, &w, &h, &frame, NULL)) {
+if (db) fprintf(stderr, "NO get_wm_frame_pos-1: 0x%lx\n", frame);
+		X_UNLOCK;
+#ifdef MACOSX
+		check_macosx_click_frame();
+#endif
+		return 0;
+	}
+	X_UNLOCK;
+if (db) fprintf(stderr, "a: %d  wf: %.3f  A: %d  frm: 0x%lx\n", w*h, wireframe_frac, (dpy_x*dpy_y), frame);
+
+	/*
 	 * apply the percentage size criterion (allow opaque moves for
 	 * small windows)
 	 */
@@ -3450,6 +4258,9 @@ if (db) fprintf(stderr, "  frame: x: %d  y: %d  w: %d  h: %d  px: %d  py: %d  fr
 	}
 	if (! try_it) {
 if (db) fprintf(stderr, "INTERIOR\n");
+#ifdef MACOSX
+		check_macosx_click_frame();
+#endif
 		return 0;
 	}
 
@@ -3540,6 +4351,13 @@ if (db) fprintf(stderr, "INTERIOR\n");
 		pointer(-1, 0, 0, NULL);
 	}
 
+	if (cursor_noshape_updates_clients(screen)) {
+		try_batch = 0;
+	}
+	if (rotating) {
+		try_batch = 0;
+	}
+
 	g = got_pointer_input;
 	gd = got_local_pointer_input;
 
@@ -3552,7 +4370,7 @@ if (db) fprintf(stderr, "INTERIOR\n");
 		/* try do induce/waitfor some more user input */
 		if (use_threads) {
 			usleep(1000);
-		} else if (drew_box) {
+		} else if (drew_box && do_copyrect_drag != 1) {
 			rfbPE(1000);
 		} else {
 			rfbCFD(1000);
@@ -3577,7 +4395,6 @@ if (db) fprintf(stderr, "INTERIOR\n");
 #endif
 		}
 
-
 		cnt++;
 		spin += dtime(&tm);
 
@@ -3624,6 +4441,8 @@ if (db || db2) fprintf(stderr, " SPIN-OUT-NO2ND_PTR: %.3f\n", spin);
 				break;
 			}
 		}
+
+		gpi = 0;
 		/* see if some pointer input occurred: */
 		if (got_pointer_input > g ||
 		    (wireframe_local && (got_local_pointer_input > gd))) {
@@ -3633,6 +4452,7 @@ if (db) fprintf(stderr, "  ++pointer event!! [%02d]  dt: %.3f  x: %d  y: %d  mas
 
 			g = got_pointer_input;
 			gd = got_local_pointer_input;
+			gpi = 1;
 
 			X_LOCK;
 			XFlush_wr(dpy);
@@ -3729,38 +4549,104 @@ if (db) fprintf(stderr, "WIN RESIZE  1st-dt: %.3f\n", first_dt_ave/n);
 				frame_changed = 1;
 if (db) fprintf(stderr, "FRAME MOVE  1st-dt: %.3f\n", first_dt_ave/n);
 			}
+		}
 
-			/*
-			 * see if it is time to draw any or a new wireframe box
-			 */
-			if (frame_changed) {
-				int drawit = 0;
-				if (x != box_x || y != box_y) {
-					/* moved since last */
-					drawit = 1;
-				} else if (w != box_w || h != box_h) {
-					/* resize since last */
-					drawit = 1;
-				}
-				if (drawit) {
-					/*
-					 * check time (to avoid too much
-					 * animations on slow machines
-					 * or links).
-					 */
-					if (spin > last_draw + min_draw ||
-					    ! drew_box) {
-						draw_box(x, y, w, h, 0);
-						drew_box = 1;
-						rfbPE(1000);
-						last_draw = spin;
+		/*
+		 * see if it is time to draw any or a new wireframe box
+		 */
+
+		if (frame_changed) {
+			int drawit = 0;
+			if (x != box_x || y != box_y) {
+				/* moved since last */
+//fprintf(stderr, "DRAW1 %d %d\n", x - box_x, y - box_y);
+				drawit = 1;
+			} else if (w != box_w || h != box_h) {
+				/* resize since last */
+				drawit = 1;
+			}
+			if (drawit) {
+				int doit = 0;
+				/*
+				 * check time (to avoid too much
+				 * animations on slow machines
+				 * or links).
+				 */
+				if (gpi) {
+					if (spin > last_draw + min_draw || ! drew_box) {
+						doit = 1;
+					}
+					if (macosx_console && doit && !mac_skip) {
+						if (x != box_x && y != box_y && w != box_w && h != box_h) {
+							doit = 0;
+						} else if (!button_mask) {
+							doit = 0;
+						}
+						mac_skip++;
+					}
+				} else {
+					if (drew_box && cnt > last_draw_cnt) 	{
+						doit = 1;
+fprintf(stderr, "*** NO GPI DRAW_BOX\n");
+					}
+				}
+		
+				if (doit) {
+					if (try_copyrect_drag) {
+						if (!ncache_copyrect) {
+							do_copyrect_drag = 0;
+						} else if (w != box_w || h != box_h) {
+							do_copyrect_drag = 0;
+						} else if (do_copyrect_drag < 0) {
+							int idx = lookup_win_index(orig_frame);
+							if (idx < 0) {
+								idx = lookup_win_index(frame);
+							}
+							if (idx >= 0) {
+								if (cache_list[idx].su_time > 0.0) {
+									double min_draw0 = min_draw;
+									min_draw *= 0.66;
+									do_copyrect_drag = 1;
+//fprintf(stderr, "min_draw: %.4f -> %.4f\n", min_draw0, min_draw);
+								}
+								nidx = idx;
+							}
+							now_x = orig_x;
+							now_y = orig_y;
+						}
+						if (do_copyrect_drag) {
+							if (orig_w != w || orig_h != h) {
+								do_copyrect_drag = 0;
+							}
+						}
 					}
+
+					drew_box = 1;
+					if (do_copyrect_drag <= 0) {
+						draw_box(x, y, w, h, 0);
+						fb_push(); /* XXX Y */
+						rfbPE(1000);
+					} else {
+#ifndef NO_NCACHE
+						do_copyrect_drag_move(orig_frame, frame, &nidx,
+						    try_batch, now_x, now_y, orig_w, orig_h, x, y, w, h,
+						    copyrect_drag_delay);
+						now_x = x;
+						now_y = y;
+						if (copyrect_drag_delay == -1.0) {
+							copyrect_drag_delay = 0.04;
+						}
+#endif
+					}
+
+					last_draw = spin;
+					last_draw_cnt = cnt;
 				}
-				box_x = x;
-				box_y = y;
-				box_w = w;
-				box_h = h;
 			}
+			box_x = x;
+			box_y = y;
+			box_w = w;
+			box_h = h;
 		}
 
 		/* 
@@ -3787,11 +4673,21 @@ if (db || db2) fprintf(stderr, "NO button_mask\n");
 			stack_list_num = 0;
 		}
 		wireframe_in_progress = 0;
+		if (macosx_console && (break_reason == 6 || break_reason == 5)) {
+			check_macosx_iconify(orig_frame, frame, drew_box);
+		}
 		return 0;
 	}
 
 	/* remove the wireframe */
-	draw_box(0, 0, 0, 0, 1);
+	if (do_copyrect_drag <= 0) {
+		draw_box(0, 0, 0, 0, 1);
+		fb_push(); /* XXX Y */
+	} else {
+		do_copyrect_drag_move(orig_frame, frame, &nidx,
+		    try_batch, now_x, now_y, orig_w, orig_h, x, y, w, h, -1.0);
+		fb_push_wait(0.15, FB_COPY|FB_MOD);
+	}
 
 	dx = x - orig_x;
 	dy = y - orig_y;
@@ -3809,9 +4705,16 @@ if (db || db2) fprintf(stderr, "NO button_mask\n");
 		;
 	} else if (dx == 0 && dy == 0) {
 		;
+	} else if (do_copyrect_drag > 0) {
+		clear_win_events();
 	} else {
 		int spin_ms = (int) (spin * 1000 * 1000);
 		int obscured, sent_copyrect = 0;
+		int np = ncache_pad;
+
+		int nidx = -1;
+		int use_batch = 0;
+		double ntim;
 
 		/*
 		 * set a timescale comparable to the spin time,
@@ -3822,61 +4725,57 @@ if (db || db2) fprintf(stderr, "NO button_mask\n");
 		} else if (spin_ms > 400) {
 			spin_ms = 400;
 		}
+		ntim = dnow();
 
 		/* try to flush the wireframe removal: */
-		fb_push_wait(0.1, FB_COPY|FB_MOD);
+fprintf(stderr, "\nSEND_COPYRECT  %.4f %.4f\n", dnowx(), dnow() - ntim);
+
+		if (! fb_push_wait(0.15, FB_COPY|FB_MOD)) {
+
+fprintf(stderr, "FB_COPY failed, try one more...", dnow() - ntim);
+
+			if (! fb_push_wait(0.15, FB_COPY|FB_MOD)) {
+
+fprintf(stderr, "FB_COPY failed again!", dnow() - ntim);
 
-		/* try to send a clipped copyrect of translation: */
-		sent_copyrect = try_copyrect(frame, x, y, w, h, dx, dy,
-		    &obscured, NULL, 0.15);
+			}
+		}
+
+#ifndef NO_NCACHE
+		ncache_pre_portions(orig_frame, frame, &nidx, try_batch, &use_batch,
+		    orig_x, orig_y, orig_w, orig_h, x, y, w, h, ntim);
+#endif
+
+		/* 2) try to send a clipped copyrect of translation: */
+
+		if (! try_batch) {
+			sent_copyrect = try_copyrect(frame, x, y, w, h, dx, dy,
+			    &obscured, NULL, 0.15, NULL);
+		} else {
+			try_copyrect(frame, x, y, w, h, dx, dy,
+			    &obscured, NULL, 0.15, &NPP_nreg);	/* XXX */
+			sent_copyrect = 1;
+			use_batch = 1;
+		}
 
 if (db) fprintf(stderr, "sent_copyrect: %d - obs: %d  frame: 0x%lx\n", sent_copyrect, obscured, frame);
 		if (sent_copyrect) {
 			/* try to push the changes to viewers: */
-			if (! obscured) {
+			if (use_batch) {
+				;
+			} else if (! obscured) {
 				fb_push_wait(0.1, FB_COPY);
 			} else {
 				/* no diff for now... */
 				fb_push_wait(0.1, FB_COPY);
 			}
 #ifndef NO_NCACHE
-			if (ncache > 0) {
-				int idx = lookup_win_index(frame);
-fprintf(stderr, "sent_copyrect: idx=%d 0x%x\n", idx, frame);
-				if (idx < 0) {
-					idx = lookup_win_index(orig_frame);
-fprintf(stderr, "sent_copyrect: idx=%d 0x%x\n", idx, orig_frame);
-				}
-				if (idx >= 0 && cache_list[idx].su_time > 0.0) {
-					sraRegionPtr r0, r1, r2;
-					sraRectangleIterator *iter;
-					sraRect rt;
-					int su_x = cache_list[idx].su_x;
-					int su_y = cache_list[idx].su_y;
-					int dx, dy;
-
-					r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y); 
-					r1 = sraRgnCreateRect(orig_x, orig_y, orig_x + orig_w, orig_y + orig_h);
-					sraRgnAnd(r1, r0);
-					r2 = sraRgnCreateRect(x, y, x + w, y + h);
-					sraRgnAnd(r2, r0);
-					sraRgnSubtract(r1, r2);
-
-					dx = orig_x - su_x;
-					dy = orig_y - su_y;
-fprintf(stderr, "sent_copyrect: su_restore: %d %d\n", dx, dy);
-					do_copyregion(r1, dx, dy);
-					fb_push_wait(0.1, FB_COPY);
-fprintf(stderr, "sent_copyrect: su_restore: done.\n");
-					sraRgnDestroy(r0);
-					sraRgnDestroy(r1);
-					sraRgnDestroy(r2);
-
-					cache_list[idx].su_time = 0.0;
-				}
-			}
+			ncache_post_portions(nidx, use_batch,
+			    orig_x, orig_y, orig_w, orig_h, x, y, w, h, -1.0, ntim);
+			clear_win_events();
 #endif
-			if (scaling) {
+
+			if (scaling && !use_batch) {
 				static double last_time = 0.0;
 				double now = dnow(), delay = 0.35;
 
@@ -3894,7 +4793,7 @@ fprintf(stderr, "sent_copyrect: su_restore: done.\n");
 						yt -= off_y;
 					}
 
-					scale_mark(xt, yt, xt+w, yt+h);
+					scale_mark(xt, yt, xt+w, yt+h, 1);
 					last_time = now;
 					last_copyrect_fix = now;
 				}
@@ -3944,6 +4843,10 @@ fprintf(stderr, "sent_copyrect: su_restore: done.\n");
 		xdamage_scheduled_mark = dnow() + 2.0;
 	}
 
+	if (macosx_console && (break_reason == 6 || break_reason == 5)) {
+		check_macosx_iconify(orig_frame, frame, drew_box);
+	}
+
 	return 1;
 }
 
@@ -4503,8 +5406,10 @@ if (debug_scroll && rc > 1) fprintf(stderr, "  CXR: check_user_input ret %d\n",
 
 	if (wireframe) {
 		if (check_wireframe()) {
+fprintf(stderr, "check_wireframe: 1\n");
 			return 0;
 		}
+//fprintf(stderr, "check_wireframe: 0\n");
 	}
 
 	if (pointer_mode == 1) {
@@ -4543,13 +5448,16 @@ if (debug_scroll && rc > 1) fprintf(stderr, "  CXR: check_user_input ret %d\n",
 	return 0;
 }
 
-#if defined(NO_NCACHE) || NO_X11
-void check_ncache(void) {
+#if defined(NO_NCACHE) || (NO_X11 && !defined(MACOSX))
+int check_ncache(int a, int b) {
 	return;
 }
 int lookup_win_index(Window win) {
 	return -1;
 }
+int find_rect(int idx, int x, int y, int w, int h) {
+	return 0;
+}
 #else
 /* maybe ncache.c it if works */
 
@@ -4560,14 +5468,14 @@ int cache_list_len = 0;
 void snapshot_cache_list(int free_only, double allowed_age) {
 	static double last_snap = 0.0, last_free = 0.0;
 	double now; 
-	int num, rc, i, j;
+	int num, rc, i;
 	unsigned int ui;
 	Window r, w;
 	Window *list;
-	int start = 2048;
+	int start = 512;
 
 	if (! cache_list) {
-		cache_list = (winattr_t *) malloc(start*sizeof(winattr_t));
+		cache_list = (winattr_t *) calloc(start*sizeof(winattr_t), 1);
 		cache_list_num = 0;
 		cache_list_len = start;
 	}
@@ -4602,38 +5510,72 @@ void snapshot_cache_list(int free_only, double allowed_age) {
 	X_LOCK;
 	/* no need to trap error since rootwin */
 	rc = XQueryTree_wr(dpy, rootwin, &r, &w, &list, &ui);
+	X_UNLOCK;
 	num = (int) ui;
 
 	if (! rc) {
 		cache_list_num = 0;
 		last_free = now;
 		last_snap = 0.0;
-		X_UNLOCK;
 		return;
 	}
 
 	last_snap = now;
 	if (num > cache_list_len) {
 		int n = 2*num;
+		n = num + 3;
 		free(cache_list);
-		cache_list = (winattr_t *) malloc(n*sizeof(winattr_t));
+		cache_list = (winattr_t *) calloc(n*sizeof(winattr_t), 1);
 		cache_list_len = n;
 	}
-	j = 0;
 	for (i=0; i<num; i++) {
-		cache_list[j].win = list[i];
-		cache_list[j].fetched = 0;
-		cache_list[j].valid = 0;
-		cache_list[j].time = now;
-		cache_list[j].selectinput = 0;
-		j++;
+		cache_list[i].win = list[i];
+		cache_list[i].fetched = 0;
+		cache_list[i].valid = 0;
+		cache_list[i].time = now;
+		cache_list[i].selectinput = 0;
+		cache_list[i].vis_cnt = 0;
+		cache_list[i].map_cnt = 0;
+		cache_list[i].unmap_cnt = 0;
+		cache_list[i].create_cnt = 0;
+		cache_list[i].vis_state = -1;
+		cache_list[i].above = None;
+	}
+	if (num == 0) {
+		cache_list[0].win = None;
+		cache_list[0].fetched = 0;
+		cache_list[0].valid = 0;
+		cache_list[0].time = now;
+		cache_list[0].selectinput = 0;
+		cache_list[0].vis_cnt = 0;
+		cache_list[0].map_cnt = 0;
+		cache_list[0].unmap_cnt = 0;
+		cache_list[0].create_cnt = 0;
+		cache_list[0].vis_state = -1;
+		cache_list[0].above = None;
+		num++;
 	}
+
 	cache_list_num = num;
-	XFree_wr(list);
-	X_UNLOCK;
+
+	if (num) {
+		X_LOCK;
+		XFree_wr(list);
+		X_UNLOCK;
+	}
 #endif	/* NO_X11 */
 }
 
+int get_bs_n(int y) {
+	int n;
+	for (n = 1; n < ncache; n += 2) {
+		if (n*dpy_y <= y && y < (n+1)*dpy_y) {
+			return n;
+		}
+	}
+	return -1;
+}
+
 #define NRECENT 32
 Window recent[NRECENT];
 int    recidx[NRECENT];
@@ -4642,16 +5584,18 @@ int rlast, rfree;
 int lookup_win_index(Window win) {
 	int k, idx = -1;
 	int foundfree = 0;
+	static int s1 = 0, s2 = 0, s3 = 0;
 
 	if (win == rootwin || win == None) {
-		return idx;
+		return -1;
 	}
 	for (k = 0; k < NRECENT; k++) {
 		if (recent[k] == win) {
 			int k2 = recidx[k];
 			if (cache_list[k2].win == win) {
 				idx = k2;
-fprintf(stderr, "recentA: %d  0x%x\n", idx, win);
+//fprintf(stderr, "recentA(shortcut): %d  0x%x\n", idx, win);
+				s1++;
 				break;
 			}
 		}
@@ -4664,7 +5608,8 @@ fprintf(stderr, "recentA: %d  0x%x\n", idx, win);
 			}
 			if (cache_list[k].win == win) {
 				idx = k;
-fprintf(stderr, "recentB: %d  0x%x\n", idx, win);
+//fprintf(stderr, "recentB(normal): %d  0x%x\n", idx, win);
+				s2++;
 				break;
 			}
 		}
@@ -4674,9 +5619,14 @@ fprintf(stderr, "recentB: %d  0x%x\n", idx, win);
 			rlast = rlast % NRECENT;
 		}
 	}
-if (idx < 0) {
-fprintf(stderr, "recentC: %d  0x%x\n", idx, win);
-}
+	if (idx < 0) {
+fprintf(stderr, "recentC(fail): %d  0x%x\n", idx, win);
+		s3++;
+	}
+	if (s1 + s2 + s3 >= 100) {
+fprintf(stderr, "lookup_win_index recent hit stats: %d/%d/%d\n", s1, s2, s3);
+		s1 = s2 = s3 = 0;
+	}
 	return idx;
 }
 
@@ -4697,12 +5647,36 @@ fprintf(stderr, "lookup_freeA: %d\n", rfree);
 		}
 	}
 	if (rfree < 0) {
+		fprintf(stderr, "*** LOOKUP_FREE_INDEX: incrementing cache_list_num %d/%d\n", cache_list_num, cache_list_len);
+
 		rfree = cache_list_num++;
 		if (rfree >= cache_list_len)  {
-			/* bad news... */
-			fprintf(stderr, "Whoops: %d %d\n", rfree, cache_list_len);
-		}
+			int i, n = 2*cache_list_len;
+			winattr_t *cache_new;
+
+			fprintf(stderr, "lookup_free_index: growing cache_list_len: %d -> %d\n", cache_list_len, n);
+
+			cache_new = (winattr_t *) calloc(n*sizeof(winattr_t), 1);
+			for (i=0; i<cache_list_num-1; i++) {
+				cache_new[i] = cache_list[i]; 
+			}
+			cache_list_len = n;
+			free(cache_list);
+			cache_list = cache_new;
+		}
+		cache_list[rfree].win = None;
+		cache_list[rfree].fetched = 0;
+		cache_list[rfree].valid = 0;
+		cache_list[rfree].time = 0.0;
+		cache_list[rfree].selectinput = 0;
+		cache_list[rfree].vis_cnt = 0;
+		cache_list[rfree].map_cnt = 0;
+		cache_list[rfree].unmap_cnt = 0;
+		cache_list[rfree].create_cnt = 0;
+		cache_list[rfree].vis_state = -1;
+		cache_list[rfree].above = None;
 	}
+
 fprintf(stderr, "lookup_freeB: %d\n", rfree);
 	return rfree;
 }
@@ -4727,121 +5701,89 @@ fprintf(stderr, "lookup_freeB: %d\n", rfree);
 	cache_list[k].su_y = -1;  \
 	cache_list[k].su_w = -1;  \
 	cache_list[k].su_h = -1;  \
+	cache_list[k].time = 0.0;  \
 	cache_list[k].bs_time = 0.0;  \
-	cache_list[k].su_time = 0.0; \
-	cache_list[k].selectinput = 0; 
+	cache_list[k].su_time = 0.0;
 
 #define DELETE(k) \
 	cache_list[k].win = None;  \
 	cache_list[k].fetched = 0;  \
 	cache_list[k].valid = 0; \
-	free_rect(k);
+	cache_list[k].selectinput = 0; \
+	cache_list[k].vis_cnt = 0; \
+	cache_list[k].map_cnt = 0; \
+	cache_list[k].unmap_cnt = 0; \
+	cache_list[k].create_cnt = 0; \
+	cache_list[k].vis_state = -1; \
+	cache_list[k].above = None; \
+	free_rect(k);	/* does CLEAR(k) */
+
+static	char unk[32];
 
 char *Etype(int type) {
-	if (type == KeyPress) return "KeyPress";
-	if (type == KeyRelease) return "KeyRelease";
-	if (type == ButtonPress) return "ButtonPress";
-	if (type == ButtonRelease) return "ButtonRelease";
-	if (type == MotionNotify) return "MotionNotify";
-	if (type == EnterNotify) return "EnterNotify";
-	if (type == LeaveNotify) return "LeaveNotify";
-	if (type == FocusIn) return "FocusIn";
-	if (type == FocusOut) return "FocusOut";
-	if (type == KeymapNotify) return "KeymapNotify";
-	if (type == Expose) return "Expose";
-	if (type == GraphicsExpose) return "GraphicsExpose";
-	if (type == NoExpose) return "NoExpose";
-	if (type == VisibilityNotify) return "VisibilityNotify";
-	if (type == CreateNotify) return "CreateNotify";
-	if (type == DestroyNotify) return "DestroyNotify";
-	if (type == UnmapNotify) return "UnmapNotify";
-	if (type == MapNotify) return "MapNotify";
-	if (type == MapRequest) return "MapRequest";
-	if (type == ReparentNotify) return "ReparentNotify";
-	if (type == ConfigureNotify) return "ConfigureNotify";
-	if (type == ConfigureRequest) return "ConfigureRequest";
-	if (type == GravityNotify) return "GravityNotify";
-	if (type == ResizeRequest) return "ResizeRequest";
-	if (type == CirculateNotify) return "CirculateNotify";
-	if (type == CirculateRequest) return "CirculateRequest";
-	if (type == PropertyNotify) return "PropertyNotify";
-	if (type == SelectionClear) return "SelectionClear";
-	if (type == SelectionRequest) return "SelectionRequest";
-	if (type == SelectionNotify) return "SelectionNotify";
-	if (type == ColormapNotify) return "ColormapNotify";
-	if (type == ClientMessage) return "ClientMessage";
-	if (type == MappingNotify) return "MappingNotify";
-	if (type == LASTEvent) return "LASTEvent";
-	return "Unknown";
+	if (type == KeyPress)		return "KeyPress";
+	if (type == KeyRelease)		return "KeyRelease";
+	if (type == ButtonPress)	return "ButtonPress";
+	if (type == ButtonRelease)	return "ButtonRelease";
+	if (type == MotionNotify)	return "MotionNotify";
+	if (type == EnterNotify)	return "EnterNotify";
+	if (type == LeaveNotify)	return "LeaveNotify";
+	if (type == FocusIn)		return "FocusIn";
+	if (type == FocusOut)		return "FocusOut";
+	if (type == KeymapNotify)	return "KeymapNotify";
+	if (type == Expose)		return "Expose";
+	if (type == GraphicsExpose)	return "GraphicsExpose";
+	if (type == NoExpose)		return "NoExpose";
+	if (type == VisibilityNotify)	return "VisibilityNotify";
+	if (type == CreateNotify)	return "CreateNotify";
+	if (type == DestroyNotify)	return "DestroyNotify";
+	if (type == UnmapNotify)	return "UnmapNotify";
+	if (type == MapNotify)		return "MapNotify";
+	if (type == MapRequest)		return "MapRequest";
+	if (type == ReparentNotify)	return "ReparentNotify";
+	if (type == ConfigureNotify)	return "ConfigureNotify";
+	if (type == ConfigureRequest)	return "ConfigureRequest";
+	if (type == GravityNotify)	return "GravityNotify";
+	if (type == ResizeRequest)	return "ResizeRequest";
+	if (type == CirculateNotify)	return "CirculateNotify";
+	if (type == CirculateRequest)	return "CirculateRequest";
+	if (type == PropertyNotify)	return "PropertyNotify";
+	if (type == SelectionClear)	return "SelectionClear";
+	if (type == SelectionRequest)	return "SelectionRequest";
+	if (type == SelectionNotify)	return "SelectionNotify";
+	if (type == ColormapNotify)	return "ColormapNotify";
+	if (type == ClientMessage)	return "ClientMessage";
+	if (type == MappingNotify)	return "MappingNotify";
+	if (type == LASTEvent)		return "LASTEvent";
+	sprintf(unk, "Unknown %d", type);
+	return unk;
 }
-sraRegionPtr rect_reg[32];
-
-int find_rect(int idx, int x, int y, int w, int h) {
-	static int first = 1;
-	sraRegionPtr r1, r2;
-	sraRectangleIterator *iter;
-	sraRect rt;
-	int n, x_hit = -1, y_hit = -1;
-
-	if (first) {
-		first = 0;
-		for (n = 1; n <= ncache; n++) {
-			rect_reg[n] = sraRgnCreateRect(0, n * dpy_y, dpy_x, (n+1) * dpy_y);
-		}
-	}
-
-	for (n = 1; n < ncache; n += 2) {
-		r1 = rect_reg[n];
-		r2 = NULL;
-		iter = sraRgnGetIterator(r1);
-		while (sraRgnIteratorNext(iter, &rt)) {
-			int rw = nabs(rt.x2 - rt.x1);
-			int rh = nabs(rt.y2 - rt.y1);
-			if (rw >= w && rh >= h) {
-				if (rt.x1 < rt.x2) {
-					x_hit = rt.x1;
-				} else {
-					x_hit = rt.x2;
-				}
-				if (rt.y1 < rt.y2) {
-					y_hit = rt.y1;
-				} else {
-					y_hit = rt.y2;
-				}
-				r2 = sraRgnCreateRect(x_hit, y_hit, x_hit + w, y_hit + h);
-				break;
-			}
-		}
-		sraRgnReleaseIterator(iter);
-		if (r2 != NULL) {
-			sraRgnSubtract(r1, r2);
-			sraRgnDestroy(r2);
-			break;
-		}
-	}
-	if (x_hit < 0) {
-		/* bad news */
-		fprintf(stderr, "*FAIL rect: %d %d %d %d -- %d %d\n", x, y, w, h, x_hit, y_hit);
-	} else {
-		fprintf(stderr, "found rect: %d %d %d %d -- %d %d\n", x, y, w, h, x_hit, y_hit);
-	}
-
-	cache_list[idx].bs_x = x_hit;
-	cache_list[idx].bs_y = y_hit;
-	cache_list[idx].bs_w = w;
-	cache_list[idx].bs_h = h;
-
-	cache_list[idx].su_x = x_hit;
-	cache_list[idx].su_y = y_hit + dpy_y;
-	cache_list[idx].su_w = w;
-	cache_list[idx].su_h = h;
+char *VState(int state) {
+	if (state == VisibilityFullyObscured)		return "VisibilityFullyObscured";
+	if (state == VisibilityPartiallyObscured)	return "VisibilityPartiallyObscured";
+	if (state == VisibilityUnobscured)		return "VisibilityUnobscured";
+	sprintf(unk, "Unknown %d", state);
+	return unk;
+}
+char *MState(int state) {
+	if (state == IsViewable)	return "IsViewable";
+	if (state == IsUnmapped)	return "IsUnmapped";
+	sprintf(unk, "Unknown %d", state);
+	return unk;
 }
+sraRegionPtr rect_reg[64];
+sraRegionPtr zero_rects = NULL;
 
 int free_rect(int idx) {
 	int n, ok = 0;
 	sraRegionPtr r1, r2;
 	int x, y, w, h;
 
+	if (idx < 0 || idx >= cache_list_num) {
+fprintf(stderr, "free_rect: bad index: %d\n", idx);
+		clean_up_exit(1);
+	}
+
 	x = cache_list[idx].bs_x;
 	y = cache_list[idx].bs_y;
 	w = cache_list[idx].bs_w;
@@ -4849,161 +5791,960 @@ int free_rect(int idx) {
 
 	if (x < 0) {
 		CLEAR(idx);
-fprintf(stderr, "free_rect: invalid: %d\n", idx);
-		return 0;
+if (dnow() > last_client + 5) fprintf(stderr, "free_rect: already bs_x invalidated: %d bs_x: %d\n", idx, x);
+		return 1;
 	}
 
 	r2 = sraRgnCreateRect(x, y, x+w, y+h);
 
-	for (n = 1; n < ncache; n += 2) {
-		if (y >= n*dpy_y && y < (n+1)*dpy_y) {
-			r1 = rect_reg[n];
-			sraRgnOr(r1, r2);
-			ok = 1;
-fprintf(stderr, "free_rect: found %d region: %d\n", idx, n);
-			break;
+	n = get_bs_n(y);
+	if (n >= 0) {
+		r1 = rect_reg[n];
+		sraRgnOr(r1, r2);
+		ok = 1;
+	}
+
+	if (zero_rects) {
+		sraRgnOr(zero_rects, r2);
+		x = cache_list[idx].su_x;
+		y = cache_list[idx].su_y;
+		w = cache_list[idx].su_w;
+		h = cache_list[idx].su_h;
+		if (x >= 0) {
+			sraRgnDestroy(r2);
+			r2 = sraRgnCreateRect(x, y, x+w, y+h);
+			sraRgnOr(zero_rects, r2);
 		}
 	}
 	sraRgnDestroy(r2);
 
 	CLEAR(idx);
-if (! ok) fprintf(stderr, "free_rect: not-found %d\n", idx);
+if (! ok) fprintf(stderr, "**** free_rect: not-found %d\n", idx);
 	return ok;
 }
 
-int bs_save(int idx) {
-	Window win = cache_list[idx].win;
-	XWindowAttributes attr;
-	int x1, y1, w1, h1;
-	int x2, y2, w2, h2;
-	int x, y, w, h;
-	int dx, dy;
-	sraRegionPtr r;
-	
-
-	x1 = cache_list[idx].x;
-	y1 = cache_list[idx].y;
-	w1 = cache_list[idx].width;
-	h1 = cache_list[idx].height;
-	
-	if (! valid_window(win, &attr, 1)) {
-fprintf(stderr, "bs_save: not valid\n");
-//		DELETE(idx);
-		return 0;
-	}
-
-	x2 = attr.x;
-	y2 = attr.y;
-	w2 = attr.width;
-	h2 = attr.height;
+int fr_BIG1 = 0;
+int fr_BIG2 = 0;
+int fr_REGION = 0;
+int fr_GRID = 0;
+int fr_EXPIRE = 0;
+int fr_FORCE = 0;
+int fr_FAIL = 0;
+int fr_BIG1t = 0;
+int fr_BIG2t = 0;
+int fr_REGIONt = 0;
+int fr_GRIDt = 0;
+int fr_EXPIREt = 0;
+int fr_FORCEt = 0;
+int fr_FAILt = 0;
+
+void expire_rects1(int idx, int w, int h, int *x_hit, int *y_hit, int big1, int big2, int cram) {
+	sraRegionPtr r1, r2, r3;
+	sraRectangleIterator *iter;
+	sraRect rt;
+	int x, y, n;
 
-	if (cache_list[idx].bs_x < 0 || w2 > cache_list[idx].bs_w || h2 > cache_list[idx].bs_h) {
-		find_rect(idx, x2, y2, w2, h2);
-	}
-	x = cache_list[idx].bs_x;
-	y = cache_list[idx].bs_y;
-	w = cache_list[idx].bs_w;
-	h = cache_list[idx].bs_h;
+	if (*x_hit < 0) {
+		int i, k, old[10], N = 4;
+		double dold[10], fa, d, d1, d2, d3;
+		int a0 = w * h, a1;
 
-	if (x < 0) {
-		STORE(idx, win, attr);
-		return 0;
-	}
+		for (k=1; k<=N; k++) {
+			old[k] = -1;
+			dold[k] = -1.0;
+		}
+		for (i=0; i<cache_list_num; i++) {
+			int wb = cache_list[i].bs_w;
+			int hb = cache_list[i].bs_h;
+			if (cache_list[i].bs_x < 0) {
+				continue;
+			}
+			if (w > wb || h > hb) {
+				continue;
+			}
+			if (wb == 0 || hb == 0) {
+				continue;
+			}
+			if (a0 == 0) {
+				continue;
+			}
+			if (i == idx) {
+				continue;
+			}
+			a1 = wb * hb;
+			fa = ((double) a1) / a0;
+			k = (int) fa;
 
-	dx = x - x2; 
-	dy = y - y2; 
+			if (k < 1) k = 1;
+			if (k > N) continue;
 
-	r = sraRgnCreateRect(x2+dx, y2+dy, x2+w2+dx, y2+h2+dy);
-fprintf(stderr, "bs_save: dx=%d dy=%d\n", dx, dy);
-	do_copyregion(r, dx, dy);
-	fb_push_wait(0.01, FB_COPY);
-fprintf(stderr, "bs_save: done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].bs_time, dnow());
-	sraRgnDestroy(r);
+			d1 = cache_list[i].time;
+			d2 = cache_list[i].bs_time;
+			d3 = cache_list[i].su_time;
 
-	STORE(idx, win, attr);
-	cache_list[idx].bs_time = dnow();
-	
-	return 1;
-}
+			d = d1;
+			if (d2 > d) d = d2;
+			if (d3 > d) d = d3;
 
-int su_save(int idx) {
-	Window win = cache_list[idx].win;
-	XWindowAttributes attr;
-	int x1, y1, w1, h1;
-	int x2, y2, w2, h2;
-	int x, y, w, h;
-	int dx, dy;
-	sraRegionPtr r;
-	
+			if (dold[k] == -1.0 || d < dold[k]) {
+				old[k] = i;
+				dold[k] = d;
+			}
+		}
 
-	x1 = cache_list[idx].x;
-	y1 = cache_list[idx].y;
-	w1 = cache_list[idx].width;
-	h1 = cache_list[idx].height;
-	
-	if (! valid_window(win, &attr, 1)) {
-fprintf(stderr, "su_save: not valid\n");
-//		DELETE(idx);
-		return 0;
+		for (k=1; k<=N; k++) {
+			if (old[k] >= 0) {
+				int ik = old[k];
+				int k_x = cache_list[ik].bs_x;
+				int k_y = cache_list[ik].bs_y;
+				int k_w = cache_list[ik].bs_w;
+				int k_h = cache_list[ik].bs_h;
+
+fprintf(stderr, ">>**--**>> found rect via EXPIRE: %d 0x%x -- %dx%d+%d+%d %d %d --  %dx%d+%d+%d  A: %d/%d\n",
+    ik, cache_list[ik].win, w, h, x, y, *x_hit, *y_hit, k_w, k_h, k_x, k_y, k_w * k_h, w * h);
+
+				free_rect(ik);
+				fr_EXPIRE++;
+				fr_EXPIREt++;
+				*x_hit = k_x;
+				*y_hit = k_y;
+				n = get_bs_n(*y_hit);
+				if (n >= 0) {
+					r1 = rect_reg[n];
+					r2 = sraRgnCreateRect(*x_hit, *y_hit, *x_hit + w, *y_hit + h);
+					sraRgnSubtract(r1, r2);
+					sraRgnDestroy(r2);
+				} else {
+					fprintf(stderr, "failure to find y n in find_rect\n");
+					clean_up_exit(1);
+				}
+				break;
+			}
+		}
 	}
 
-	x2 = attr.x;
-	y2 = attr.y;
-	w2 = attr.width;
-	h2 = attr.height;
+	/* next, force ourselves into some corner, expiring many */
+	if (*x_hit < 0) {
+		int corner_x = (int) (2 * rfac());
+		int corner_y = (int) (2 * rfac());
+		int x0 = 0, y0 = 0, i, nrand, nr = ncache/2;
+		if (nr == 1) {
+			nrand = 1;
+		} else {
+			if (! big1) {
+				nrand = 1;
+			} else {
+				if (big2 && nr > 2) {
+					nrand =  1 + (int) ((nr - 2) * rfac());
+					nrand += 2; 
+				} else {
+					nrand =  1 + (int) ((nr - 1) * rfac());
+					nrand += 1; 
+				}
+			}
+		}
+		if (nrand < 0 || nrand > nr) {
+			nrand = nr;
+		}
+		if (cram && big1) {
+			corner_x = 1;
+		}
 
-	if (cache_list[idx].su_x < 0 || w2 > cache_list[idx].su_w || h2 > cache_list[idx].su_h) {
-		find_rect(idx, x2, y2, w2, h2);
-	}
-	x = cache_list[idx].su_x;
-	y = cache_list[idx].su_y;
-	w = cache_list[idx].su_w;
-	h = cache_list[idx].su_h;
+		y0 += dpy_y; 
+		if (nrand > 1) {
+			y0 += 2 * (nrand - 1) * dpy_y; 
+		}
+		if (corner_y) {
+			y0 += dpy_y - h; 
+		}
+		if (corner_x) {
+			x0 += dpy_x - w; 
+		}
+		r1 = sraRgnCreateRect(x0, y0, x0+w, y0+h);
 
-	if (x < 0) {
-		STORE(idx, win, attr);
-		return 0;
-	}
+		for (i=0; i<cache_list_num; i++) {
+			int xb = cache_list[i].bs_x;
+			int yb = cache_list[i].bs_y;
+			int wb = cache_list[i].bs_w;
+			int hb = cache_list[i].bs_h;
+			if (xb < 0) {
+				continue;
+			}
+			if (nabs(yb - y0) > dpy_y) {
+				continue;
+			}
+			r2 = sraRgnCreateRect(xb, yb, xb+wb, yb+hb);
+			if (sraRgnAnd(r2, r1)) {
+				free_rect(i);
+			}
+			sraRgnDestroy(r2);
+		}
+		*x_hit = x0;
+		*y_hit = y0;
+		r3 = rect_reg[2*nrand-1];
+		sraRgnSubtract(r3, r1);
+		sraRgnDestroy(r1);
 
-	dx = x - x2; 
-	dy = y - y2; 
+fprintf(stderr, ">>**--**>> found rect via FORCE: %dx%d+%d+%d -- %d %d\n", w, h, x, y, *x_hit, *y_hit);
 
-	r = sraRgnCreateRect(x2+dx, y2+dy, x2+w2+dx, y2+h2+dy);
-fprintf(stderr, "su_save: dx=%d dy=%d\n", dx, dy);
-	do_copyregion(r, dx, dy);
-	fb_push_wait(0.01, FB_COPY);
-fprintf(stderr, "su_save: done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].su_time, dnow());
-	sraRgnDestroy(r);
+		fr_FORCE++;
+		fr_FORCEt++;
+	}
+}
+
+void expire_rects2(int idx, int w, int h, int *x_hit, int *y_hit, int big1, int big2, int cram) {
+	sraRegionPtr r1, r2, r3;
+	int x, y, n, i, j, k;
+	int nwgt_max = 128, nwgt = 0;
+	int type[128];
+	int val[4][128];
+	double wgt[128], norm;
+	int Expire = 1, Force = 2;
+	int do_expire = 1;
+	int do_force = 1;
+	double now = dnow(), r;
+
+	if (do_expire) {
+		int old[10], N = 4;
+		double dold[10], fa, d, d1, d2, d3;
+		int a0 = w * h, a1;
+
+		for (k=1; k<=N; k++) {
+			old[k] = -1;
+			dold[k] = -1.0;
+		}
+		for (i=0; i<cache_list_num; i++) {
+			int wb = cache_list[i].bs_w;
+			int hb = cache_list[i].bs_h;
+			if (cache_list[i].bs_x < 0) {
+				continue;
+			}
+			if (w > wb || h > hb) {
+				continue;
+			}
+			if (wb == 0 || hb == 0) {
+				continue;
+			}
+			if (a0 == 0) {
+				continue;
+			}
+			if (i == idx) {
+				continue;
+			}
+
+			a1 = wb * hb;
+			fa = ((double) a1) / a0;
+			k = (int) fa;
+
+			if (k < 1) k = 1;
+			if (k > N) continue;
+
+			d1 = cache_list[i].time;
+			d2 = cache_list[i].bs_time;
+			d3 = cache_list[i].su_time;
+
+			d = d1;
+			if (d2 > d) d = d2;
+			if (d3 > d) d = d3;
+
+			if (dold[k] == -1.0 || d < dold[k]) {
+				old[k] = i;
+				dold[k] = d;
+			}
+		}
+
+		for (k=1; k<=N; k++) {
+			if (old[k] >= 0) {
+				int ik = old[k];
+				int k_w = cache_list[ik].bs_w;
+				int k_h = cache_list[ik].bs_h;
+
+				wgt[nwgt] =  (now - dold[k]) / (k_w * k_h);
+				type[nwgt] = Expire;
+				val[0][nwgt] = ik;
+fprintf(stderr, "Expire[%02d]   %9.5f  age=%9.4f  area=%8d  need=%8d\n", nwgt, 10000 * wgt[nwgt], now - dold[k], k_w * k_h, w*h);
+				nwgt++;
+				if (nwgt >= nwgt_max) {
+					break;
+				}
+			}
+		}
+	}
+
+	/* next, force ourselves into some corner, expiring many rect */
+	if (do_force) {
+		int corner_x, corner_y;
+		int x0, y0;
+		double nfac = 1.0;
+
+		for (n = 1; n < ncache; n += 2) {
+		    if (big1 && ncache > 2 && n == 1) {
+			continue;
+		    }
+		    if (big2 && ncache > 4 && n <= 3) {
+			continue;
+		    }
+		    for (corner_x = 0; corner_x < 2; corner_x++) {
+			if (cram && big1 && corner_x == 0) {
+				continue;
+			}
+			for (corner_y = 0; corner_y < 2; corner_y++) {
+				double age = 0.0, area = 0.0, a;
+				double d, d1, d2, d3, score;
+				int nc = 0;
+
+				x0 = 0;
+				y0 = 0;
+				y0 += n * dpy_y; 
+
+				if (corner_y) {
+					y0 += dpy_y - h; 
+				}
+				if (corner_x) {
+					x0 += dpy_x - w; 
+				}
+				r1 = sraRgnCreateRect(x0, y0, x0+w, y0+h);
+
+				for (i=0; i<cache_list_num; i++) {
+					int xb = cache_list[i].bs_x;
+					int yb = cache_list[i].bs_y;
+					int wb = cache_list[i].bs_w;
+					int hb = cache_list[i].bs_h;
+
+					if (xb < 0) {
+						continue;
+					}
+					if (nabs(yb - y0) > dpy_y) {
+						continue;
+					}
+
+					r2 = sraRgnCreateRect(xb, yb, xb+wb, yb+hb);
+					if (! sraRgnAnd(r2, r1)) {
+						sraRgnDestroy(r2);
+						continue;
+					}
+					sraRgnDestroy(r2);
+
+					a = wb * hb;
+
+					d1 = cache_list[i].time;
+					d2 = cache_list[i].bs_time;
+					d3 = cache_list[i].su_time;
+
+					d = d1;
+					if (d2 > d) d = d2;
+					if (d3 > d) d = d3;
+
+					area += a;
+					age +=  (now - d) * a;
+					nc++;
+				}
+				if (nc == 0) {
+					score = 999999.9;
+				} else {
+					age = age / area;
+					score = age / area;
+				}
+
+				wgt[nwgt] =  score;
+				type[nwgt] = Force;
+				val[0][nwgt] = n;
+				val[1][nwgt] = x0;
+				val[2][nwgt] = y0;
+fprintf(stderr, "Force [%02d]   %9.5f  age=%9.4f  area=%8d  need=%8d\n", nwgt, 10000 * wgt[nwgt], age, (int) area, w*h);
+				nwgt++;
+				if (nwgt >= nwgt_max) break;
+				sraRgnDestroy(r1);
+			}
+			if (nwgt >= nwgt_max) break;
+		    }
+		    if (nwgt >= nwgt_max) break;
+		}
+	}
+
+	if (nwgt == 0) {
+fprintf(stderr, "nwgt=0\n");
+		*x_hit = -1;
+		return;
+	}
+
+	norm = 0.0;
+	for (i=0; i < nwgt; i++) {
+		norm += wgt[i];
+	}
+	for (i=0; i < nwgt; i++) {
+		wgt[i] /= norm; 
+	}
+
+	r = rfac();
+
+	norm = 0.0;
+	for (j=0; j < nwgt; j++) {
+		norm += wgt[j];
+fprintf(stderr, "j=%2d  acc=%.6f r=%.6f\n", j, norm, r); 
+		if (r < norm) {
+			break;
+		}
+	}
+	if (j >= nwgt) {
+		j = nwgt - 1;
+	}
+
+	if (type[j] == Expire) {
+		int ik = val[0][j];
+		int k_x = cache_list[ik].bs_x;
+		int k_y = cache_list[ik].bs_y;
+		int k_w = cache_list[ik].bs_w;
+		int k_h = cache_list[ik].bs_h;
+
+fprintf(stderr, ">>**--**>> found rect [%d] via RAN EXPIRE: %d 0x%x -- %dx%d+%d+%d %d %d --  %dx%d+%d+%d  A: %d/%d\n",
+	get_bs_n(*y_hit), ik, cache_list[ik].win, w, h, x, y, *x_hit, *y_hit, k_w, k_h, k_x, k_y, k_w * k_h, w * h);
+
+		free_rect(ik);
+		fr_EXPIRE++;
+		fr_EXPIREt++;
+		*x_hit = k_x;
+		*y_hit = k_y;
+		n = get_bs_n(*y_hit);
+		if (n >= 0) {
+			r1 = rect_reg[n];
+			r2 = sraRgnCreateRect(*x_hit, *y_hit, *x_hit + w, *y_hit + h);
+			sraRgnSubtract(r1, r2);
+			sraRgnDestroy(r2);
+		} else {
+			fprintf(stderr, "failure to find y n in find_rect\n");
+			clean_up_exit(1);
+		}
+		
+	} else if (type[j] == Force) {
+
+		int x0 = val[1][j];
+		int y0 = val[2][j];
+		n = val[0][j];
+		
+		r1 = sraRgnCreateRect(x0, y0, x0+w, y0+h);
+
+		for (i=0; i<cache_list_num; i++) {
+			int xb = cache_list[i].bs_x;
+			int yb = cache_list[i].bs_y;
+			int wb = cache_list[i].bs_w;
+			int hb = cache_list[i].bs_h;
+			if (xb < 0) {
+				continue;
+			}
+			if (nabs(yb - y0) > dpy_y) {
+				continue;
+			}
+			r2 = sraRgnCreateRect(xb, yb, xb+wb, yb+hb);
+			if (sraRgnAnd(r2, r1)) {
+				free_rect(i);
+			}
+			sraRgnDestroy(r2);
+		}
+		*x_hit = x0;
+		*y_hit = y0;
+		r3 = rect_reg[2*n-1];
+		sraRgnSubtract(r3, r1);
+		sraRgnDestroy(r1);
+
+fprintf(stderr, ">>**--**>> found rect [%d] via RAN FORCE: %dx%d+%d+%d -- %d %d\n", n, w, h, x, y, *x_hit, *y_hit);
+
+		fr_FORCE++;
+		fr_FORCEt++;
+	}
+}
+
+void expire_rects(int idx, int w, int h, int *x_hit, int *y_hit, int big1, int big2, int cram) {
+	int method = 2;
+	if (method == 1) {
+		expire_rects1(idx, w, h, x_hit, y_hit, big1, big2, cram);
+	} else if (method == 2) {
+		expire_rects2(idx, w, h, x_hit, y_hit, big1, big2, cram);
+	}
+}
+
+int find_rect(int idx, int x, int y, int w, int h) {
+	sraRegionPtr r1, r2, r3;
+	sraRectangleIterator *iter;
+	sraRect rt;
+	int n, x_hit = -1, y_hit = -1;
+	int big1 = 0, big2 = 0, cram = 0;
+	double fac1 = 0.1, fac2 = 0.25;
+	double last_clean = 0.0;
+	double now = dnow();
+
+	if (rect_reg[1] == NULL) {
+		for (n = 1; n <= ncache; n++) {
+			rect_reg[n] = sraRgnCreateRect(0, n * dpy_y, dpy_x, (n+1) * dpy_y);
+		}
+	} else if (now > last_clean + 60) {
+//fprintf(stderr, "free_rect: cleaning up regions:\n");
+		last_clean = now;
+		for (n = 1; n < ncache; n += 2) {
+			int i, n2 = n+1;
+
+			/* n */
+			sraRgnDestroy(rect_reg[n]);
+			r1 = sraRgnCreateRect(0, n * dpy_y, dpy_x, (n+1) * dpy_y);
+			for (i=0; i<cache_list_num; i++) {
+				int bs_x = cache_list[i].bs_x;
+				int bs_y = cache_list[i].bs_y;
+				int bs_w = cache_list[i].bs_w;
+				int bs_h = cache_list[i].bs_h;
+				if (bs_x < 0) {
+					continue;
+				}
+				if (get_bs_n(bs_y) != n) {
+					continue;
+				}
+				r2 = sraRgnCreateRect(bs_x, bs_y, bs_x+bs_w, bs_y+bs_h);
+				sraRgnSubtract(r1, r2);
+			}
+			rect_reg[n] = r1;
+
+			/* n+1 */
+			sraRgnDestroy(rect_reg[n2]);
+			r1 = sraRgnCreateRect(0, n2 * dpy_y, dpy_x, (n2+1) * dpy_y);
+			for (i=0; i<cache_list_num; i++) {
+				int bs_x = cache_list[i].bs_x;
+				int su_x = cache_list[i].su_x;
+				int su_y = cache_list[i].su_y;
+				int su_w = cache_list[i].su_w;
+				int su_h = cache_list[i].su_h;
+				if (bs_x < 0) {
+					continue;
+				}
+				if (get_bs_n(su_y) != n2) {
+					continue;
+				}
+				r2 = sraRgnCreateRect(su_x, su_y, su_x+su_w, su_y+su_h);
+				sraRgnSubtract(r1, r2);
+			}
+			rect_reg[n2] = r1;
+		}
+	}
+
+	if (idx < 0 || idx >= cache_list_num) {
+fprintf(stderr, "free_rect: bad index: %d\n", idx);
+		clean_up_exit(1);
+	}
+
+	cache_list[idx].bs_x = -1;
+	cache_list[idx].su_x = -1;
+	cache_list[idx].bs_time = 0.0;
+	cache_list[idx].su_time = 0.0;
+
+	if (ncache_pad) {
+		x -= ncache_pad;	
+		y -= ncache_pad;	
+		w += 2 * ncache_pad;	
+		h += 2 * ncache_pad;	
+	}
+
+	if (ncache <= 2) {
+		cram = 1;
+		fac2 = 0.45;
+	} else if (ncache <= 4) {
+		fac1 = 0.18;
+		fac2 = 0.35;
+	}
+	if (w * h > fac1 * (dpy_x * dpy_y)) {
+		big1 = 1;
+	}
+	if (w * h > fac2 * (dpy_x * dpy_y)) {
+		big2 = 1;
+	}
+
+	if (w > dpy_x || h > dpy_y) {
+fprintf(stderr, ">>**--**>> BIG1 rect: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+		fr_BIG1++;
+		fr_BIG1t++;
+		return 0;
+	}
+	if (w == dpy_x && h && dpy_y) {
+fprintf(stderr, ">>**--**>> BIG1 rect: %dx%d+%d+%d -- %d %d (FULL DISPLAY)\n", w, h, x, y, x_hit, y_hit);
+		fr_BIG1++;
+		fr_BIG1t++;
+		return 0;
+	}
+	if (cram && big2) {
+fprintf(stderr, ">>**--**>> BIG2 rect: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+		fr_BIG2++;
+		fr_BIG2t++;
+		return 0;
+	}
+
+	/* first try individual rects of unused region */
+	for (n = 1; n < ncache; n += 2) {
+		r1 = rect_reg[n];
+		r2 = NULL;
+		if (big1 && n == 1 && ncache > 2) {
+			continue;
+		}
+		if (big2 && n <= 3 && ncache > 4) {
+			continue;
+		}
+		iter = sraRgnGetIterator(r1);
+		while (sraRgnIteratorNext(iter, &rt)) {
+			int rw = rt.x2 - rt.x1;
+			int rh = rt.y2 - rt.y1;
+			if (cram && big1 && rt.x1 < dpy_x/4) {
+				continue;
+			}
+			if (rw >= w && rh >= h) {
+				x_hit = rt.x1;
+				y_hit = rt.y1;
+				if (cram && big1) {
+					x_hit = rt.x2 - w;
+				}
+				r2 = sraRgnCreateRect(x_hit, y_hit, x_hit + w, y_hit + h);
+				break;
+			}
+		}
+		sraRgnReleaseIterator(iter);
+		if (r2 != NULL) {
+fprintf(stderr, ">>**--**>> found rect via REGION: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+			fr_REGION++;
+			fr_REGIONt++;
+			sraRgnSubtract(r1, r2);
+			sraRgnDestroy(r2);
+			break;
+		}
+	}
+
+	
+	/* next try moving corner to grid points */
+	if (x_hit < 0) {
+	    for (n = 1; n < ncache; n += 2) {
+		int rx, ry, Nx = 48, Ny = 24, ny = n * dpy_y;
+
+		if (big1 && n == 1 && ncache > 2) {
+			continue;
+		}
+		if (big2 && n == 3 && ncache > 4) {
+			continue;
+		}
+
+		r1 = sraRgnCreateRect(0, n * dpy_y, dpy_x, (n+1) * dpy_y);
+		sraRgnSubtract(r1, rect_reg[n]);
+		r2 = NULL;
+
+		rx = 0;
+		while (rx + w <= dpy_x) {
+		    ry = 0;
+		    if (cram && big1 && rx < dpy_x/4) {
+			rx += dpy_x/Nx;
+		    	continue;
+		    }
+		    while (ry + h <= dpy_y) {
+			r2 = sraRgnCreateRect(rx, ry+ny, rx + w, ry+ny + h);
+			if (sraRgnAnd(r2, r1)) {
+				sraRgnDestroy(r2);
+				r2 = NULL;
+			} else {
+				sraRgnDestroy(r2);
+				r2 = sraRgnCreateRect(rx, ry+ny, rx + w, ry+ny + h);
+				x_hit = rx;
+				y_hit = ry+ny;
+			}
+			ry += dpy_y/Ny;
+			if (r2) break;
+		    }
+		    rx += dpy_x/Nx;
+		    if (r2) break;
+		}
+		sraRgnDestroy(r1);
+		if (r2 != NULL) {
+			sraRgnSubtract(rect_reg[n], r2);
+			sraRgnDestroy(r2);
+fprintf(stderr, ">>**--**>> found rect via GRID: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+			fr_GRID++;
+			fr_GRIDt++;
+			break;
+		}
+	    }
+	}
+
+	/* next, try expiring the oldest/smallest used bs/su rectangle we fit in */
+
+	if (x_hit < 0) {
+		expire_rects(idx, w, h, &x_hit, &y_hit, big1, big2, cram);
+	}
+
+	cache_list[idx].bs_x = x_hit;
+	cache_list[idx].bs_y = y_hit;
+	cache_list[idx].bs_w = w;
+	cache_list[idx].bs_h = h;
+
+	cache_list[idx].su_x = x_hit;
+	cache_list[idx].su_y = y_hit + dpy_y;
+	cache_list[idx].su_w = w;
+	cache_list[idx].su_h = h;
+
+	if (x_hit < 0) {
+		/* bad news, can it still happen? */
+		fprintf(stderr, ">>**--**>> *FAIL rect: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+		fr_FAIL++;
+		fr_FAILt++;
+		return 0;
+	} else {
+		//fprintf(stderr, ">>**--**>> found rect: %dx%d+%d+%d -- %d %d\n", w, h, x, y, x_hit, y_hit);
+	}
+
+	if (zero_rects) {
+		r1 = sraRgnCreateRect(x_hit, y_hit, x_hit+w, y_hit+h);
+		sraRgnSubtract(zero_rects, r1);
+		sraRgnDestroy(r1);
+		r1 = sraRgnCreateRect(x_hit, y_hit+dpy_y, x_hit+w, y_hit+dpy_y+h);
+		sraRgnSubtract(zero_rects, r1);
+		sraRgnDestroy(r1);
+	}
+
+	return 1;
+}
+
+static void cache_cr(sraRegionPtr r, int dx, int dy, double d0, double d1, int *nbatch) {
+	if (sraRgnEmpty(r)) {
+		return;
+	}
+	if (nbatch == NULL) {
+		if (!fb_push_wait(d0, FB_COPY)) {
+			fb_push_wait(d0/2, FB_COPY);
+		}
+		do_copyregion(r, dx, dy, 0);
+		if (!fb_push_wait(d1, FB_COPY)) {
+			fb_push_wait(d1/2, FB_COPY);
+		}
+	} else {
+		batch_dxs[*nbatch] = dx;
+		batch_dys[*nbatch] = dy;
+		batch_reg[*nbatch] = sraRgnCreateRgn(r);
+		(*nbatch)++;
+	}
+}
+
+double save_delay0    = 0.02;
+double restore_delay0 = 0.02;
+double save_delay1    = 0.05;
+double restore_delay1 = 0.05;
+static double dtA, dtB;
+
+int valid_wr(int idx, Window win, XWindowAttributes *attr) {
+#ifdef MACOSX
+	if (macosx_console) {
+		/* this is all to avoid animation changing WxH+X+Y... */
+		if (idx >= 0) {
+			int rc = valid_window(win, attr, 1);
+			attr->x = cache_list[idx].x;
+			attr->y = cache_list[idx].y;
+			attr->width = cache_list[idx].width;
+			attr->height = cache_list[idx].height;
+			return rc;
+		} else {
+			return valid_window(win, attr, 1);
+		}
+	}
+#endif
+	return valid_window(win, attr, 1);
+}
+
+int bs_save(int idx, int *nbatch) {
+	Window win = cache_list[idx].win;
+	XWindowAttributes attr;
+	int x1, y1, w1, h1;
+	int x2, y2, w2, h2;
+	int x, y, w, h;
+	int dx, dy, rc = 1;
+	sraRegionPtr r, r0;
+	
+	x1 = cache_list[idx].x;
+	y1 = cache_list[idx].y;
+	w1 = cache_list[idx].width;
+	h1 = cache_list[idx].height;
+
+fprintf(stderr, "backingstore save:       0x%x  %3d \n", win, idx);
+	
+	X_LOCK;
+	if (! valid_wr(idx, win, &attr)) {
+fprintf(stderr, "bs_save:    not a valid X window: 0x%x\n", win);
+/* XXX Y */
+//		DELETE(idx);
+		X_UNLOCK;
+		cache_list[idx].valid = 0;
+		return 0;
+	}
+	X_UNLOCK;
+
+	x2 = attr.x;
+	y2 = attr.y;
+	w2 = attr.width;
+	h2 = attr.height;
+
+	if (cache_list[idx].bs_x < 0) {
+		rc = find_rect(idx, x2, y2, w2, h2);
+	} else if (w2 > cache_list[idx].bs_w || h2 > cache_list[idx].bs_h) {
+		free_rect(idx);
+		rc = find_rect(idx, x2, y2, w2, h2);
+	}
+
+	x = cache_list[idx].bs_x;
+	y = cache_list[idx].bs_y;
+	w = cache_list[idx].bs_w;
+	h = cache_list[idx].bs_h;
+
+	if (x < 0 || ! rc) {
+		STORE(idx, win, attr);
+fprintf(stderr, "BS_save: FAIL FOR: %d\n", idx);
+		return 0;
+	}
+
+	if (ncache_pad) {
+		x2 -= ncache_pad;	
+		y2 -= ncache_pad;	
+		w2 += 2 * ncache_pad;	
+		h2 += 2 * ncache_pad;	
+	}
+
+	if (clipshift) {
+		x2 -= coff_x;
+		y2 -= coff_y;
+	}
+
+	dx = x - x2; 
+	dy = y - y2; 
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r = sraRgnCreateRect(x2, y2, x2+w2, y2+h2);
+	sraRgnAnd(r, r0);
+	sraRgnOffset(r, dx, dy);
+
+	dtA =  dnowx();
+fprintf(stderr, "BS_save: %.4f      %d dx=%d dy=%d\n", dtA, idx, dx, dy);
+	if (w2 > 0 && h2 > 0) {
+		cache_cr(r, dx, dy, save_delay0, save_delay1, nbatch);
+	}
+	dtB =  dnowx();
+fprintf(stderr, "BS_save: %.4f %.2f %d done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", dtB, dtB-dtA, idx, w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].bs_time - x11vnc_start, dnowx());
+
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r);
 
 	STORE(idx, win, attr);
-	cache_list[idx].su_time = dnow();
+	cache_list[idx].bs_time = dnow();
 	
 	return 1;
 }
 
-int bs_restore(int idx) {
+int su_save(int idx, int *nbatch) {
 	Window win = cache_list[idx].win;
 	XWindowAttributes attr;
 	int x1, y1, w1, h1;
 	int x2, y2, w2, h2;
 	int x, y, w, h;
-	int dx, dy;
-	sraRegionPtr r;
+	int dx, dy, rc = 1;
+	sraRegionPtr r, r0;
+	
+fprintf(stderr, "save-unders save:        0x%x  %3d \n", win, idx);
+
+	x1 = cache_list[idx].x;
+	y1 = cache_list[idx].y;
+	w1 = cache_list[idx].width;
+	h1 = cache_list[idx].height;
 	
-	if (cache_list[idx].bs_x < 0 || cache_list[idx].bs_time == 0.0) {
+	X_LOCK;
+	if (! valid_wr(idx, win, &attr)) {
+fprintf(stderr, "su_save:    not a valid X window: 0x%x\n", win);
+/* XXX Y */
+//		DELETE(idx);
+		X_UNLOCK;
+		cache_list[idx].valid = 0;
 		return 0;
 	}
+	X_UNLOCK;
+
+	x2 = attr.x;
+	y2 = attr.y;
+	w2 = attr.width;
+	h2 = attr.height;
+
+	if (cache_list[idx].bs_x < 0) {
+		rc = find_rect(idx, x2, y2, w2, h2);
+	} else if (w2 > cache_list[idx].su_w || h2 > cache_list[idx].su_h) {
+		free_rect(idx);
+		rc = find_rect(idx, x2, y2, w2, h2);
+	}
+	x = cache_list[idx].su_x;
+	y = cache_list[idx].su_y;
+	w = cache_list[idx].su_w;
+	h = cache_list[idx].su_h;
+
+	if (x < 0 || ! rc) {
+		STORE(idx, win, attr);
+fprintf(stderr, "SU_save: FAIL FOR: %d\n", idx);
+		return 0;
+	}
+
+	if (ncache_pad) {
+		x2 -= ncache_pad;	
+		y2 -= ncache_pad;	
+		w2 += 2 * ncache_pad;	
+		h2 += 2 * ncache_pad;	
+	}
+
+	if (clipshift) {
+		x2 -= coff_x;
+		y2 -= coff_y;
+	}
+
+	dx = x - x2; 
+	dy = y - y2; 
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r = sraRgnCreateRect(x2, y2, x2+w2, y2+h2);
+	sraRgnAnd(r, r0);
+	sraRgnOffset(r, dx, dy);
+
+	dtA =  dnowx();
+fprintf(stderr, "SU_save: %.4f      %d dx=%d dy=%d\n", dtA, idx, dx, dy);
+	if (w2 > 0 && h2 > 0) {
+		cache_cr(r, dx, dy, save_delay0, save_delay1, nbatch);
+	}
+	dtB =  dnowx();
+fprintf(stderr, "SU_save: %.4f %.2f %d done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", dtB, dtB-dtA, idx, w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].su_time - x11vnc_start, dnowx());
+
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r);
+
+	STORE(idx, win, attr);
+	cache_list[idx].su_time = dnow();
+	
+	return 1;
+}
+
+int bs_restore(int idx, int *nbatch, int nopad) {
+	Window win = cache_list[idx].win;
+	XWindowAttributes attr;
+	int x1, y1, w1, h1;
+	int x2, y2, w2, h2;
+	int x, y, w, h;
+	int dx, dy;
+	sraRegionPtr r, r0;
+
+fprintf(stderr, "backingstore restore:    0x%x  %3d \n", win, idx);
 
 	x1 = cache_list[idx].x;
 	y1 = cache_list[idx].y;
 	w1 = cache_list[idx].width;
 	h1 = cache_list[idx].height;
 	
-	if (! valid_window(win, &attr, 1)) {
-fprintf(stderr, "bs_restore: not valid\n");
+	X_LOCK;
+	if (! valid_wr(idx, win, &attr)) {
+fprintf(stderr, "BS_restore: not a valid X window: 0x%x\n", win);
 		DELETE(idx);
+		X_UNLOCK;
 		return 0;
 	}
+	X_UNLOCK;
 
 	x2 = attr.x;
 	y2 = attr.y;
@@ -5015,19 +6756,54 @@ fprintf(stderr, "bs_restore: not valid\n");
 	w = cache_list[idx].bs_w;
 	h = cache_list[idx].bs_h;
 
-	if (x < 0) {
+	if (x < 0 || cache_list[idx].bs_time == 0.0) {
 		STORE(idx, win, attr);
 		return 0;
 	}
 
+	if (ncache_pad) {
+		if (nopad) {
+			x += ncache_pad;	
+			y += ncache_pad;	
+			w -= 2 * ncache_pad;	
+			h -= 2 * ncache_pad;	
+		} else {
+			x2 -= ncache_pad;	
+			y2 -= ncache_pad;	
+			w2 += 2 * ncache_pad;	
+			h2 += 2 * ncache_pad;	
+		}
+	}
+
+	if (clipshift) {
+		x2 -= coff_x;
+		y2 -= coff_y;
+	}
+
 	dx = x2 - x; 
 	dy = y2 - y; 
 
-	r = sraRgnCreateRect(x+dx, y+dy, x+w2+dx, y+h2+dy);
-fprintf(stderr, "bs_restore: dx=%d dy=%d\n", dx, dy);
-	do_copyregion(r, dx, dy);
-	fb_push_wait(0.01, FB_COPY);
-fprintf(stderr, "bs_rest: done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].bs_time, dnow());
+	if (w2 > w) {
+		w2 = w;
+	}
+	if (h2 > h) {
+		h2 = h;
+	}
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r = sraRgnCreateRect(x, y, x+w2, y+h2);
+	sraRgnOffset(r, dx, dy);
+	sraRgnAnd(r, r0);
+
+	dtA =  dnowx();
+fprintf(stderr, "BS_rest: %.4f      %d dx=%d dy=%d\n", dtA, idx, dx, dy);
+	if (w2 > 0 && h2 > 0) {
+		cache_cr(r, dx, dy, restore_delay0, restore_delay1, nbatch);
+	}
+	dtB =  dnowx();
+fprintf(stderr, "BS_rest: %.4f %.2f %d done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", dtB, dtB-dtA, idx, w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].bs_time - x11vnc_start, dnowx());
+
+	sraRgnDestroy(r0);
 	sraRgnDestroy(r);
 
 	STORE(idx, win, attr);
@@ -5035,27 +6811,26 @@ fprintf(stderr, "bs_rest: done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", w1, h1,
 	return 1;
 }
 
-int su_restore(int idx) {
+int su_restore(int idx, int *nbatch, int nopad) {
 	Window win = cache_list[idx].win;
 	XWindowAttributes attr;
 	int x1, y1, w1, h1;
 	int x2, y2, w2, h2;
 	int x, y, w, h;
 	int dx, dy;
-	sraRegionPtr r;
+	sraRegionPtr r, r0;
 	int invalid = 0;
-	
-	if (cache_list[idx].su_x < 0 || cache_list[idx].su_time == 0.0) {
-		return 0;
-	}
 
+fprintf(stderr, "save-unders  restore:    0x%x  %3d \n", win, idx);
+	
 	x1 = cache_list[idx].x;
 	y1 = cache_list[idx].y;
 	w1 = cache_list[idx].width;
 	h1 = cache_list[idx].height;
 	
-	if (! valid_window(win, &attr, 1)) {
-fprintf(stderr, "su_restore: not valid\n");
+	X_LOCK;
+	if (! valid_wr(idx, win, &attr)) {
+fprintf(stderr, "SU_restore: not a valid X window: 0x%x\n", win);
 		invalid = 1;
 		x2 = x1;
 		y2 = y1;
@@ -5067,237 +6842,946 @@ fprintf(stderr, "su_restore: not valid\n");
 		w2 = attr.width;
 		h2 = attr.height;
 	}
+	X_UNLOCK;
 
 	x = cache_list[idx].su_x;
 	y = cache_list[idx].su_y;
 	w = cache_list[idx].su_w;
 	h = cache_list[idx].su_h;
 
-	if (x < 0) {
+	if (x < 0 || cache_list[idx].bs_x < 0 || cache_list[idx].su_time == 0.0) {
+fprintf(stderr, "SU_rest: su_x/bs_x/su_time: %d %d %.3f\n", x, cache_list[idx].bs_x, cache_list[idx].su_time);
 		if (invalid) {
 			DELETE(idx);
 		}
 		return 0;
 	}
 
-	dx = x2 - x; 
-	dy = y2 - y; 
+	if (ncache_pad) {
+		if (nopad) {
+			x += ncache_pad;	
+			y += ncache_pad;	
+			w -= 2 * ncache_pad;	
+			h -= 2 * ncache_pad;	
+		} else {
+			x2 -= ncache_pad;	
+			y2 -= ncache_pad;	
+			w2 += 2 * ncache_pad;	
+			h2 += 2 * ncache_pad;	
+		}
+	}
+
+	if (clipshift) {
+		x2 -= coff_x;
+		y2 -= coff_y;
+	}
+
+	dx = x2 - x; 
+	dy = y2 - y; 
+
+	if (w2 > w) {
+		w2 = w;
+	}
+	if (h2 > h) {
+		h2 = h;
+	}
+
+	r0 = sraRgnCreateRect(0, 0, dpy_x, dpy_y);
+	r = sraRgnCreateRect(x, y, x+w2, y+h2);
+	sraRgnOffset(r, dx, dy);
+	sraRgnAnd(r, r0);
+
+	dtA =  dnowx();
+fprintf(stderr, "SU_rest: %.4f      %d dx=%d dy=%d\n", dtA, idx, dx, dy);
+	if (w2 > 0 && h2 > 0) {
+		cache_cr(r, dx, dy, restore_delay0, restore_delay1, nbatch);
+	}
+	dtB =  dnowx();
+fprintf(stderr, "SU_rest: %.4f %.2f %d done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", dtB, dtB-dtA, idx, w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].su_time - x11vnc_start, dnowx());
+
+	sraRgnDestroy(r0);
+	sraRgnDestroy(r);
+
+	if (invalid) {
+		DELETE(idx);
+		return 0;
+	} else {
+		STORE(idx, win, attr);
+		return 1;
+	}
+}
+
+void check_zero_rects(void) {
+	sraRect rt;
+	sraRectangleIterator *iter;
+	if (! zero_rects) {
+		zero_rects = sraRgnCreate();
+	}
+	if (sraRgnEmpty(zero_rects)) {
+		return;
+	}
+		
+	iter = sraRgnGetIterator(zero_rects);
+	while (sraRgnIteratorNext(iter, &rt)) {
+		zero_fb(rt.x1, rt.y1, rt.x2, rt.y2);
+		mark_rect_as_modified(rt.x1, rt.y1, rt.x2, rt.y2, 0);
+	}
+	sraRgnReleaseIterator(iter);
+	sraRgnMakeEmpty(zero_rects);
+}
+
+void block_stats(void) {
+	int n, k, area, s1, s2;
+	static int t = -1;
+	int vcnt, icnt, tcnt, vtot = 0, itot = 0, ttot = 0;
+	t++;
+	for (n = 1; n < ncache+1; n += 2) {
+		double area = 0.0, frac;
+		vcnt = 0;
+		icnt = 0;
+		tcnt = 0;
+		for(k=0; k<cache_list_num; k++) {
+			XWindowAttributes attr;
+			int x = cache_list[k].bs_x;
+			int y = cache_list[k].bs_y;
+			int w = cache_list[k].bs_w;
+			int h = cache_list[k].bs_h;
+			int rc;
+			Window win = cache_list[k].win;
+			if (win == None) {
+				continue;
+			}
+			if (n == 1) {
+				X_LOCK;
+				rc = valid_window(win, &attr, 1);
+				X_UNLOCK;
+				if (rc) {
+					vtot++;
+				} else {
+					itot++;
+				}
+				if (x >= 0) {
+					ttot++;
+				}
+			}
+			if (y < n*dpy_y || y > (n+1)*dpy_y) {
+				continue;
+			}
+			if (n != 1) {
+				X_LOCK;
+				rc = valid_window(win, &attr, 1);
+				X_UNLOCK;
+			}
+			if (rc) {
+				vcnt++;
+			} else {
+				icnt++;
+			}
+			if (x >= 0) {
+				tcnt++;
+			}
+			if (x < 0) {
+				continue;
+			}
+			area += cache_list[k].width * cache_list[k].height;
+			if (! rc && ! macosx_console) {
+				char *u = getenv("USER");
+				if (u && !strcmp(u, "runge"))	fprintf(stderr, "\a");
+				fprintf(stderr, "\n   *** UNRECLAIMED WINDOW: 0x%x  %dx%d+%d+%d\n\n", win, w, h, x, y);
+				DELETE(k);
+			}
+			if (t < 3 || (t % 4) == 0 || hack_val || macosx_console) {
+				double t1 = cache_list[k].su_time;
+				double t2 = cache_list[k].bs_time;
+				if (t1 > 0.0) {t1 = dnow() - t1;} else {t1 = -1.0;}
+				if (t2 > 0.0) {t2 = dnow() - t2;} else {t2 = -1.0;}
+				fprintf(stderr, "     [%02d] %04d 0x%08x bs: %04dx%04d+%04d+%05d vw: %04dx%04d+%04d+%04d cl: %04dx%04d+%04d+%04d map=%d su=%9.3f bs=%9.3f\n",
+				    n, k, win, w, h, x, y, attr.width, attr.height, attr.x, attr.y,
+				    cache_list[k].width, cache_list[k].height, cache_list[k].x, cache_list[k].y,
+				    attr.map_state == IsViewable, t1, t2); 
+			}
+		}
+		frac = area /(dpy_x * dpy_y);
+		fprintf(stderr, "block[%02d]  %.3f  %8d  trak/val/inval: %d/%d/%d of %d\n", n, frac, (int) area, tcnt, vcnt, icnt, vcnt+icnt);
+	}
+
+	fprintf(stderr, "\n");
+	fprintf(stderr, "block: trak/val/inval %d/%d/%d of %d\n", ttot, vtot, itot, vtot+itot);
+
+	s1 = fr_REGION  + fr_GRID  + fr_EXPIRE  + fr_FORCE  + fr_BIG1  + fr_BIG2  + fr_FAIL;
+	s2 = fr_REGIONt + fr_GRIDt + fr_EXPIREt + fr_FORCEt + fr_BIG1t + fr_BIG2t + fr_FAILt;
+	fprintf(stderr, "\n");
+	fprintf(stderr, "find_rect:  REGION/GRID/EXPIRE/FORCE - BIG1/BIG2/FAIL  %d/%d/%d/%d - %d/%d/%d  of %d\n",
+	    fr_REGION,  fr_GRID,  fr_EXPIRE,  fr_FORCE,  fr_BIG1,  fr_BIG2,  fr_FAIL, s1);
+	fprintf(stderr, "                                       totals:         %d/%d/%d/%d - %d/%d/%d  of %d\n",
+	    fr_REGIONt, fr_GRIDt, fr_EXPIREt, fr_FORCEt, fr_BIG1t, fr_BIG2t, fr_FAILt, s2);
+
+	fr_BIG1 = 0;
+	fr_BIG2 = 0;
+	fr_REGION = 0;
+	fr_GRID = 0;
+	fr_EXPIRE = 0;
+	fr_FORCE = 0;
+	fr_FAIL = 0;
+	fprintf(stderr, "\n");
+}
+
+#define NSCHED 64
+Window sched_bs[NSCHED];
+double sched_tm[NSCHED];
+double last_sched_bs = 0.0;
+
+#define SCHED(w) \
+{ \
+	int k, save = -1, empty = 1; \
+	for (k=0; k < NSCHED; k++) { \
+		if (sched_bs[k] == None) { \
+			save = k; \
+		} \
+		if (sched_bs[k] == w) { \
+			save = k; \
+			empty = 0; \
+			break; \
+		} \
+	} \
+	if (save >= 0) { \
+		sched_bs[save] = w; \
+		if (empty) { \
+			sched_tm[save] = dnow(); \
+			fprintf(stderr, "SCHED: %d %f\n", save, dnowx()); \
+		} \
+	} \
+}
+
+void xselectinput(Window w, unsigned long evmask, int sync) {
+#if NO_X11
+	trapped_xerror = 0;
+	trapped_xioerror = 0;
+#else
+	XErrorHandler   old_handler1;
+	XIOErrorHandler old_handler2;
+
+	old_handler1 = XSetErrorHandler(trap_xerror);
+	old_handler2 = XSetIOErrorHandler(trap_xioerror);
+	trapped_xerror = 0;
+	trapped_xioerror = 0;
+
+	XSelectInput(dpy, w, evmask);
+
+	/*
+	 * We seem to need to synchronize right away since the window
+	 * might go away quickly.
+	 */
+	if (sync) {
+		XSync(dpy, False);
+	} else {
+		XFlush_wr(dpy);
+	}
+
+	XSetErrorHandler(old_handler1);
+	XSetIOErrorHandler(old_handler2);
+#endif
 
-	r = sraRgnCreateRect(x+dx, y+dy, x+w2+dx, y+h2+dy);
-fprintf(stderr, "su_restore: dx=%d dy=%d\n", dx, dy);
-	do_copyregion(r, dx, dy);
-	fb_push_wait(0.01, FB_COPY);
-fprintf(stderr, "su_rest: done.  %dx%d+%d+%d %dx%d+%d+%d  %.2f %.2f\n", w1, h1, x1, y1, w2, h2, x2, y2, cache_list[idx].su_time, dnow());
-	sraRgnDestroy(r);
+	if (trapped_xerror) {
+		fprintf(stderr, "XSELECTINPUT: trapped X Error.");
+	}
+	if (trapped_xioerror) {
+		fprintf(stderr, "XSELECTINPUT: trapped XIO Error.");
+	}
+if (sync) fprintf(stderr, "XSELECTINPUT: 0x%x  sync=%d err=%d/%d\n", w, sync, trapped_xerror, trapped_xioerror);
+}
 
-	if (invalid) {
-		DELETE(idx);
-		return 0;
-	} else {
-		STORE(idx, win, attr);
-		return 1;
+Bool xcheckmaskevent(Display *d, long mask, XEvent *ev) {
+#ifdef MACOSX
+	if (macosx_console) {
+		if (macosx_checkevent(ev)) {
+			return True;
+		} else {
+			return False;
+		}
 	}
+#endif
+	RAWFB_RET(False);
+
+#if NO_X11
+	return False;
+#else
+	return XCheckMaskEvent(d, mask, ev);
+#endif
 }
 
 #include <rfb/default8x16.h>
 
-void check_ncache(void) {
+#define EVMAX 2048
+XEvent Ev[EVMAX];
+int Ev_done[EVMAX];
+int Ev_area[EVMAX];
+Window Ev_win[EVMAX];
+Window Ev_map[EVMAX];
+Window Ev_unmap[EVMAX];
+sraRect Ev_rects[EVMAX];
+
+int check_ncache(int reset, int mode) {
 	static int last_map = -1;
 	static double last_root = 0.0;
 	static int first = 1;
-	int i, j, k; 
+	static int last_client_count = -1;
+	int i, j, k, n, t; 
+	int n_CN = 0, n_RN = 0, n_DN = 0, n_ON = 0, n_MN = 0, n_UN = 0;
+	int n_VN = 0, n_VN_p = 0, n_VN_u = 0;
+
 	double now, refresh = 60.0;
 	Window win, win2;
 	XWindowAttributes attr;
 	XEvent ev;
+	unsigned long all_ev = SubstructureNotifyMask|StructureNotifyMask|VisibilityChangeMask;
+	unsigned long win_ev = StructureNotifyMask|VisibilityChangeMask;
+
+	Window awin0, awin1, awin2;
+	int area0, area1, area2;
+	int try_batch = 1; /* XXX Y */
+	int use_batch = 0;
+	int nreg = 0, *nbatch;
+	static int didtopmost = 0;
+	int create_cnt, create_tot;
+	int pixels = 0;
+
+	int nrects = 0;
+
+	Window resize_inc[16];
+	Window resize_dec[16];
+	XWindowAttributes attr_inc[16];
+	XWindowAttributes attr_dec[16];
+	int nresize = 16;
 
-	if (! ncache || ! ncache0) {
-		return;
+#ifdef MACOSX
+	if (! macosx_console) {
+		RAWFB_RET(-1)
 	}
+#else
+	RAWFB_RET(-1)
+#endif
+
 	if (! screen) {
-		return;
+		return -1;
 	}
-	if (! dpy) {
-		return;
+
+	now = dnow();
+
+	if (ncache0) {
+		if (reset) {
+			;
+		} else if (! client_count || !ncache) {
+			static double last_purge = 0.0;
+			double delay = client_count ? 0.5 : 2.0;
+			if (now > last_purge + delay) {
+				int c = 0;
+				XEvent ev;
+				X_LOCK;
+				while (xcheckmaskevent(dpy, all_ev, &ev)) {
+					c++;
+				}
+				X_UNLOCK;
+				last_purge = dnow();
+if (c) fprintf(stderr, "check_ncache purged %d events\n", c); 
+			}
+			if (!client_count && last_client_count >= 0 &&
+			    client_count != last_client_count) {
+				/* this should use less RAM when no clients */
+				do_new_fb(1);
+			}
+			last_client_count = client_count;
+			return -1;
+		}
+	}
+	last_client_count = client_count;
+
+	if (ncache && ! ncache0) {
+		ncache0 = ncache;
+	}
+
+	if (! ncache || ! ncache0) {
+		return -1;
+	}
+	if (subwin) {
+		return -1;
+	}
+
+	if (reset) {
+		rfbLog("check_ncache: resetting cache\n");
+		for (i=0; i < cache_list_num; i++) {
+			free_rect(i);
+			CLEAR(i);
+		}
+		for (n = 1; n <= ncache; n++) {
+			if (rect_reg[n] != NULL) {
+				sraRgnDestroy(rect_reg[n]);
+				rect_reg[n] = NULL;
+			}
+		}
+		zero_fb(0, dpy_y, dpy_x, (ncache+1)*dpy_y);
+		mark_rect_as_modified(0, dpy_y, dpy_x, (ncache+1)*dpy_y, 0);
+		return -1;
 	}
 
 	if (first) {
-		int dx = 10, dy = 24;
+		int dx = 10, dy = 24, ds = 0;
+		int Dx = dpy_x, Dy = dpy_y;
+		first = 0;
 		for (i=0; i < NRECENT; i++) {
 			recent[i] = None;
 		}
+		for (i=0; i < NSCHED; i++) {
+			sched_bs[i] = None;
+		}
 		rlast = 0;
+
 		X_LOCK;
 		/* event leak with client_count == 0 */
 		xselectinput_rootwin |= SubstructureNotifyMask;
-		XSelectInput(dpy, rootwin, xselectinput_rootwin);
+		XSelectInput_wr(dpy, rootwin, xselectinput_rootwin);
 		X_UNLOCK;
-		first = 0;
-		rfbDrawString(screen, &default8x16Font, dx, dpy_y+1*dy,
-		    "This is the Pixel buffer cache region. Your VNC Viewer is not hiding it from you.",
-		    white_pixel());
-		rfbDrawString(screen, &default8x16Font, dx, dpy_y+2*dy,
-		    "Try resizing your VNC Viewer so you don't see it !!",
-		    white_pixel());
-		rfbDrawString(screen, &default8x16Font, dx, dpy_y+3*dy,
-		    "To disable run the server with:  x11vnc -ncache 0 ...",
-		    white_pixel());
-		rfbDrawString(screen, &default8x16Font, dx, dpy_y+4*dy,
-		    "More info:  http://www.karlrunge.com/x11vnc/#faq-client-caching",
-		    white_pixel());
+
+		if (scaling) {
+			Dx = scaled_x;
+			Dy = scaled_y;
+		}
+		if (!rotating_same) {
+			int t = Dx;
+			Dx = Dy;
+			Dy = t;
+		}
+
+		for (i = 0; i < 3; i++) {
+			rfbDrawString(screen, &default8x16Font, dx, ds + Dy+1*dy,
+			    "This is the Pixel buffer cache region. Your VNC Viewer is not hiding it from you.",
+			    white_pixel());
+			rfbDrawString(screen, &default8x16Font, dx, ds + Dy+2*dy,
+			    "Try resizing your VNC Viewer so you don't see it !!",
+			    white_pixel());
+			rfbDrawString(screen, &default8x16Font, dx, ds + Dy+3*dy,
+			    "To disable run the server with:  x11vnc -ncache 0 ...",
+			    white_pixel());
+			rfbDrawString(screen, &default8x16Font, dx, ds + Dy+4*dy,
+			    "More info:  http://www.karlrunge.com/x11vnc/#faq-client-caching",
+			    white_pixel());
+
+			ds += 8 * dy;
+		}
+
 		snapshot_cache_list(0, 100.0);
+fprintf(stderr, "cache_list_num: %d\n", cache_list_num);
+		for (i=0; i < cache_list_num; i++) {
+			CLEAR(i);
+		}
+		for (n = 1; n <= ncache; n++) {
+			rect_reg[n] = NULL;
+		}
 	}
 
-	if (! client_count) {
-		return;
+	if (now < last_client + 2) {
+		return -1;
 	}
-	now = dnow();
+
+if (hack_val == 2) {
+	block_stats();
+	hack_val = 1;
+}
+#ifdef MACOSX
+	if (macosx_console) {
+		static double last_all_windows = 0.0;
+		if (! macosx_checkevent(NULL)) {
+			if (now > last_all_windows + 0.05) {
+				macosxCGS_get_all_windows();
+				last_all_windows = dnow();
+			}
+		}
+		/* XXX Y */
+		rootwin = -1;
+	}
+#endif
 
 	if (now > last_root + refresh) {
+		Window topmapped = None;
+
 fprintf(stderr, "\n**** checking cache_list[%d]\n\n", cache_list_num);
+		block_stats();
+
 		for(k=0; k<cache_list_num; k++) {
+			int valid = 0;
 			win = cache_list[k].win; 
+			X_LOCK;
 			if (win == None) {
-fprintf(stderr, " Empty[%d]: 0x%x\n", k, win);
+				;
 			} else if (cache_list[k].selectinput && cache_list[k].time > now - refresh) {
-fprintf(stderr, " Young[%d]: 0x%x\n", k, win);
+				;
 			} else if (valid_window(win, &attr, 1)) {
 				STORE(k, win, attr);
+//fprintf(stderr, "STORE(%2d) %03dx%03d+%03d+%03d\n", k, cache_list[k].width, cache_list[k].height, cache_list[k].x, cache_list[k].y);
 				if (! cache_list[k].selectinput) {
-					X_LOCK;
-fprintf(stderr, " XSelectInput[%d]: 0x%x\n", k, win);
-					XSelectInput(dpy, win, StructureNotifyMask);
-					X_UNLOCK;
+					xselectinput(win, win_ev, 0);
 					CLEAR(k);
 					cache_list[k].selectinput = 1;
 				} else {
-//fprintf(stderr, " SKIP XSelectInput[%d]: 0x%x\n", k, win);
+					;
+				}
+				if (attr.map_state == IsViewable) {
+					topmapped = win;
 				}
+				valid = 1;
 			} else {
-fprintf(stderr, " DELETE(%d) 0x%x\n", k, win);
+fprintf(stderr, "DELETE(%d) %dx%d+%d+%d\n", k, cache_list[k].width, cache_list[k].height, cache_list[k].x, cache_list[k].y);
 				DELETE(k);
 			}
+			X_UNLOCK;
+/* XXX Y */
+			if (valid) {
+				if (cache_list[k].create_cnt && attr.map_state != IsViewable && cache_list[k].map_cnt == 0) {
+					if (cache_list[k].bs_x >= 0) {
+fprintf(stderr, "Created window never mapped: freeing(%d) 0x%x\n", k, win);
+						free_rect(k);
+					}
+				}
+			}
 		}
 		last_root = dnow();
+		if (0 && ! didtopmost && topmapped != None) {
+			int idx = lookup_win_index(topmapped);
+			if (idx >= 0) {
+				if (! macosx_console) {
+					bs_save(idx, NULL);
+				}
+			}
+		}
+		didtopmost = 1;
+	}
+
+	check_zero_rects();
+
+	if (now > last_sched_bs + 0.2) {
+		static double last_sched_vis = 0.0;
+		int nr = 0, *bat = NULL;
+
+		if (try_batch) {
+			bat = &nr;
+		}
+		
+		for (i=0; i < NSCHED; i++) {
+			if (sched_bs[i] != None) {
+				int idx;
+				win = sched_bs[i];	
+				if (now < sched_tm[i] + 0.65) {
+					continue;
+				}
+				idx = lookup_win_index(win);
+				if (idx >= 0) {
+					int aw = cache_list[idx].width; 
+					int ah = cache_list[idx].height; 
+					if (cache_list[idx].map_state != IsViewable) {
+						;
+					} else if (cache_list[idx].vis_state != VisibilityUnobscured) {
+						;
+					} else if (aw * ah < 64 * 64) {
+						;
+					} else {
+fprintf(stderr, "*NEW BS_save: 0x%x %d %d %d\n", win, aw, ah, cache_list[idx].map_state); 
+						bs_save(idx, bat);
+					}
+				}
+			}
+			sched_bs[i] = None;
+		}
+		if (nr) {
+			int k;
+			batch_copyregion(batch_reg, batch_dxs, batch_dys, nr, -1.0);
+			for (k=0; k < nr; k++) {
+				sraRgnDestroy(batch_reg[k]);
+			}
+		}
+		last_sched_bs = dnow();
+
+		if (now > last_sched_vis + 3.0) {
+			for (i=0; i < cache_list_num; i++) {
+				if (cache_list[i].map_state == IsViewable) {
+					if (cache_list[i].vis_state == VisibilityUnobscured) {
+						if (cache_list[i].valid) {
+							if (cache_list[i].win != None) {
+								SCHED(cache_list[i].win) 
+							}
+						}
+					}
+				}
+			}
+			last_sched_vis = dnow();
+		}
+	}
+
+	n = 0;
+	create_tot = 0;
+
+	X_LOCK;
+	while (xcheckmaskevent(dpy, all_ev, &Ev[n])) {
+		int type = Ev[n].type; 
+		win = Ev[n].xany.window;
+		Ev_done[n] = 0;
+		Ev_area[n] = 0;
+		Ev_win[n] = None;
+		Ev_map[n] = None;
+		Ev_unmap[n] = None;
+
+		if (win == rootwin) {
+			if (type == CreateNotify) {
+				n++;
+				create_tot++;
+				n_CN++;
+			} else if (type == ReparentNotify) {
+				n++;
+				n_RN++;
+			} else {
+				Window w = None;
+				/* skip rest */
+#if 0
+if (type == DestroyNotify) w = Ev[n].xdestroywindow.window;
+if (type == UnmapNotify)   w = Ev[n].xunmap.window;
+if (type == MapNotify)     w = Ev[n].xmap.window;
+if (type == Expose)        w = Ev[n].xexpose.window;
+if (type == ConfigureNotify) w = Ev[n].xconfigure.window;
+if (type != ConfigureNotify) fprintf(stderr, "root: skip %s  for 0x%x\n", Etype(type), w);
+#endif
+
+			}
+		} else {
+			if (type == ReparentNotify) {
+				n++;
+				n_RN++;
+			} else if (type == DestroyNotify) {
+				n++;
+				n_DN++;
+			} else if (type == ConfigureNotify) {
+				n++;
+				n_ON++;
+			} else if (type == VisibilityNotify) {
+				if (Ev[n].xvisibility.state == VisibilityUnobscured) {
+					n_VN_u++;
+				} else {
+					n_VN_p++;
+				}
+				n++;
+				n_VN++;
+			} else if (type == MapNotify) {
+				n++;
+				n_MN++;
+			} else if (type == UnmapNotify) {
+				n++;
+				n_UN++;
+			} else {
+				/* skip rest */
+fprintf(stderr, "----- skip %s\n", Etype(type));
+			}
+		}
+		if (n >= EVMAX) {
+			break;
+		}
+	}
+	X_UNLOCK;
+
+	if (n == 0) {
+		return 0;
+	}
+fprintf(stderr, "\n"); rfbLog("IN  check_ncache() %d events.\n", n);
+
+	for (i=0; i < n; i++) {
+		XEvent ev = Ev[i];
+		int a, w, h, type, idx = -1;
+
+		type = ev.type;
+		win  = ev.xany.window;
+		Ev_win[i] = win;
+
+	}
+
+	if (try_batch) {
+		use_batch = 1;
 	}
 
+	if (rotating) {
+		use_batch = 0;
+	}
+	if (cursor_noshape_updates_clients(screen)) {
+		use_batch = 0;
+	}
+
+	if (! use_batch) {
+		nbatch = NULL;
+	} else {
+		nreg = 0;
+		nbatch = &nreg;
+	}
+
+	create_cnt = 0;
+
 	X_LOCK;
-	while (XCheckMaskEvent(dpy, SubstructureNotifyMask|StructureNotifyMask, &ev)) {
-		int type = ev.type; 
-		int idx;
-		win = ev.xany.window;
+	for (i=0; i < n; i++) {
+		XEvent ev;
+		int a, w, h, type, idx = -1;
+
+		if (Ev_done[i]) continue;
+		win = Ev_win[i];
 
-//fprintf(stderr, "evnt: 0x%x %d pending: %d\n", win, type, XPending(dpy));
+		ev = Ev[i];
+		type = ev.type;
+		Ev_done[i] = 1;
+		
 		if (win == rootwin) {
 			if (type == CreateNotify) {
-				int x=0,y=0,w=0,h=0;
+				int x=0, y=0, w=0, h=0;
+				int valid = 0;
 				win2 = ev.xcreatewindow.window;
 				idx = lookup_win_index(win2);
 				if (idx < 0) {
 					idx = lookup_free_index();
+					if (idx < 0) {
+						continue;
+					}
+					CLEAR(idx);
 				}
 				if (valid_window(win2, &attr, 1)) {
 					STORE(idx, win2, attr);
 					CLEAR(idx);
-//					su_save(idx);	// not working
 					x=attr.x;
 					y=attr.y;
 					w=attr.width;
 					h=attr.height;
-					XSelectInput(dpy, win2, StructureNotifyMask);
-					cache_list[idx].selectinput = 1;
+/* XXX Y */
+					if (create_tot <= 6 && create_cnt++ < 3) {
+						if (w*h > 64 * 64) {
+							X_UNLOCK;
+							su_save(idx, nbatch);
+							X_LOCK;
+							if (cache_list[idx].valid) {
+								SCHED(win2) 
+							}
+							create_cnt++;
+						}
+					}
+					if (cache_list[idx].valid) {
+						xselectinput(win2, win_ev, 1);
+						cache_list[idx].selectinput = 1;
+						cache_list[idx].create_cnt = 1;
+						valid = 1;
+					} else {
+						DELETE(idx);
+					}
 				}
-fprintf(stderr, "root: ** CreateNotify 0x%x  %d  -- %dx%d+%d+%d\n", win2, idx, w, h, x, y);
+fprintf(stderr, "root%02d: ** CreateNotify  0x%x  %3d  -- %dx%d+%d+%d valid=%d\n", i, win2, idx, w, h, x, y, valid);
+
 			} else if (type == ReparentNotify) {
 				if (ev.xreparent.parent != rootwin) {
 					win2 = ev.xreparent.window;
 					if (win2 != rootwin) {
 						idx = lookup_win_index(win2);
-fprintf(stderr, "root: ReparentNotify RM: 0x%x  %d\n", win2, idx);
+fprintf(stderr, "root%02d: ReparentNotifyRM 0x%x  %3d\n", i, win2, idx);
 						if (idx >= 0) {
 							DELETE(idx);
 						}
-						XSelectInput(dpy, win2, 0);
+						xselectinput(win2, 0, 1);
 					}
 				}
-			} else {
-				Window ww = None;
-				/* skip rest */
-if (type == DestroyNotify) ww = ev.xdestroywindow.window;
-if (type == UnmapNotify)   ww = ev.xunmap.window;
-if (type == MapNotify)     ww = ev.xmap.window;
-if (type == Expose)        ww = ev.xexpose.window;
-if (type == ConfigureNotify) ww = ev.xconfigure.window;
-fprintf(stderr, "root: skip %s  for 0x%x\n", Etype(type), ww);
 			}
 		} else {
-			if (type == ReparentNotify) {
-				if (ev.xreparent.parent != rootwin) {
-					win2 = ev.xreparent.window;
-					if (win2 != rootwin) {
-						idx = lookup_win_index(win2);
-fprintf(stderr, "----- ReparentNotify RM: 0x%x  %d\n", win2, idx);
-						if (idx >= 0) {
-							DELETE(idx);
-						}
-						XSelectInput(dpy, win2, 0);
-					}
-				}
+			if (type == ConfigureNotify) {
+				int x_new, y_new, w_new, h_new;
+				int x_old, y_old, w_old, h_old;
+				Window oabove = None;
+
+				idx = lookup_win_index(win);
 
-			} else if (type == DestroyNotify) {
-				win2 = ev.xdestroywindow.window;
-				idx = lookup_win_index(win2);
-fprintf(stderr, "----- DestroyNotify 0x%x  %d\n", win2, idx);
 				if (idx >= 0) {
-					DELETE(idx);
+					oabove = cache_list[idx].above;
 				}
 
-			} else if (type == ConfigureNotify) {
+fprintf(stderr, "----%02d: ConfigureNotify  0x%x  %3d  -- above: 0x%x -> 0x%x  %dx%d+%d+%d\n", i, win, idx,
+    oabove, ev.xconfigure.above, ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y);
+
+				if (idx < 0) {
+					continue;
+				}
+
+				x_new = ev.xconfigure.x; 
+				y_new = ev.xconfigure.y; 
+				w_new = ev.xconfigure.width; 
+				h_new = ev.xconfigure.height; 
+				x_old = cache_list[idx].x;
+				y_old = cache_list[idx].y;
+				w_old = cache_list[idx].width;
+				h_old = cache_list[idx].height;
+
+				if (x_old != x_new || y_old != y_new) {
+					/* invalidate su */
+					cache_list[idx].su_time = 0.0;
+fprintf(stderr, "          invalidate su: 0x%x xy: %d/%d  %d/%d \n", win, x_old, y_old, x_new, y_new);
+				}
+				if (w_old != w_new || h_old != h_new) {
+					/* invalidate bs */
+					cache_list[idx].bs_time = 0.0;
+fprintf(stderr, "          invalidate bs: 0x%x wh: %d/%d  %d/%d \n", win, w_old, h_old, w_new, h_new);
+				}
+
+				cache_list[idx].x = x_new;
+				cache_list[idx].y = y_new;
+				cache_list[idx].width = w_new;
+				cache_list[idx].height = h_new;
+				cache_list[idx].above = ev.xconfigure.above;
+				cache_list[idx].time = dnow();
+
+			} else if (type == VisibilityNotify) {
+				int state = ev.xvisibility.state;
 				idx = lookup_win_index(win);
-fprintf(stderr, "----- ConfigureNotify 0x%x  %d  -- %dx%d+%d+%d\n", win, idx, ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y);
-				if (idx >= 0) {
-					/* XXX invalidate su and/or bs  */
-					cache_list[idx].x = ev.xconfigure.x;
-					cache_list[idx].y = ev.xconfigure.y;
-					cache_list[idx].width = ev.xconfigure.width;
-					cache_list[idx].height = ev.xconfigure.height;
+fprintf(stderr, "----%02d: VisibilityNotify 0x%x  %3d  state: %s U/P %d/%d\n", i, win, idx, VState(state), n_VN_u, n_VN_p);
+
+				if (idx < 0) {
+					continue;
 				}
+				if (macosx_console && n_VN_p == 0) {
+					;	/* XXXX not working well yet with UnmapNotify ... */
+				} else if (state == VisibilityUnobscured) {
+					int i2, ok = 1;
+					for (i2=0; i2 < n; i2++)  {
+						if (Ev_map[i2] == win) {
+							ok = 0;
+							break;
+						}
+					}
+					if (ncache <= 2) {
+						ok = 0;
+					}
+					if (ok) {
+						X_UNLOCK;
+						bs_restore(idx, nbatch, 1);
+						X_LOCK;
+						cache_list[idx].time = dnow();
+						cache_list[idx].vis_cnt++;
+						Ev_map[i] = win;
+						Ev_rects[nrects].x1 = cache_list[idx].x;
+						Ev_rects[nrects].y1 = cache_list[idx].y;
+						Ev_rects[nrects].x2 = cache_list[idx].width;
+						Ev_rects[nrects].y2 = cache_list[idx].height;
+						nrects++;
+						SCHED(win) 
+					}
+				}
+				cache_list[idx].vis_state = state;
 
 			} else if (type == MapNotify) {
 				idx = lookup_win_index(win);
-fprintf(stderr, "----- MapNotify 0x%x  %d\n", win, idx);
+fprintf(stderr, "----%02d: MapNotify        0x%x  %3d\n", i, win, idx);
+
 				if (idx < 0) {
 					continue;
 				}
-				if (cache_list[idx].map_state == IsUnmapped) {
+
+				if (cache_list[idx].map_state == IsUnmapped || macosx_console) {
 					X_UNLOCK;
-					su_save(idx);
-					bs_restore(idx);
+					su_save(idx, nbatch);
+					bs_restore(idx, nbatch, 0);
+					if (macosx_console) {
+#ifdef MACOSX
+						macosxCGS_follow_animation_win(win, -1, 1);
+						if (valid_window(win, &attr, 1)) {
+							STORE(idx, win, attr);
+							SCHED(win);
+						}
+						/* XXX Y */
+						if (cache_list[idx].vis_state == -1)  {
+							cache_list[idx].vis_state = VisibilityUnobscured;
+						}
+#endif
+					}
 					X_LOCK;
+					pixels += cache_list[idx].width * cache_list[idx].height;
+					cache_list[idx].time = dnow();
+					cache_list[idx].map_cnt++;
+					Ev_map[i] = win;
+					Ev_rects[nrects].x1 = cache_list[idx].x;
+					Ev_rects[nrects].y1 = cache_list[idx].y;
+					Ev_rects[nrects].x2 = cache_list[idx].width;
+					Ev_rects[nrects].y2 = cache_list[idx].height;
+					nrects++;
 				}
+				cache_list[idx].map_state = IsViewable;
 
 			} else if (type == UnmapNotify) {
 				idx = lookup_win_index(win);
-fprintf(stderr, "----- UnmapNotify 0x%x  %d\n", win, idx);
+fprintf(stderr, "----%02d: UnmapNotify      0x%x  %3d\n", i, win, idx);
+
 				if (idx < 0) {
 					continue;
 				}
-				if (cache_list[idx].map_state == IsViewable) {
+				if (macosx_console) {
+					if (mode == 2) {
+						cache_list[idx].map_state = IsViewable;
+					}
+				}
+
+				if (cache_list[idx].map_state == IsViewable || macosx_console) {
 					X_UNLOCK;
-					bs_save(idx);
-					su_restore(idx);
+					bs_save(idx, nbatch);
+					su_restore(idx, nbatch, 0);
 					X_LOCK;
+					pixels += cache_list[idx].width * cache_list[idx].height;
+					cache_list[idx].time = dnow();
+					cache_list[idx].unmap_cnt++;
+					Ev_unmap[i] = win;
+					Ev_rects[nrects].x1 = cache_list[idx].x;
+					Ev_rects[nrects].y1 = cache_list[idx].y;
+					Ev_rects[nrects].x2 = cache_list[idx].width;
+					Ev_rects[nrects].y2 = cache_list[idx].height;
+					nrects++;
+				}
+				cache_list[idx].map_state = IsUnmapped;
+
+			} else if (type == ReparentNotify) {
+				if (ev.xreparent.parent != rootwin) {
+					win2 = ev.xreparent.window;
+					if (win2 != rootwin) {
+						idx = lookup_win_index(win2);
+fprintf(stderr, "----%02d: ReparentNotifyRM 0x%x  %3d\n", i, win2, idx);
+						if (idx >= 0) {
+							DELETE(idx);
+						}
+						xselectinput(win2, 0, 1);
+					}
+				}
+
+			} else if (type == DestroyNotify) {
+				win2 = ev.xdestroywindow.window;
+				idx = lookup_win_index(win2);
+fprintf(stderr, "----%02d: DestroyNotify    0x%x  %3d\n", i, win2, idx);
+
+				if (idx >= 0) {
+					DELETE(idx);
 				}
-			} else {
-				/* skip rest */
-fprintf(stderr, "----- skip %s\n", Etype(type));
 			}
+
 		}
 	}
-//fprintf(stderr, "pending2: %d\n", XPending(dpy));
 	X_UNLOCK;
-if (dnow() - now > 0.05) fprintf(stderr, "check_ncache OUT: %f\n", dnow() - now);
+
+	if (use_batch && nreg) {
+		int k;
+		batch_copyregion(batch_reg, batch_dxs, batch_dys, nreg, -1.0);
+		for (k=0; k < nreg; k++) {
+			sraRgnDestroy(batch_reg[k]);
+		}
+	}
+	if (nrects) {
+		if (scaling) {
+			push_borders(Ev_rects, nrects);
+		}
+	}
+
+rfbLog("OUT check_ncache(): %.6f events: %d  pixels: %d\n", dnow() - now, n, pixels);
+	return pixels;
 }
 #endif
 
-
diff --git a/x11vnc/userinput.h b/x11vnc/userinput.h
index ffe9551a3a852974eca11b29fb9d9df54a594e3b..19185f00fa4aeb575aca69e291b1d77534d407bf 100644
--- a/x11vnc/userinput.h
+++ b/x11vnc/userinput.h
@@ -21,7 +21,7 @@ extern void initialize_max_keyrepeat(void);
 
 extern int direct_fb_copy(int x1, int y1, int x2, int y2, int mark);
 extern void fb_push(void);
-extern void fb_push_wait(double max_wait, int flags);
+extern int fb_push_wait(double max_wait, int flags);
 extern void eat_viewonly_input(int max_eat, int keep);
 
 extern void mark_for_xdamage(int x, int y, int w, int h);
@@ -35,6 +35,6 @@ extern int check_xrecord(void);
 extern int check_wireframe(void);
 extern int fb_update_sent(int *count);
 extern int check_user_input(double dt, double dtr, int tile_diffs, int *cnt);
-extern void do_copyregion(sraRegionPtr region, int dx, int dy);
+extern void do_copyregion(sraRegionPtr region, int dx, int dy, int mode);
 
 #endif /* _X11VNC_USERINPUT_H */
diff --git a/x11vnc/winattr_t.h b/x11vnc/winattr_t.h
index d153f600d51f5afacf46fc90e654fdcdd60708f7..1696b3f909707ce8c0949eef0e406a9e2d42d5e0 100644
--- a/x11vnc/winattr_t.h
+++ b/x11vnc/winattr_t.h
@@ -19,7 +19,13 @@ typedef struct winattr {
 	double su_time;
 	int bs_x, bs_y, bs_w, bs_h;
 	int su_x, su_y, su_w, su_h;
-	int selectinput;
+	Window above;
+	short vis_state;
+	short selectinput;
+	short map_cnt;
+	short unmap_cnt;
+	short vis_cnt;
+	short create_cnt;
 } winattr_t;
 
 #endif /* _X11VNC_WINATTR_T_H */
diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1
index 736bd5cb8ecd07b8fd7aff7810e078e49527f665..d82c9faaecb510582b3a7f9580dd5c1a5a299bc5 100644
--- a/x11vnc/x11vnc.1
+++ b/x11vnc/x11vnc.1
@@ -2,7 +2,7 @@
 .TH X11VNC "1" "December 2006" "x11vnc " "User Commands"
 .SH NAME
 x11vnc - allow VNC connections to real X11 displays
-         version: 0.8.4, lastmod: 2006-12-17
+         version: 0.8.4, lastmod: 2006-12-28
 .SH SYNOPSIS
 .B x11vnc
 [OPTION]...
@@ -2391,16 +2391,52 @@ will have to set things up so you can't see that region.
 If this method is successful, the changes required for
 clients to do this less awkwardly will be investigated.
 .IP
-Note that this mode consumes a lot of memory, both
-on the x11vnc server side and on the VNC Viewer side.
-If n=2 then the amount of RAM used is roughly tripled
-for both x11vnc and the VNC Viewer.  As a rule of
-thumb, note that 1280x1024 at depth 24 is about 5MB of
-pixel data.
+Note that this mode consumes a huge amount of memory,
+both on the x11vnc server side and on the VNC Viewer
+side.  If n=2 then the amount of RAM used is roughly
+tripled for both x11vnc and the VNC Viewer.  As a rule
+of thumb, note that 1280x1024 at depth 24 is about 5MB
+of pixel data.
+.IP
+For reasonable response when cycling through 4 to 6
+large (e.g. web browser) windows a value n of 6 to 12
+is recommended. (that's right: ~10X more memory...)
 .IP
 Because of the way window backingstore and saveunders
 are implemented, n must be even.  It will be incremented
 by 1 if it is not.
+.IP
+This mode also works for native MacOS X, but may not
+be as effective as the X version.  This is due to a
+number of things, one is the drop-shadow compositing
+that leaves extra areas that need to be repaired (see
+\fB-ncache_pad).\fR  Another is the window iconification
+animations need to be avoided (see \fB-macicontime).\fR
+It appears the that the 'Scale' animation mode gives
+better results than the 'Genie' one.  Also, window event
+detection not as accurate as the X version.
+.PP
+\fB-ncache_cr\fR
+.IP
+In \fB-nache\fR mode, try do to copyrect opaque window
+moves/drags instead of wireframes (this can induce
+painting errors).  The wireframe will still be used when
+moving a window whose save-unders has not yet been set
+or has been invalidated.
+.IP
+Some VNC Viewers provide better response than others
+with this option.  On Unix, realvnc viewer gives
+smoother drags than tightvnc viewer.  Response may also
+be choppy if the server side machine is too slow.
+.PP
+\fB-ncache_pad\fR \fIn\fR
+.IP
+In \fB-nache\fR mode, pad each window with n pixels for the
+caching rectangles.  This can be used to try to improve
+the situation with dropshadows or other compositing
+(e.g. MacOS X window manager), although it could make
+things worse.  The default is 0 on Unix and 24 on
+MacOS X.
 .PP
 \fB-wireframe\fR \fI[str],\fR \fB-nowireframe\fR
 .IP
@@ -3498,6 +3534,19 @@ For the native Mac OS X server, do not resize or reset
 the framebuffer even if it is detected that the screen
 resolution or depth has changed.
 .PP
+\fB-maciconanim\fR \fIn\fR
+.IP
+For the native Mac OS X server, set n to the number
+of milliseconds that the window iconify/deiconify
+animation takes.  In \fB-ncache\fR mode this value will be
+used to skip the animation if possible. (default 400)
+.PP
+\fB-macmenu\fR
+.IP
+For the native Mac OS X server, in \fB-ncache\fR client-side
+caching mode, try to cache pull down menus (not perfect
+because they have animated fades, etc.)
+.PP
 \fB-gui\fR \fI[gui-opts]\fR
 .IP
 Start up a simple tcl/tk gui based on the the remote
@@ -3942,6 +3991,16 @@ dragging        disable \fB-nodragging\fR mode.
 .IP
 nodragging      enable  \fB-nodragging\fR mode.
 .IP
+ncache          reenable \fB-ncache\fR mode.
+.IP
+noncache        disable  \fB-ncache\fR mode.
+.IP
+ncache_size:n   set \fB-ncache\fR size to n.
+.IP
+ncache_cr       enable  \fB-ncache_cr\fR mode.
+.IP
+noncache_cr     disable \fB-ncache_cr\fR mode.
+.IP
 wireframe       enable  \fB-wireframe\fR mode. same as "wf"
 .IP
 nowireframe     disable \fB-wireframe\fR mode. same as "nowf"
@@ -4071,6 +4130,26 @@ macnosaver      enable  \fB-macnosaver\fR mode.
 .IP
 macsaver        disable \fB-macnosaver\fR mode.
 .IP
+macnowait       enable  \fB-macnowait\fR  mode.
+.IP
+macwait         disable \fB-macnowait\fR  mode.
+.IP
+macwheel:n      set \fB-macwheel\fR to n.
+.IP
+macnoswap       enable  \fB-macnoswap\fR mouse button mode.
+.IP
+macswap         disable \fB-macnoswap\fR mouse button mode.
+.IP
+macnoresize     enable  \fB-macnoresize\fR mode.
+.IP
+macresize       disable \fB-macnoresize\fR mode.
+.IP
+maciconanim:n   set \fB-maciconanim\fR to n.
+.IP
+macmenu         enable  \fB-macmenu\fR  mode.
+.IP
+macnomenu       disable \fB-macnmenu\fR mode.
+.IP
 httpport:n      set \fB-httpport\fR to n.
 .IP
 httpdir:dir     set \fB-httpdir\fR to dir (and enable http).
@@ -4203,7 +4282,8 @@ show_cursor noshow_cursor nocursor arrow xfixes noxfixes
 xdamage noxdamage xd_area xd_mem alphacut alphafrac
 alpharemove noalpharemove alphablend noalphablend
 xwarppointer xwarp noxwarppointer noxwarp buttonmap
-dragging nodragging wireframe_mode wireframe wf
+dragging nodragging ncache_cr noncache_cr ncache
+noncache ncache_size wireframe_mode wireframe wf
 nowireframe nowf wireframelocal wfl nowireframelocal
 nowfl wirecopyrect wcr nowirecopyrect nowcr scr_area
 scr_skip scr_inc scr_keys scr_term scr_keyrepeat
@@ -4226,7 +4306,10 @@ debug_xdamage debug_wireframe nodebug_wireframe
 debug_wireframe debug_scroll nodebug_scroll debug_scroll
 debug_tiles dbt nodebug_tiles nodbt debug_tiles
 debug_grabs nodebug_grabs debug_sel nodebug_sel dbg
-nodbg macnosaver macsaver noremote
+nodbg macnosaver macsaver nomacnosaver macnowait macwait
+nomacnowait macwheel macnoswap macswap nomacnoswap
+macnoresize macresize nomacnoresize maciconanim macmenu
+macnomenu nomacmenu noremote
 .IP
 aro=  noop display vncdisplay desktopname guess_desktop
 http_url auth xauth users rootshift clipshift
diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c
index de5a3524da23e6909760e978b588568cd4674d62..f8b10f9474a5aff328292261e2a59891f33b0341 100644
--- a/x11vnc/x11vnc.c
+++ b/x11vnc/x11vnc.c
@@ -329,7 +329,7 @@ static int choose_delay(double dt) {
 	}
 	dts[ndt-1] = dt;
 
-if (0 && dt > 0.0) fprintf(stderr, "dt: %.5f %.4f\n", dt, dnow() - x11vnc_start);
+if (0 && dt > 0.0) fprintf(stderr, "dt: %.5f %.4f\n", dt, dnowx());
 	if (bogdown) {
 		if (use_xdamage) {
 			/* DAMAGE can queue ~1000 rectangles for a scroll */
@@ -554,7 +554,7 @@ static void watch_loop(void) {
 			}
 
 			check_new_clients();
-			check_ncache();
+			check_ncache(0, 0);
 			check_xevents(0);
 			check_autorepeat();
 			check_pm();
@@ -2115,6 +2115,11 @@ int main(int argc, char* argv[]) {
 			if (ncache % 2 != 0) {
 				ncache++;
 			}
+		} else if (!strcmp(arg, "-ncache_cr")) {
+			ncache_copyrect = 1;
+		} else if (!strcmp(arg, "-ncache_pad")) {
+			CHECK_ARGC
+			ncache_pad = atoi(argv[++i]);
 #endif
 		} else if (!strcmp(arg, "-wireframe")
 		    || !strcmp(arg, "-wf")) {
@@ -2335,6 +2340,11 @@ int main(int argc, char* argv[]) {
 			macosx_swap23 = 0;
 		} else if (!strcmp(arg, "-macnoresize")) {
 			macosx_resize = 0;
+		} else if (!strcmp(arg, "-maciconanim")) {
+			CHECK_ARGC
+			macosx_icon_anim_time = atoi(argv[++i]);
+		} else if (!strcmp(arg, "-macmenu")) {
+			macosx_ncache_macmenu = 1;
 		} else if (!strcmp(arg, "-gui")) {
 			launch_gui = 1;
 			if (i < argc-1) {
@@ -3094,8 +3104,7 @@ int main(int argc, char* argv[]) {
 
 	if (priv_remote) {
 		if (! remote_control_access_ok()) {
-			rfbLog("** Disabling remote commands in -privremote "
-			    "mode.\n");
+			rfbLog("** Disabling remote commands in -privremote mode.\n");
 			accept_remote_cmds = 0;
 		}
 	}
@@ -3108,8 +3117,7 @@ int main(int argc, char* argv[]) {
 #if LIBVNCSERVER_HAVE_LIBXFIXES
 	if (! XFixesQueryExtension(dpy, &xfixes_base_event_type, &er)) {
 		if (! quiet && ! raw_fb_str) {
-			rfbLog("Disabling XFIXES mode: display does not "
-			    "support it.\n");
+			rfbLog("Disabling XFIXES mode: display does not support it.\n");
 		}
 		xfixes_base_event_type = 0;
 		xfixes_present = 0;
@@ -3124,8 +3132,7 @@ int main(int argc, char* argv[]) {
 #if LIBVNCSERVER_HAVE_LIBXDAMAGE
 	if (! XDamageQueryExtension(dpy, &xdamage_base_event_type, &er)) {
 		if (! quiet && ! raw_fb_str) {
-			rfbLog("Disabling X DAMAGE mode: display does not "
-			    "support it.\n");
+			rfbLog("Disabling X DAMAGE mode: display does not support it.\n");
 		}
 		xdamage_base_event_type = 0;
 		xdamage_present = 0;
@@ -3137,31 +3144,24 @@ int main(int argc, char* argv[]) {
 		use_xdamage = 0;
 	}
 	if (! quiet && xdamage_present && use_xdamage && ! raw_fb_str) {
-		rfbLog("X DAMAGE available on display, using it for"
-		    " polling hints.\n");
-		rfbLog("  To disable this behavior use: "
-		    "'-noxdamage'\n");
+		rfbLog("X DAMAGE available on display, using it for polling hints.\n");
+		rfbLog("  To disable this behavior use: '-noxdamage'\n");
 	}
 
 	if (! quiet && wireframe && ! raw_fb_str) {
-		rfbLog("Wireframing: -wireframe mode is in effect for window "
-		    "moves.\n");
-		rfbLog("  If this yields undesired behavior (poor response, "
-		    "painting\n");
+		rfbLog("\n");
+		rfbLog("Wireframing: -wireframe mode is in effect for window moves.\n");
+		rfbLog("  If this yields undesired behavior (poor response, painting\n");
 		rfbLog("  errors, etc) it may be disabled:\n");
 		rfbLog("   - use '-nowf' to disable wireframing completely.\n");
-		rfbLog("   - use '-nowcr' to disable the Copy Rectangle after "
-		    "the\n");
+		rfbLog("   - use '-nowcr' to disable the Copy Rectangle after the\n");
 		rfbLog("     moved window is released in the new position.\n");
 		rfbLog("  Also see the -help entry for tuning parameters.\n");
-		rfbLog("  You can press 3 Alt_L's (Left \"Alt\" key) in a row"
-		    " to \n");
-		rfbLog("  repaint the screen, also see the -fixscreen option"
-		    " for\n");
+		rfbLog("  You can press 3 Alt_L's (Left \"Alt\" key) in a row to \n");
+		rfbLog("  repaint the screen, also see the -fixscreen option for\n");
 		rfbLog("  periodic repaints.\n");
 		if (scale_str && !strstr(scale_str, "nocr")) {
-			rfbLog("  Note: '-scale' is on and this can cause "
-			    "more problems.\n");
+			rfbLog("  Note: '-scale' is on and this can cause more problems.\n");
 		}
 	}
 
@@ -3169,8 +3169,7 @@ int main(int argc, char* argv[]) {
 #if defined(SOLARIS_OVERLAY) && !NO_X11
 	if (! XQueryExtension(dpy, "SUN_OVL", &maj, &ev, &er)) {
 		if (! quiet && overlay && ! raw_fb_str) {
-			rfbLog("Disabling -overlay: SUN_OVL "
-			    "extension not available.\n");
+			rfbLog("Disabling -overlay: SUN_OVL extension not available.\n");
 		}
 	} else {
 		overlay_present = 1;
@@ -3179,8 +3178,7 @@ int main(int argc, char* argv[]) {
 #if defined(IRIX_OVERLAY) && !NO_X11
 	if (! XReadDisplayQueryExtension(dpy, &ev, &er)) {
 		if (! quiet && overlay && ! raw_fb_str) {
-			rfbLog("Disabling -overlay: IRIX ReadDisplay "
-			    "extension not available.\n");
+			rfbLog("Disabling -overlay: IRIX ReadDisplay extension not available.\n");
 		}
 	} else {
 		overlay_present = 1;
@@ -3202,11 +3200,9 @@ int main(int argc, char* argv[]) {
 			multiple_cursors_mode = strdup("most");
 
 			if (! quiet && ! raw_fb_str) {
-				rfbLog("XFIXES available on display, resetting"
-				    " cursor mode\n");
+				rfbLog("XFIXES available on display, resetting cursor mode\n");
 				rfbLog("  to: '-cursor most'.\n");
-				rfbLog("  to disable this behavior use: "
-				    "'-cursor arrow'\n");
+				rfbLog("  to disable this behavior use: '-cursor arrow'\n");
 				rfbLog("  or '-noxfixes'.\n");
 			}
 		}
@@ -3214,8 +3210,7 @@ int main(int argc, char* argv[]) {
 			if (xfixes_present && use_xfixes &&
 			    overlay_cursor == 1) {
 				if (! quiet && ! raw_fb_str) {
-					rfbLog("using XFIXES for cursor "
-					    "drawing.\n");
+					rfbLog("using XFIXES for cursor drawing.\n");
 				}
 				overlay_cursor = 0;
 			}
@@ -3225,8 +3220,7 @@ int main(int argc, char* argv[]) {
 	if (overlay) {
 		using_shm = 0;
 		if (flash_cmap && ! quiet && ! raw_fb_str) {
-			rfbLog("warning: -flashcmap may be "
-			    "incompatible with -overlay\n");
+			rfbLog("warning: -flashcmap may be incompatible with -overlay\n");
 		}
 		if (show_cursor && overlay_cursor) {
 			char *s = multiple_cursors_mode;
@@ -3252,19 +3246,14 @@ int main(int argc, char* argv[]) {
 	/* check for XTEST */
 	if (! XTestQueryExtension_wr(dpy, &ev, &er, &maj, &min)) {
 		if (! quiet && ! raw_fb_str) {
-			rfbLog("WARNING: XTEST extension not available "
-			    "(either missing from\n");
-			rfbLog("  display or client library libXtst "
-			    "missing at build time).\n");
-			rfbLog("  MOST user input (pointer and keyboard) "
-			    "will be DISCARDED.\n");
-			rfbLog("  If display does have XTEST, be sure to "
-			    "build x11vnc with\n");
-			rfbLog("  a working libXtst build environment "
-			    "(e.g. libxtst-dev,\n");
+			rfbLog("\n");
+			rfbLog("WARNING: XTEST extension not available (either missing from\n");
+			rfbLog("  display or client library libXtst missing at build time).\n");
+			rfbLog("  MOST user input (pointer and keyboard) will be DISCARDED.\n");
+			rfbLog("  If display does have XTEST, be sure to build x11vnc with\n");
+			rfbLog("  a working libXtst build environment (e.g. libxtst-dev,\n");
 			rfbLog("  or other packages).\n");
-			rfbLog("No XTEST extension, switching to "
-			    "-xwarppointer mode for\n");
+			rfbLog("No XTEST extension, switching to -xwarppointer mode for\n");
 			rfbLog("  pointer motion input.\n");
 		}
 		xtest_present = 0;
@@ -3297,6 +3286,7 @@ int main(int argc, char* argv[]) {
 	if (! XRecordQueryVersion_wr(dpy, &maj, &min)) {
 		xrecord_present = 0;
 		if (! quiet) {
+			rfbLog("\n");
 			rfbLog("The RECORD X extension was not found on the display.\n");
 			rfbLog("If your system has disabled it by default, you can\n");
 			rfbLog("enable it to get a nice x11vnc performance speedup\n");
@@ -3333,23 +3323,39 @@ int main(int argc, char* argv[]) {
 	tmpi = 0;
 #endif
 	if (! quiet && tmpi && ! raw_fb_str) {
-		rfbLog("Scroll Detection: -scrollcopyrect mode is in effect "
-		    "to\n");
-		rfbLog("  use RECORD extension to try to detect scrolling "
-		    "windows\n");
+		rfbLog("\n");
+		rfbLog("Scroll Detection: -scrollcopyrect mode is in effect to\n");
+		rfbLog("  use RECORD extension to try to detect scrolling windows\n");
 		rfbLog("  (induced by either user keystroke or mouse input).\n");
-		rfbLog("  If this yields undesired behavior (poor response, "
-		    "painting\n");
+		rfbLog("  If this yields undesired behavior (poor response, painting\n");
 		rfbLog("  errors, etc) it may be disabled via: '-noscr'\n");
 		rfbLog("  Also see the -help entry for tuning parameters.\n");
-		rfbLog("  You can press 3 Alt_L's (Left \"Alt\" key) in a row"
-		    " to \n");
-		rfbLog("  repaint the screen, also see the -fixscreen option"
-		    " for\n");
+		rfbLog("  You can press 3 Alt_L's (Left \"Alt\" key) in a row to \n");
+		rfbLog("  repaint the screen, also see the -fixscreen option for\n");
 		rfbLog("  periodic repaints.\n");
 		if (scale_str && !strstr(scale_str, "nocr")) {
-			rfbLog("  Note: '-scale' is on and this can cause "
-			    "more problems.\n");
+			rfbLog("  Note: '-scale' is on and this can cause more problems.\n");
+		}
+	}
+
+	if (! quiet && ncache && ! raw_fb_str) {
+		rfbLog("\n");
+		rfbLog("Client Side Caching: -ncache mode is in effect to provide\n");
+		rfbLog("  some client-side pixel data caching.  This speeds up\n");
+		rfbLog("  iconifying/deiconifying windows, moving and raising\n");
+		rfbLog("  windows, and reposting menus.  In the simple CopyRect\n");
+		rfbLog("  encoding scheme used (no compression) a huge amount\n");
+		rfbLog("  of extra memory (20-80MB) is used on both the server and\n");
+		rfbLog("  client sides.  This mode works with any VNC viewer,\n");
+		rfbLog("  however in most you can actually see the cached pixel\n");
+		rfbLog("  data by scrolling down, so you need to re-adjust its size.\n");
+		rfbLog("  If this mode yields undesired behavior (poor response,\n");
+		rfbLog("  painting errors, etc) it may be disabled via: '-ncache 0'\n");
+		rfbLog("  You can press 3 Alt_L's (Left \"Alt\" key) in a row to \n");
+		rfbLog("  repaint the screen, also see the -fixscreen option for\n");
+		rfbLog("  periodic repaints.\n");
+		if (scale_str) {
+			rfbLog("  Note: '-scale' is on and this can cause more problems.\n");
 		}
 	}
 
@@ -3367,16 +3373,14 @@ int main(int argc, char* argv[]) {
 		xshm_present = 0;
 		if (! using_shm) {
 			if (! quiet && ! raw_fb_str) {
-				rfbLog("info: display does not support"
-				    " XShm.\n");
+				rfbLog("info: display does not support XShm.\n");
 			}
 		} else {
 		    if (! quiet && ! raw_fb_str) {
+			rfbLog("\n");
 			rfbLog("warning: XShm extension is not available.\n");
-			rfbLog("For best performance the X Display should be"
-			    " local. (i.e.\n");
-			rfbLog("the x11vnc and X server processes should be"
-			    " running on\n");
+			rfbLog("For best performance the X Display should be local. (i.e.\n");
+			rfbLog("the x11vnc and X server processes should be running on\n");
 			rfbLog("the same machine.)\n");
 #if LIBVNCSERVER_HAVE_XSHM
 			rfbLog("Restart with -noshm to override this.\n");
@@ -3396,8 +3400,7 @@ int main(int argc, char* argv[]) {
 	initialize_watch_bell();
 	if (!xkb_present && use_xkb_modtweak) {
 		if (! quiet && ! raw_fb_str) {
-			rfbLog("warning: disabling xkb modtweak."
-			    " XKEYBOARD ext. not present.\n");
+			rfbLog("warning: disabling xkb modtweak. XKEYBOARD ext. not present.\n");
 		}
 		use_xkb_modtweak = 0;
 	}
@@ -3412,8 +3415,7 @@ int main(int argc, char* argv[]) {
 #if LIBVNCSERVER_HAVE_LIBXRANDR
 	if (! XRRQueryExtension(dpy, &xrandr_base_event_type, &er)) {
 		if (xrandr && ! quiet && ! raw_fb_str) {
-			rfbLog("Disabling -xrandr mode: display does not"
-			    " support X RANDR.\n");
+			rfbLog("Disabling -xrandr mode: display does not support X RANDR.\n");
 		}
 		xrandr_base_event_type = 0;
 		xrandr = 0;
diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c
index 7c0a296deed493c6f411b25ace85cfcc400e7f03..9227b55877ee8b3c3586fecbceac730ef13a622e 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.8.4 lastmod: 2006-12-17";
+char lastmod[] = "0.8.4 lastmod: 2006-12-28";
 
 /* X display info */
 
diff --git a/x11vnc/xevents.c b/x11vnc/xevents.c
index 83fce6df6b55b204bdba397dd053e744045cb7db..ad950492c3d413bd15e1f368dac1c84ff424fbf5 100644
--- a/x11vnc/xevents.c
+++ b/x11vnc/xevents.c
@@ -108,7 +108,7 @@ static void initialize_xevents(int reset) {
 		 */
 		X_LOCK;
 		xselectinput_rootwin |= PropertyChangeMask;
-		XSelectInput(dpy, rootwin, xselectinput_rootwin);
+		XSelectInput_wr(dpy, rootwin, xselectinput_rootwin);
 		X_UNLOCK;
 		did_xselect_input = 1;
 	}
diff --git a/x11vnc/xrecord.c b/x11vnc/xrecord.c
index ababb371657405f4170dbfadbd89f30d5028d997..26630fd50e311a4fb6b93ea2bd08b75b421be4f9 100644
--- a/x11vnc/xrecord.c
+++ b/x11vnc/xrecord.c
@@ -647,7 +647,7 @@ if (db > 1) fprintf(stderr, "record_CA-%d\n", k++);
 	dt = (dnow() - servertime_diff) - st;
 	fprintf(stderr, "record_CA-%d *FOUND_SCROLL: src: 0x%lx dx: %d dy: %d "
 	"x: %d y: %d w: %d h: %d st: %.4f %.4f  %.4f\n", k++, src, dx, dy,
-	src_x, src_y, w, h, st, dt, dnow() - x11vnc_start);
+	src_x, src_y, w, h, st, dt, dnowx());
  }
 
 	i = scr_ev_cnt;
@@ -1144,7 +1144,7 @@ if (db > 1) fprintf(stderr, "record_CW-%d\n", k++);
 	dt = (dnow() - servertime_diff) - st;
 	fprintf(stderr, "record_CW-%d *FOUND_SCROLL: win: 0x%lx dx: %d dy: %d "
 	"x: %d y: %d w: %d h: %d  st: %.4f  dt: %.4f  %.4f\n", k++, win,
-	dx, dy, src_x, src_y, w, h, st, dt, dnow() - x11vnc_start);
+	dx, dy, src_x, src_y, w, h, st, dt, dnowx());
  }
 
 	i = scr_ev_cnt;
@@ -1271,7 +1271,7 @@ static void record_grab(XPointer ptr, XRecordInterceptData *rec_data) {
 	req = (xReq *) rec_data->data;
 
 	if (req->reqType == X_GrabServer) {
-		double now = dnow() - x11vnc_start;
+		double now = dnowx();
 		xserver_grabbed++;
 		if (db) rfbLog("X server Grabbed:    %d %.5f\n", xserver_grabbed, now);
 		if (xserver_grabbed > 1) {
@@ -1282,7 +1282,7 @@ static void record_grab(XPointer ptr, XRecordInterceptData *rec_data) {
 			xserver_grabbed = 1;
 		}
 	} else if (req->reqType == X_UngrabServer) {
-		double now = dnow() - x11vnc_start;
+		double now = dnowx();
 		xserver_grabbed--;
 		if (xserver_grabbed < 0) {
 			xserver_grabbed = 0;
diff --git a/x11vnc/xwrappers.c b/x11vnc/xwrappers.c
index cc48b4a1c0b6bb208afd6187d65b4d369631c288..5822ddc3f4d221b4b08f5c0f21297e07234b7a48 100644
--- a/x11vnc/xwrappers.c
+++ b/x11vnc/xwrappers.c
@@ -80,6 +80,7 @@ Bool XQueryPointer_wr(Display *display, Window w, Window *root_return,
     int *win_x_return, int *win_y_return, unsigned int *mask_return);
 
 int XFree_wr(void *data);
+int XSelectInput_wr(Display *display, Window w, long event_mask);
 
 void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h);
 static void upup_downdown_warning(KeyCode key, Bool down);
@@ -671,7 +672,7 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
 	}
 	if (debug_keyboard) {
 		rfbLog("calling XTestFakeKeyEvent(%d, %d)  %.4f\n",
-		    key, down, dnow() - x11vnc_start);	
+		    key, down, dnowx());	
 	}
 #if LIBVNCSERVER_HAVE_XTEST
 	XTestFakeKeyEvent(dpy, key, down, delay);
@@ -740,7 +741,7 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
 	}
 	if (debug_pointer) {
 		rfbLog("calling XTestFakeButtonEvent(%d, %d)  %.4f\n",
-		    button, is_press, dnow() - x11vnc_start);	
+		    button, is_press, dnowx());	
 	}
 #if LIBVNCSERVER_HAVE_XTEST
     	XTestFakeButtonEvent(dpy, button, is_press, delay);
@@ -799,7 +800,7 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
 
 	if (debug_pointer) {
 		rfbLog("calling XTestFakeMotionEvent(%d, %d)  %.4f\n",
-		    x, y, dnow() - x11vnc_start);	
+		    x, y, dnowx());	
 	}
 #if LIBVNCSERVER_HAVE_XTEST
 	XTestFakeMotionEvent(dpy, screen, x, y, delay);
@@ -1081,16 +1082,26 @@ Bool XQueryPointer_wr(Display *display, Window w, Window *root_return,
     Window *child_return, int *root_x_return, int *root_y_return,
     int *win_x_return, int *win_y_return, unsigned int *mask_return) {
 	Bool rc;
+	XErrorHandler old_handler;
 
 #if NO_X11
 	return False;
 #else
+
 	if (! display) {
 		return False;
 	}
+	old_handler = XSetErrorHandler(trap_xerror);
+	trapped_xerror = 0;
+
 	rc = XQueryPointer(display, w, root_return, child_return,
 	    root_x_return, root_y_return, win_x_return, win_y_return,
 	    mask_return);
+
+	XSetErrorHandler(old_handler);
+	if (trapped_xerror) {
+		rc = 0;
+	}
 	if (rc) {
 		display_button_mask = (*mask_return) & Bmask;
 		display_mod_mask    = (*mask_return) & Mmask;
@@ -1146,6 +1157,26 @@ int XFree_wr(void *data) {
 #endif
 }
 
+int XSelectInput_wr(Display *display, Window w, long event_mask) {
+#if NO_X11
+	return 0;
+#else
+	int rc;
+	XErrorHandler old_handler;
+	if (display == NULL || w == None) {
+		return 0;
+	}
+	old_handler = XSetErrorHandler(trap_xerror);
+	trapped_xerror = 0;
+	rc = XSelectInput(display, w, event_mask);
+	XSetErrorHandler(old_handler);
+	if (trapped_xerror) {
+		rc = 0;
+	}
+	return rc;
+#endif
+}
+
 void nox11_exit(int rc) {
 #if NO_X11
 	rfbLog("This x11vnc was not built with X11 support.\n");
diff --git a/x11vnc/xwrappers.h b/x11vnc/xwrappers.h
index 6ee2805a1544fa209a5651831242e310328e02b1..22ac1fc8023bea4dacf385a6e47785a25509475d 100644
--- a/x11vnc/xwrappers.h
+++ b/x11vnc/xwrappers.h
@@ -77,6 +77,7 @@ extern Bool XQueryPointer_wr(Display *display, Window w, Window *root_return,
     int *win_x_return, int *win_y_return, unsigned int *mask_return);
 
 extern int XFree_wr(void *data);
+extern int XSelectInput_wr(Display *display, Window w, long event_mask);
 
 
 #endif /* _X11VNC_XWRAPPERS_H */