diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | x11vnc/ChangeLog | 7 | ||||
-rw-r--r-- | x11vnc/README | 295 | ||||
-rwxr-xr-x | x11vnc/tkx11vnc | 1 | ||||
-rw-r--r-- | x11vnc/tkx11vnc.h | 1 | ||||
-rw-r--r-- | x11vnc/x11vnc.1 | 92 | ||||
-rw-r--r-- | x11vnc/x11vnc.c | 364 |
8 files changed, 551 insertions, 234 deletions
@@ -1,3 +1,8 @@ +2005-04-03 Karl Runge <runge@karlrunge.com> + * configure.ac: add conditional libXTrap checking + * x11vnc: use DEC-XTRAP on old X11R5 for grab control. + -shiftcmap n, -http, fix DAMAGE event leak. + 2005-03-29 Karl Runge <runge@karlrunge.com> * x11vnc: fix event leaks, build-time customizations, -nolookup diff --git a/configure.ac b/configure.ac index 3b1fdf1..5274259 100644 --- a/configure.ac +++ b/configure.ac @@ -45,11 +45,13 @@ HAVE_X="false" AC_PATH_XTRA AH_TEMPLATE(HAVE_XSHM, [MIT-SHM extension build environment present]) AH_TEMPLATE(HAVE_XTEST, [XTEST extension build environment present]) +AH_TEMPLATE(HAVE_XTESTGRABCONTROL, [XTEST extension has XTestGrabControl]) AH_TEMPLATE(HAVE_XKEYBOARD, [XKEYBOARD extension build environment present]) AH_TEMPLATE(HAVE_LIBXINERAMA, [XINERAMA extension build environment present]) AH_TEMPLATE(HAVE_LIBXRANDR, [XRANDR extension build environment present]) AH_TEMPLATE(HAVE_LIBXFIXES, [XFIXES extension build environment present]) AH_TEMPLATE(HAVE_LIBXDAMAGE, [XDAMAGE extension build environment present]) +AH_TEMPLATE(HAVE_LIBXTRAP, [DEC-XTRAP extension build environment present]) if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then AC_CHECK_LIB(X11, XGetImage, HAVE_X="true", HAVE_X="false", @@ -62,11 +64,29 @@ if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then [AC_DEFINE(HAVE_XSHM)], , $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) + AC_CHECK_LIB(Xtst, XTestGrabControl, + X_PRELIBS="$X_PRELIBS -lXtst" + [AC_DEFINE(HAVE_XTESTGRABCONTROL) HAVE_XTESTGRABCONTROL="true"], , + $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) + AC_CHECK_LIB(Xtst, XTestFakeKeyEvent, X_PRELIBS="$X_PRELIBS -lXtst" [AC_DEFINE(HAVE_XTEST)], , $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) + # we use XTRAP on X11R5, or user can set X11VNC_USE_XTRAP + if test ! -z "$X11VNC_USE_XTRAP" -o -z "$HAVE_XTESTGRABCONTROL"; then + AC_CHECK_LIB(XTrap, XETrapSetGrabServer, + X_PRELIBS="$X_PRELIBS -lXTrap" + [AC_DEFINE(HAVE_LIBXTRAP)], , + $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) + # tru64 uses libXETrap.so + AC_CHECK_LIB(XETrap, XETrapSetGrabServer, + X_PRELIBS="$X_PRELIBS -lXETrap" + [AC_DEFINE(HAVE_LIBXTRAP)], , + $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) + fi + saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" AC_CHECK_HEADER(X11/XKBlib.h, HAVE_XKBLIB_H="true", diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index a996b14..20448ab 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,10 @@ +2005-04-03 Karl Runge <runge@karlrunge.com> + * try DEC-XTRAP on X11R5 if XTestGrabControl is missing. + * -shiftcmap n, for 8bpp displays using < 256 color cells + and with pixel values shifted from zero. + * fix DAMAGE event leak after viewers disconnect. + * -http option to try to guess where the java viewer is. + 2005-03-29 Karl Runge <runge@karlrunge.com> * build-time customizations X11VNC_SHARED, X11VNC_FOREVER, REMOTE_CONTROL, SMALL_FOOTPRINT for CPPFLAGS diff --git a/x11vnc/README b/x11vnc/README index dae101d..f079d56 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Tue Mar 29 09:30:54 EST 2005 +x11vnc README file Date: Sun Apr 3 16:28:59 EDT 2005 The following information is taken from these URLs: @@ -515,9 +515,14 @@ make x11vnc is both a client and a server at the same time. It is an X client because it connects to the running X server to do the screen polls. Think of it as a rather efficient "screenshot" program running - continuously. It is a server in the sense that it is a VNC server that - VNC viewers on the network can connect to and view the screen - framebuffer it manages. + continuously. It is a server in the sense that it is a VNC server VNC + viewers on the network can connect to and view the screen framebuffer + it manages. + + When trying debug problems, remember to think of both roles. E.g. "how + is x11vnc connecting to the X server?", "how is the vncviewer + connecting to x11vnc?", "what permits/restricts the connection?". Both + links may have reachability, permission, and other issues. Network performance: Whether you are using Xvnc or x11vnc it is always a good idea to have a solid background color instead of a @@ -1311,7 +1316,22 @@ display :0 env CPPFLAGS="-DX11VNC_FOREVER=1" ./configure; make If other things (e.g. "-I ...") are needed in CPPFLAGS add them as - well. Let us know if more customizations would be useful. + well. + + Let us know if more build-time customizations would be useful. + + If the system does not have the XTEST XTestGrabControl interface (some + early X11R5 systems have XTEST but not this interface), then configure + will automatically try to see if the DEC-XTRAP extension build + environment is available and use that for avoiding GrabServer + deadlock. If you want DEC-XTRAP compiled in no matter what, set + X11VNC_USE_XTRAP=1 in your environment. Note that DEC-XTRAP should + only be used as a last resort on legacy machines since the standard + XTEST works well. If there is interest for legacy machines to use + DEC-XTRAP for all of the user input injection (not just grab control) + let us know and we will put it in for you to try. (Note: DEC-XTRAP + grab control seems to be broken on Linux/XFree86) + [Win2VNC Related] Q-12: I have two separate machine displays in front of me, one Windows @@ -1559,8 +1579,8 @@ TrueColor defdepth 24 If the X display machine is a traditional Xterminal (where the X server process runs on the Xterminal box, but all of the X client applications (mozilla, etc) run on a central server (aka "terminal - server")), you will need somehow to be able to log into the Xterminal - machine (i.e. get a shell there) and start the x11vnc program. If the + server")), you will need to log into the Xterminal machine (i.e. get a + shell running there) and then start the x11vnc program. If the Xterminal Linux/Unix machine is stripped down (e.g. no users besides root) that may be difficult. @@ -1568,13 +1588,14 @@ TrueColor defdepth 24 hence the MIT-MAGIC-COOKIE auth files, are on the central server and not on the Xterminal box where the X server and x11vnc processes are. - To run the x11vnc process on the Xterminal box, somehow the - MIT-MAGIC-COOKIE auth file data (XAUTHORITY or $HOME/.Xauthority) must - be accessible by or 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 [189]-auth option to point to the correct file). Other - options include copying the auth file using scp, or something like: + So unless X permissions are completely turned off (e.g. "xhost +"), to + run the x11vnc process on the Xterminal box the MIT-MAGIC-COOKIE auth + file data (XAUTHORITY or $HOME/.Xauthority) must be accessible by or + 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 + [189]-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 - and then, say, ssh from central-server to xterm123 to start x11vnc. @@ -3822,62 +3843,64 @@ 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.7.2pre lastmod: 2005-03-1 -9 +x11vnc: allow VNC connections to real X11 displays. 0.7.2pre lastmod: 2005-04-0 +3 x11vnc options: -display disp -auth file -id windowid -sid windowid -clip WxH+X+Y -flashcmap - -notruecolor -visual n - -overlay -overlay_nocursor - -scale fraction -scale_cursor frac - -viewonly -shared - -once -forever - -timeout n -inetd + -shiftcmap n -notruecolor + -visual n -overlay + -overlay_nocursor -scale fraction + -scale_cursor frac -viewonly + -shared -once + -forever -timeout n + -inetd -http -connect string -vncconnect -novncconnect -allow host1[,host2..] - -localhost -input string - -viewpasswd string -passwdfile filename - -storepasswd pass file -accept string - -gone string -users list - -noshm -flipbyteorder - -onetile -solid [color] - -blackout string -xinerama - -xrandr [mode] -padgeom WxH - -o logfile -rc filename - -norc -h, -help - -?, -opts -V, -version - -q -bg - -modtweak -nomodtweak - -xkb -skip_keycodes string - -add_keysyms -clear_mods - -clear_keys -remap string - -norepeat -repeat - -nofb -nobell - -nosel -noprimary - -cursor [mode] -nocursor - -arrow n -noxfixes - -alphacut n -alphafrac fraction - -alpharemove -noalphablend - -nocursorshape -cursorpos - -nocursorpos -xwarppointer - -buttonmap string -nodragging - -pointer_mode n -input_skip n - -speeds rd,bw,lat -debug_pointer - -debug_keyboard -defer time - -wait time -nap - -nonap -sb time - -noxdamage -xd_area A - -xd_mem f -sigpipe string - -threads -nothreads - -fs f -gaps n - -grow n -fuzz n - -snapfb -gui [gui-opts] - -remote command -query variable - -sync -noremote - -unsafe -safer - -deny_all + -localhost -nolookup + -input string -viewpasswd string + -passwdfile filename -storepasswd pass file + -accept string -gone string + -users list -noshm + -flipbyteorder -onetile + -solid [color] -blackout string + -xinerama -xrandr [mode] + -padgeom WxH -o logfile + -rc filename -norc + -h, -help -?, -opts + -V, -version -q + -bg -modtweak + -nomodtweak -xkb + -skip_keycodes string -add_keysyms + -clear_mods -clear_keys + -remap string -norepeat + -repeat -nofb + -nobell -nosel + -noprimary -cursor [mode] + -nocursor -arrow n + -noxfixes -alphacut n + -alphafrac fraction -alpharemove + -noalphablend -nocursorshape + -cursorpos -nocursorpos + -xwarppointer -buttonmap string + -nodragging -pointer_mode n + -input_skip n -speeds rd,bw,lat + -debug_pointer -debug_keyboard + -defer time -wait time + -nap -nonap + -sb time -noxdamage + -xd_area A -xd_mem f + -sigpipe string -threads + -nothreads -fs f + -gaps n -grow n + -fuzz n -snapfb + -gui [gui-opts] -remote command + -query variable -sync + -noremote -unsafe + -safer -deny_all + libvncserver options: -rfbport port TCP port for RFB protocol @@ -3903,8 +3926,8 @@ libvncserver options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.7.2pre lastmod: 2005-03-1 -9 +x11vnc: allow VNC connections to real X11 displays. 0.7.2pre lastmod: 2005-04-0 +3 Typical usage is: @@ -3978,6 +4001,13 @@ Options: -flashcmap In 8bpp indexed color, let the installed colormap flash as the pointer moves from window to window (slow). +-shiftcmap n Rare problem, but some 8bpp displays use less than 256 + colorcells (e.g. 16-color grayscale, perhaps the other + bits are used for double buffering) *and* also need to + shift the pixels values away from 0, .., ncells. "n" + indicates the shift to be applied to the pixel values. + To see the pixel values set DEBUG_CMAP=1 to print out + a colormap histogram. Example: -shiftcmap 240 -notruecolor For 8bpp displays, force indexed color (i.e. a colormap) even if it looks like 8bpp TrueColor (rare problem). -visual n Experimental option: probably does not do what you @@ -4027,7 +4057,7 @@ Options: If "fraction" contains a decimal point "." it is taken as a floating point number, alternatively the notation "m/n" may be used to denote fractions - exactly, e.g. -scale 2/3. + exactly, e.g. -scale 2/3 Scaling Options: can be added after "fraction" via ":", to supply multiple ":" options use commas. @@ -4061,6 +4091,11 @@ Options: Note: if you are not redirecting stderr to a log file (via shell 2> or -o option) you must also specify the -q option, otherwise the stderr goes to the viewer. +-http Instead of using -httpdir (see below) to specify + where the Java vncviewer applet is, have x11vnc try + to *guess* where the directory is by looking relative + to the program location and in standard locations + (/usr/local/share/x11vnc/classes, etc). -connect string For use with "vncviewer -listen" reverse connections. If "string" has the form "host" or "host:port" the connection is made once at startup. Use commas @@ -4100,6 +4135,11 @@ Options: vice versa) to avoid situations where no connections (or too many) are allowed. +-nolookup Do not use gethostbyname() or gethostbyaddr() to look up + host names or IP numbers. Use this if name resolution + is incorrectly set up and leads to long pauses as name + lookup times out, etc. + -input string Fine tuning of allowed user input. If "string" does not contain a comma "," the tuning applies only to normal clients. Otherwise the part before "," is @@ -4341,6 +4381,7 @@ Options: to the terminal. Same as "-logfile file". To append to the file use "-oa file" or "-logappend file". -rc filename Use "filename" instead of $HOME/.x11vncrc for rc file. + -norc Do not process any .x11vncrc file for options. -h, -help Print this help text. -?, -opts Only list the x11vnc options. @@ -4576,7 +4617,7 @@ Options: or scrolling. So a scheme has to be used to "eat" much of that pointer input before re-polling the screen and sending out framebuffer updates. The mode number - "n" can be 0 to 4 and selects one of the schemes + "n" can be 0 to 5 and selects one of the schemes desribed below. n=0: does the same as -nodragging. (all screen polling @@ -4589,19 +4630,24 @@ Options: n=2 is an improved scheme: by watching the current rate of input events it tries to detect if it should try to "eat" additional pointer events before continuing. + This mode was the default until Apr 2005. + + n=3 is basically the same as n=2 except with slightly + tweaked parameters. We made this a new one so one + could use -pm 2 for the old behavior. NOT FINISHED. - n=3 is basically a dynamic -nodragging mode: it detects + n=4 is basically a dynamic -nodragging mode: it detects when the mouse motion has paused and then refreshes the display. - n=4: attempts to measures network rates and latency, + n=5 attempts to measures network rates and latency, the video card read rate, and how many tiles have been changed on the screen. From this, it aggressively tries to push screen "frames" when it decides it has enough resources to do so. NOT FINISHED. - The default n is 2. Note that modes 2, 3, 4 will skip - -input_skip keyboard events (but it will not count + The default n is 2. Note that modes 2, 3, 4, 5 will + skip -input_skip keyboard events (but it will not count pointer events). Also note that these modes are not available in -threads mode which has its own pointer event handling mechanism. @@ -4619,7 +4665,7 @@ Options: -speeds rd,bw,lat x11vnc tries to estimate some speed parameters that are used to optimize scheduling (e.g. -pointer_mode - 4) and other things. Use the -speeds option to set + 5) and other things. Use the -speeds option to set these manually. The triple "rd,bw,lat" corresponds to video h/w read rate in MB/sec, network bandwidth to clients in KB/sec, and network latency to clients in @@ -4627,14 +4673,16 @@ Options: e.g. "-speeds ,100,15", then the internal scheme is used to estimate the empty value(s). + Note: use this option is currently NOT FINISHED. + Typical PC video cards have read rates of 5-10 MB/sec. If the framebuffer is in main memory instead of video h/w (e.g. SunRay, shadowfb, Xvfb), the read rate may be much faster. "x11perf -getimage500" can be used to get a lower bound (remember to factor in the bytes per pixel). It is up to you to estimate the network - bandwith to clients. For the latency the ping(1) - command can be used. + bandwith and latency to clients. For the latency the + ping(1) command can be used. For convenience there are some aliases provided, e.g. "-speeds modem". The aliases are: "modem" for @@ -4815,6 +4863,7 @@ Options: clip:WxH+X+Y set -clip mode to "WxH+X+Y" flashcmap enable -flashcmap mode. noflashcmap disable -flashcmap mode. + shiftcmap:n set -shiftcmap to n. notruecolor enable -notruecolor mode. truecolor disable -notruecolor mode. overlay enable -overlay mode (if applicable). @@ -4834,6 +4883,8 @@ Options: timeout:n reset -timeout to n, if there are currently no clients, exit unless one connects in the next n secs. + http enable http client connections. + nohttp disable http client connections. deny deny any new connections, same as "lock" nodeny allow new connections, same as "unlock" connect:host do reverse connection to host, "host" @@ -4843,8 +4894,8 @@ Options: same as "close:host". Use host "all" to close all current clients. If you know the client internal hex ID, - e.g. 0x3 (returned by -query clients and - RFB_CLIENT_ID), you can use that too. + e.g. 0x3 (returned by "-query clients" + and RFB_CLIENT_ID) you can use that too. allowonce:host For the next connection only, allow connection from "host". allow:hostlist set -allow list to (comma separated) @@ -4855,6 +4906,8 @@ Options: localhost enable -localhost mode nolocalhost disable -localhost mode listen:str set -listen to str, empty to disable. + nolookup enable -nolookup mode. + lookup disable -nolookup mode. input:str set -input to "str", empty to disable. client_input:str set the K, M, B -input on a per-client basis. select which client as for @@ -4965,8 +5018,6 @@ Options: desktop:str set -desktop name to str for new clients . rfbport:n set -rfbport to n. - http enable http client connections. - nohttp disable http client connections. httpport:n set -httpport to n. httpdir:dir set -httpdir to dir (and enable http). enablehttpproxy enable -enablehttpproxy mode. @@ -5019,27 +5070,28 @@ Options: the returned value corresponds to (hint: the ext_* variables correspond to the presence of X extensions): - ans= stop quit exit shutdown ping blacken zero refresh - reset close disconnect id sid waitmapped nowaitmapped - clip flashcmap noflashcmap truecolor notruecolor - overlay nooverlay overlay_cursor overlay_yescursor - nooverlay_nocursor nooverlay_cursor nooverlay_yescursor - overlay_nocursor visual scale scale_cursor viewonly - noviewonly shared noshared forever noforever once - timeout deny lock nodeny unlock connect allowonce - allow localhost nolocalhost listen accept gone - shm noshm flipbyteorder noflipbyteorder onetile - noonetile solid_color solid nosolid blackout xinerama - noxinerama xrandr noxrandr xrandr_mode padgeom quiet - q noquiet modtweak nomodtweak xkb noxkb skip_keycodes - add_keysyms noadd_keysyms clear_mods noclear_mods - clear_keys noclear_keys remap repeat norepeat fb nofb - bell nobell sel nosel primary noprimary cursorshape - nocursorshape cursorpos nocursorpos cursor show_cursor - noshow_cursor nocursor arrow xfixes noxfixes xdamage - noxdamage xd_area xd_mem alphacut alphafrac alpharemove - noalpharemove alphablend noalphablend xwarp xwarppointer - noxwarp noxwarppointer buttonmap dragging nodragging + ans= stop quit exit shutdown ping blacken zero + refresh reset close disconnect id sid waitmapped + nowaitmapped clip flashcmap noflashcmap shiftcmap + truecolor notruecolor overlay nooverlay overlay_cursor + overlay_yescursor nooverlay_nocursor nooverlay_cursor + nooverlay_yescursor overlay_nocursor visual scale + scale_cursor viewonly noviewonly shared noshared + forever noforever once timeout deny lock nodeny unlock + connect allowonce allow localhost nolocalhost listen + lookup nolookup accept gone shm noshm flipbyteorder + noflipbyteorder onetile noonetile solid_color solid + nosolid blackout xinerama noxinerama xrandr noxrandr + xrandr_mode padgeom quiet q noquiet modtweak nomodtweak + xkb noxkb skip_keycodes add_keysyms noadd_keysyms + clear_mods noclear_mods clear_keys noclear_keys + remap repeat norepeat fb nofb bell nobell sel nosel + primary noprimary cursorshape nocursorshape cursorpos + nocursorpos cursor show_cursor noshow_cursor nocursor + arrow xfixes noxfixes xdamage noxdamage xd_area + xd_mem alphacut alphafrac alpharemove noalpharemove + alphablend noalphablend xwarp xwarppointer noxwarp + noxwarppointer buttonmap dragging nodragging pointer_mode pm input_skip input client_input speeds debug_pointer dp nodebug_pointer nodp debug_keyboard dk nodebug_keyboard nodk deferupdate defer wait rfbwait @@ -5055,19 +5107,20 @@ Options: scaling_nomult4 scaling_pad scaling_interpolate inetd safer unsafe passwdfile using_shm logfile o rc norc h help V version lastmod bg sigpipe threads clients - client_count pid ext_xtest ext_xkb ext_xshm ext_xinerama - ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin - num_buttons button_mask 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 + client_count pid ext_xtest ext_xtrap ext_xkb ext_xshm + ext_xinerama ext_overlay ext_xfixes ext_xdamage + ext_xrandr rootwin num_buttons button_mask 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 -sync By default -remote commands are run asynchronously, that is, the request is posted and the program immediately exits. Use -sync to have the program wait for an - acknowledgement from the x11vnc server that command - was processed. On the other hand -query requests are - always processed synchronously because they have wait - for the result. + acknowledgement from the x11vnc server that command was + processed (somehow). On the other hand -query requests + are always processed synchronously because they have + to wait for the result. Also note that if both -remote and -query requests are supplied on the command line, the -remote is processed @@ -5083,19 +5136,21 @@ Options: -noremote Do not process any remote control commands or queries. A note about security wrt remote control commands. - If someone can connect to the X display and change the - property VNC_CONNECT, then they can remotely control - x11vnc. Normally access to the X display is protected. - Note that if they can modify VNC_CONNECT, they could - also run their own x11vnc and have complete control + If someone can connect to the X display and change + the property VNC_CONNECT, then they can remotely + control x11vnc. Normally access to the X display is + protected. Note that if they can modify VNC_CONNECT + on the X server, they have enough permissions to also + run their own x11vnc and thus have complete control of the desktop. If the "-connect /path/to/file" - channel is being used, obviously anyone who can - write to /path/to/file can remotely control x11vnc. - So be sure to protect the X display and that file's - write permissions. - - To disable the VNC_CONNECT property channel completely - use -novncconnect. + channel is being used, obviously anyone who can write + to /path/to/file can remotely control x11vnc. So be + sure to protect the X display and that file's write + permissions. + + If you are paranoid and do not think -noremote is + enough, to disable the VNC_CONNECT property channel + completely use -novncconnect. -unsafe If x11vnc is running as root (e.g. inetd or Xsetup for a display manager) a few remote commands are disabled diff --git a/x11vnc/tkx11vnc b/x11vnc/tkx11vnc index 3e793f5..6115a85 100755 --- a/x11vnc/tkx11vnc +++ b/x11vnc/tkx11vnc @@ -114,6 +114,7 @@ Screen -- visual: flashcmap + shiftcmap: notruecolor -- clip: diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h index b64c437..512a45f 100644 --- a/x11vnc/tkx11vnc.h +++ b/x11vnc/tkx11vnc.h @@ -120,6 +120,7 @@ " --\n" " visual:\n" " flashcmap\n" +" shiftcmap:\n" " notruecolor\n" " --\n" " clip:\n" diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index cd519d9..e1d4cf8 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -1,8 +1,8 @@ .\" This file was automatically generated from x11vnc -help output. -.TH X11VNC "1" "March 2005" "x11vnc " "User Commands" +.TH X11VNC "1" "April 2005" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.7.2pre, lastmod: 2005-03-29 + version: 0.7.2pre, lastmod: 2005-04-03 .SH SYNOPSIS .B x11vnc [OPTION]... @@ -103,6 +103,16 @@ of the selected window. In 8bpp indexed color, let the installed colormap flash as the pointer moves from window to window (slow). .PP +\fB-shiftcmap\fR \fIn\fR +.IP +Rare problem, but some 8bpp displays use less than 256 +colorcells (e.g. 16-color grayscale, perhaps the other +bits are used for double buffering) *and* also need to +shift the pixels values away from 0, .., ncells. \fIn\fR +indicates the shift to be applied to the pixel values. +To see the pixel values set DEBUG_CMAP=1 to print out +a colormap histogram. Example: \fB-shiftcmap\fR 240 +.PP \fB-notruecolor\fR .IP For 8bpp displays, force indexed color (i.e. a colormap) @@ -224,6 +234,14 @@ Note: if you are not redirecting stderr to a log file (via shell 2> or \fB-o\fR option) you must also specify the \fB-q\fR option, otherwise the stderr goes to the viewer. .PP +\fB-http\fR +.IP +Instead of using \fB-httpdir\fR (see below) to specify +where the Java vncviewer applet is, have x11vnc try +to *guess* where the directory is by looking relative +to the program location and in standard locations +(/usr/local/share/x11vnc/classes, etc). +.PP \fB-connect\fR \fIstring\fR .IP For use with "vncviewer -listen" reverse connections. @@ -942,7 +960,7 @@ This mode was the default until Apr 2005. .IP n=3 is basically the same as n=2 except with slightly tweaked parameters. We made this a new one so one -could use \fB-pm\fR 2 for the old behavior. +could use \fB-pm\fR 2 for the old behavior. NOT FINISHED. .IP n=4 is basically a dynamic \fB-nodragging\fR mode: it detects when the mouse motion has paused and then refreshes @@ -954,7 +972,7 @@ changed on the screen. From this, it aggressively tries to push screen "frames" when it decides it has enough resources to do so. NOT FINISHED. .IP -The default n is 3. Note that modes 2, 3, 4, 5 will +The default n is 2. Note that modes 2, 3, 4, 5 will skip \fB-input_skip\fR keyboard events (but it will not count pointer events). Also note that these modes are not available in \fB-threads\fR mode which has its own pointer @@ -977,7 +995,7 @@ Default: 10 .IP x11vnc tries to estimate some speed parameters that are used to optimize scheduling (e.g. \fB-pointer_mode\fR -4) and other things. Use the \fB-speeds\fR option to set +5) and other things. Use the \fB-speeds\fR option to set these manually. The triple \fIrd,bw,lat\fR corresponds to video h/w read rate in MB/sec, network bandwidth to clients in KB/sec, and network latency to clients in @@ -1239,6 +1257,8 @@ flashcmap enable \fB-flashcmap\fR mode. .IP noflashcmap disable \fB-flashcmap\fR mode. .IP +shiftcmap:n set \fB-shiftcmap\fR to n. +.IP notruecolor enable \fB-notruecolor\fR mode. .IP truecolor disable \fB-notruecolor\fR mode. @@ -1274,6 +1294,10 @@ timeout:n reset \fB-timeout\fR to n, if there are currently no clients, exit unless one connects in the next n secs. .IP +http enable http client connections. +.IP +nohttp disable http client connections. +.IP deny deny any new connections, same as "lock" .IP nodeny allow new connections, same as "unlock" @@ -1508,10 +1532,6 @@ desktop:str set \fB-desktop\fR name to str for new clients. .IP rfbport:n set \fB-rfbport\fR to n. .IP -http enable http client connections. -.IP -nohttp disable http client connections. -.IP httpport:n set \fB-httpport\fR to n. .IP httpdir:dir set \fB-httpdir\fR to dir (and enable http). @@ -1592,27 +1612,28 @@ remote command, we hope the name makes it obvious what the returned value corresponds to (hint: the ext_* variables correspond to the presence of X extensions): .IP -ans= stop quit exit shutdown ping blacken zero refresh -reset close disconnect id sid waitmapped nowaitmapped -clip flashcmap noflashcmap truecolor notruecolor -overlay nooverlay overlay_cursor overlay_yescursor -nooverlay_nocursor nooverlay_cursor nooverlay_yescursor -overlay_nocursor visual scale scale_cursor viewonly -noviewonly shared noshared forever noforever once -timeout deny lock nodeny unlock connect allowonce allow -localhost nolocalhost listen lookup nolookup accept -gone shm noshm flipbyteorder noflipbyteorder onetile -noonetile solid_color solid nosolid blackout xinerama -noxinerama xrandr noxrandr xrandr_mode padgeom quiet -q noquiet modtweak nomodtweak xkb noxkb skip_keycodes -add_keysyms noadd_keysyms clear_mods noclear_mods -clear_keys noclear_keys remap repeat norepeat fb nofb -bell nobell sel nosel primary noprimary cursorshape -nocursorshape cursorpos nocursorpos cursor show_cursor -noshow_cursor nocursor arrow xfixes noxfixes xdamage -noxdamage xd_area xd_mem alphacut alphafrac alpharemove -noalpharemove alphablend noalphablend xwarp xwarppointer -noxwarp noxwarppointer buttonmap dragging nodragging +ans= stop quit exit shutdown ping blacken zero +refresh reset close disconnect id sid waitmapped +nowaitmapped clip flashcmap noflashcmap shiftcmap +truecolor notruecolor overlay nooverlay overlay_cursor +overlay_yescursor nooverlay_nocursor nooverlay_cursor +nooverlay_yescursor overlay_nocursor visual scale +scale_cursor viewonly noviewonly shared noshared +forever noforever once timeout deny lock nodeny unlock +connect allowonce allow localhost nolocalhost listen +lookup nolookup accept gone shm noshm flipbyteorder +noflipbyteorder onetile noonetile solid_color solid +nosolid blackout xinerama noxinerama xrandr noxrandr +xrandr_mode padgeom quiet q noquiet modtweak nomodtweak +xkb noxkb skip_keycodes add_keysyms noadd_keysyms +clear_mods noclear_mods clear_keys noclear_keys +remap repeat norepeat fb nofb bell nobell sel nosel +primary noprimary cursorshape nocursorshape cursorpos +nocursorpos cursor show_cursor noshow_cursor nocursor +arrow xfixes noxfixes xdamage noxdamage xd_area +xd_mem alphacut alphafrac alpharemove noalpharemove +alphablend noalphablend xwarp xwarppointer noxwarp +noxwarppointer buttonmap dragging nodragging pointer_mode pm input_skip input client_input speeds debug_pointer dp nodebug_pointer nodp debug_keyboard dk nodebug_keyboard nodk deferupdate defer wait rfbwait @@ -1628,11 +1649,12 @@ scale_numer scale_denom scale_fac scaling_noblend scaling_nomult4 scaling_pad scaling_interpolate inetd safer unsafe passwdfile using_shm logfile o rc norc h help V version lastmod bg sigpipe threads clients -client_count pid ext_xtest ext_xkb ext_xshm ext_xinerama -ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin -num_buttons button_mask 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 +client_count pid ext_xtest ext_xtrap ext_xkb ext_xshm +ext_xinerama ext_overlay ext_xfixes ext_xdamage +ext_xrandr rootwin num_buttons button_mask 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 .PP \fB-sync\fR .IP diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index 5b670b0..d98a4c1 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -165,6 +165,7 @@ #define LIBVNCSERVER_HAVE_XSHM 1 #define LIBVNCSERVER_HAVE_XTEST 1 +#define LIBVNCSERVER_HAVE_XTESTGRABCONTROL 1 #define LIBVNCSERVER_HAVE_PWD_H 1 #define LIBVNCSERVER_HAVE_SYS_WAIT_H 1 @@ -290,6 +291,7 @@ #define LIBVNCSERVER_HAVE_PWD_H 0 #define REMOTE_CONTROL 0 #endif +/****************************************************************************/ /* Extensions and related includes: */ @@ -306,6 +308,16 @@ #if LIBVNCSERVER_HAVE_XTEST #include <X11/extensions/XTest.h> #endif +static int xtest_base_event_type = 0; + +#if LIBVNCSERVER_HAVE_LIBXTRAP +#define NEED_EVENTS +#define NEED_REPLIES +#include <X11/extensions/xtraplib.h> +#include <X11/extensions/xtraplibp.h> +XETC *trap_ctx = NULL; +#endif +static int xtrap_base_event_type = 0; #if LIBVNCSERVER_HAVE_XKEYBOARD #include <X11/XKBlib.h> @@ -373,8 +385,9 @@ int overlay_present = 0; */ #if LIBVNCSERVER_HAVE_LIBXRANDR #include <X11/extensions/Xrandr.h> -static int xrandr_base_event_type = 0; #endif +static int xrandr_base_event_type = 0; + int xfixes_present = 0; int use_xfixes = 1; @@ -383,29 +396,29 @@ int alpha_threshold = 240; double alpha_frac = 0.33; int alpha_remove = 0; int alpha_blend = 1; - int alt_arrow = 1; #if LIBVNCSERVER_HAVE_LIBXFIXES #include <X11/extensions/Xfixes.h> -static int xfixes_base_event_type = 0; #endif +static int xfixes_base_event_type = 0; + int xdamage_present = 0; int use_xdamage = 1; /* just use the xdamage rects. for scanline hints */ #if LIBVNCSERVER_HAVE_LIBXDAMAGE #include <X11/extensions/Xdamage.h> -static int xdamage_base_event_type = 0; Damage xdamage = 0; #endif +static int xdamage_base_event_type = 0; int xdamage_max_area = 20000; /* pixels */ double xdamage_memory = 1.0; /* in units of NSCAN */ int xdamage_tile_count; -int hack_val = 0; /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.7.2pre lastmod: 2005-03-29"; +char lastmod[] = "0.7.2pre lastmod: 2005-04-03"; +int hack_val = 0; /* X display info */ @@ -461,7 +474,7 @@ unsigned long main_red_mask, main_green_mask, main_blue_mask; unsigned short main_red_max, main_green_max, main_blue_max; unsigned short main_red_shift, main_green_shift, main_blue_shift; -/* we now have a struct with client specific data: */ +/* struct with client specific data: */ #define RATE_SAMPLES 5 #define CILEN 10 typedef struct _ClientData { @@ -559,8 +572,8 @@ int scanlines[NSCAN] = { 19, 3, 27, 11, 29, 13, 5, 21 }; -/* function prototypes (see filename comment above) */ +/* function prototypes (see filename comment above) */ int all_clients_initialized(void); void close_all_clients(void); void close_clients(char *); @@ -606,8 +619,8 @@ void initialize_watch_bell(void); void initialize_xinerama(void); void initialize_xfixes(void); void initialize_xdamage(void); -void create_xdamage(void); -void destroy_xdamage(void); +void create_xdamage_if_needed(void); +void destroy_xdamage_if_needed(void); void initialize_xrandr(void); XImage *initialize_xdisplay_fb(void); @@ -620,6 +633,7 @@ int XTestGrabControl_wr(Display*, Bool); Bool XTestCompareCurrentCursorWithWindow_wr(Display*, Window); Bool XTestCompareCursorWithWindow_wr(Display*, Window, Cursor); Bool XTestQueryExtension_wr(Display*, int*, int*, int*, int*); +Bool XETrapQueryExtension_wr(Display*, int*, int*, int*); void XTestDiscard_wr(Display*); typedef struct hint { @@ -698,6 +712,7 @@ void push_black_screen(int); void push_sleep(int); void refresh_screen(void); + /* -- options.h -- */ /* * variables for the command line options @@ -753,6 +768,7 @@ char *viewonly_passwd = NULL; /* view only passwd. */ int inetd = 0; /* spawned from inetd(1) */ int first_conn_timeout = 0; /* -timeout */ int flash_cmap = 0; /* follow installed colormaps */ +int shift_cmap = 0; /* ncells < 256 and needs shift of pixel values */ int force_indexed_color = 0; /* whether to force indexed color for 8bpp */ int launch_gui = 0; /* -gui */ @@ -801,7 +817,7 @@ char *remap_file = NULL; /* -remap */ char *pointer_remap = NULL; /* use the various ways of updating pointer */ #ifndef POINTER_MODE_DEFAULT -#define POINTER_MODE_DEFAULT 3 +#define POINTER_MODE_DEFAULT 2 #endif #define POINTER_MODE_NOFB 2 int pointer_mode = POINTER_MODE_DEFAULT; @@ -851,6 +867,11 @@ int xtest_present = 1; #else int xtest_present = 0; #endif +#if LIBVNCSERVER_HAVE_LIBXTRAP +int xtrap_present = 1; +#else +int xtrap_present = 0; +#endif #if LIBVNCSERVER_HAVE_XKEYBOARD int xkb_present = 1; #else @@ -2300,6 +2321,7 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, XTestFakeKeyEvent(dpy, key, down, delay); #endif } +/* XTRAP: XESimulateXEventRequest(tc, KeyPress, key, 0, 0, 0); */ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, unsigned long delay) { @@ -2310,6 +2332,7 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, XTestFakeButtonEvent(dpy, button, is_press, delay); #endif } +/* XTRAP: XESimulateXEventRequest(tc, ButtonPress, button, 0, 0, 0); */ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, unsigned long delay) { @@ -2320,6 +2343,7 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, XTestFakeMotionEvent(dpy, screen, x, y, delay); #endif } +/* XTRAP: XESimulateXEventRequest(tc, MotionNotify, 0, x, y, 0); */ Bool XTestCompareCurrentCursorWithWindow_wr(Display* dpy, Window w) { if (! xtest_present) { @@ -2343,11 +2367,20 @@ Bool XTestCompareCursorWithWindow_wr(Display* dpy, Window w, Cursor cursor) { #endif } +/* how to handle old tree for this w/o OLD_TREE? */ +#if 0 +#if LIBVNCSERVER_HAVE_XTEST +#ifndef LIBVNCSERVER_HAVE_XTESTGRABCONTROL +#define LIBVNCSERVER_HAVE_XTESTGRABCONTROL 1 +#endif +#endif +#endif + int XTestGrabControl_wr(Display* dpy, Bool impervious) { if (! xtest_present) { return 0; } -#if LIBVNCSERVER_HAVE_XTEST +#if LIBVNCSERVER_HAVE_XTEST && LIBVNCSERVER_HAVE_XTESTGRABCONTROL return XTestGrabControl(dpy, impervious); #else return 0; @@ -2372,6 +2405,43 @@ void XTestDiscard_wr(Display *dpy) { #endif } +Bool XETrapQueryExtension_wr(Display *dpy, int *ev, int *er, int *op) { +#if LIBVNCSERVER_HAVE_LIBXTRAP + return XETrapQueryExtension(dpy, (INT32 *)ev, (INT32 *)er, + (INT32 *)op); +#else + return False; +#endif +} + +void disable_grabserver(void) { +#if LIBVNCSERVER_HAVE_XTEST && LIBVNCSERVER_HAVE_XTESTGRABCONTROL + if (XTestGrabControl_wr(dpy, True)) { + return; + } +#endif +#if LIBVNCSERVER_HAVE_LIBXTRAP + if (xtrap_present) { + ReqFlags requests; + + trap_ctx = XECreateTC(dpy, 0, NULL); + if (! trap_ctx) { + rfbLog("DEC-XTRAP XECreateTC failed. Watch out for" + "XGrabServer from wm's\n"); + return; + } + XEStartTrapRequest(trap_ctx); + memset(requests, 0, sizeof(requests)); + BitTrue(requests, X_GrabServer); + BitTrue(requests, X_UngrabServer); + XETrapSetRequests(trap_ctx, True, requests); + XETrapSetGrabServer(trap_ctx, True); + return; + } +#endif + rfbLog("No XTEST or DEC-XTRAP protection from XGrabServer.\n"); +} + /* -- cleanup.c -- */ /* @@ -2453,6 +2523,11 @@ void clean_up_exit (int ret) { XDamageDestroy(dpy, xdamage); } #endif +#if LIBVNCSERVER_HAVE_LIBXTRAP + if (trap_ctx) { + XEFreeTC(trap_ctx); + } +#endif XCloseDisplay(dpy); X_UNLOCK; @@ -7049,17 +7124,30 @@ void check_xevents(void) { } } - if (now > last_call && XCheckTypedEvent(dpy, MappingNotify, &xev)) { - /* we only check this once a second or so. */ - XRefreshKeyboardMapping((XMappingEvent *) &xev); + if (now > last_call+1) { + /* we only check these once a second or so. */ + int n = 0; while (XCheckTypedEvent(dpy, MappingNotify, &xev)) { XRefreshKeyboardMapping((XMappingEvent *) &xev); + n++; } - if (use_modifier_tweak) { + if (n && use_modifier_tweak) { X_UNLOCK; initialize_modtweak(); X_LOCK; } + if (xtrap_base_event_type) { + int base = xtrap_base_event_type; + while (XCheckTypedEvent(dpy, base, &xev)) { + ; + } + } + if (xtest_base_event_type) { + int base = xtest_base_event_type; + while (XCheckTypedEvent(dpy, base, &xev)) { + ; + } + } } if (last_sendevent && (now > last_sendevent+1 || now % 10 == 0)) { @@ -7176,7 +7264,7 @@ void check_xevents(void) { } #ifndef DEBUG_XEVENTS -#define DEBUG_XEVENTS 0 +#define DEBUG_XEVENTS 1 #endif #if DEBUG_XEVENTS if (hack_val) { @@ -7210,7 +7298,7 @@ void check_xevents(void) { } #endif - if (now > last_sync + 3600) { + if (now > last_sync + 1200) { /* kludge for any remaining event leaks */ int bugout = use_xdamage ? 500 : 50; if (last_sync != 0) { @@ -7547,7 +7635,8 @@ int check_httpdir(void) { if (stat(httpdir, &sbuf) == 0) { /* good enough for me */ - rfbLog("check_httpdir: guessed: %s\n", httpdir); + rfbLog("check_httpdir: guessed directory:\n"); + rfbLog(" %s\n", httpdir); http_dir = httpdir; return 1; } else { @@ -7562,7 +7651,8 @@ int check_httpdir(void) { http_dir = strdup("/usr/share/x11vnc/classes"); return 1; } - rfbLog("check_httpdir: bad guess: %s\n", httpdir); + rfbLog("check_httpdir: bad guess:\n"); + rfbLog(" %s\n", httpdir); return 0; } } @@ -7941,6 +8031,17 @@ char *process_remote_cmd(char *cmd, int stringonly) { rfbLog("process_remote_cmd: turning off flashcmap mode.\n"); flash_cmap = 0; + } else if (strstr(p, "shiftcmap") == p) { + COLON_CHECK("shiftcmap:") + if (query) { + snprintf(buf, bufn, "ans=%s%s%d", p, co, shift_cmap); + goto qry; + } + p += strlen("shiftcmap:"); + shift_cmap = atoi(p); + rfbLog("process_remote_cmd: set -shiftcmap %d\n", shift_cmap); + do_new_fb(1); + } else if (!strcmp(p, "truecolor")) { int orig = force_indexed_color; if (query) { @@ -9190,7 +9291,7 @@ char *process_remote_cmd(char *cmd, int stringonly) { use_xdamage = 1; if (use_xdamage != orig) { initialize_xdamage(); - create_xdamage(); + create_xdamage_if_needed(); } } else if (!strcmp(p, "noxdamage")) { int orig = use_xdamage; @@ -9207,7 +9308,7 @@ char *process_remote_cmd(char *cmd, int stringonly) { use_xdamage = 0; if (use_xdamage != orig) { initialize_xdamage(); - destroy_xdamage(); + destroy_xdamage_if_needed(); } } else if (strstr(p, "xd_area") == p) { @@ -9948,6 +10049,8 @@ char *process_remote_cmd(char *cmd, int stringonly) { snprintf(buf, bufn, "aro=%s:%d", p, (int) getpid()); } else if (!strcmp(p, "ext_xtest")) { snprintf(buf, bufn, "aro=%s:%d", p, xtest_present); + } else if (!strcmp(p, "ext_xtrap")) { + snprintf(buf, bufn, "aro=%s:%d", p, xtrap_present); } else if (!strcmp(p, "ext_xkb")) { snprintf(buf, bufn, "aro=%s:%d", p, xkb_present); } else if (!strcmp(p, "ext_xshm")) { @@ -10318,7 +10421,7 @@ void initialize_xdamage(void) { } } -void create_xdamage(void) { +void create_xdamage_if_needed(void) { #if LIBVNCSERVER_HAVE_LIBXDAMAGE if (! xdamage) { X_LOCK; @@ -10330,7 +10433,7 @@ void create_xdamage(void) { #endif } -void destroy_xdamage(void) { +void destroy_xdamage_if_needed(void) { #if LIBVNCSERVER_HAVE_LIBXDAMAGE if (xdamage) { XEvent ev; @@ -10351,7 +10454,7 @@ void destroy_xdamage(void) { } void check_xdamage_state(void) { - if (! use_xdamage || ! xdamage_present) { + if (! xdamage_present) { return; } /* @@ -10359,9 +10462,9 @@ void check_xdamage_state(void) { * one if no clients are connected. */ if (client_count) { - create_xdamage(); + create_xdamage_if_needed(); } else { - destroy_xdamage(); + destroy_xdamage_if_needed(); } } @@ -11723,19 +11826,30 @@ int get_which_cursor(void) { } if (which == which0) { /* the string "term" mean I-beam. */ + char *name, *class; lowercase(winfo.res_name); lowercase(winfo.res_class); - if (strstr(winfo.res_name, "term")) { + name = winfo.res_name; + class = winfo.res_class; + if (strstr(name, "term")) { + which = CURS_TERM; + } else if (strstr(class, "term")) { + which = CURS_TERM; + } else if (strstr(name, "text")) { + which = CURS_TERM; + } else if (strstr(class, "text")) { + which = CURS_TERM; + } else if (strstr(name, "onsole")) { which = CURS_TERM; - } else if (strstr(winfo.res_class, "term")) { + } else if (strstr(class, "onsole")) { which = CURS_TERM; - } else if (strstr(winfo.res_name, "text")) { + } else if (strstr(name, "cmdtool")) { which = CURS_TERM; - } else if (strstr(winfo.res_class, "text")) { + } else if (strstr(class, "cmdtool")) { which = CURS_TERM; - } else if (strstr(winfo.res_name, "onsole")) { + } else if (strstr(name, "shelltool")) { which = CURS_TERM; - } else if (strstr(winfo.res_class, "onsole")) { + } else if (strstr(class, "shelltool")) { which = CURS_TERM; } } @@ -12184,12 +12298,14 @@ void set_colormap(int reset) { } } - if (first && ncells != NCOLOR) { - if (! quiet) { - fprintf(stderr, "set_colormap: number of cells is %d " + if (ncells != NCOLOR) { + if (first && ! quiet) { + rfbLog("set_colormap: number of cells is %d " "instead of %d.\n", ncells, NCOLOR); } - screen->colourMap.count = ncells; + if (! shift_cmap) { + screen->colourMap.count = ncells; + } } if (flash_cmap && ! first) { @@ -12215,7 +12331,7 @@ void set_colormap(int reset) { } } if (ncells > NCOLOR && ! quiet) { - fprintf(stderr, "set_colormap: big problem: ncells=%d > %d\n", + rfbLog("set_colormap: big problem: ncells=%d > %d\n", ncells, NCOLOR); } @@ -12225,7 +12341,7 @@ void set_colormap(int reset) { * the StaticColor map. The ncells = 8 is "8 per subfield" * mentioned in xdpyinfo. Looks OK... perhaps fortuitously. */ - if (ncells == 8) { + if (ncells == 8 && ! shift_cmap) { ncells = NCOLOR; } } @@ -12239,7 +12355,9 @@ void set_colormap(int reset) { X_UNLOCK; - for(i=0; i < ncells; i++) { + for(i = ncells - 1; i >= 0; i--) { + int k = i + shift_cmap; + screen->colourMap.data.shorts[i*3+0] = color[i].red; screen->colourMap.data.shorts[i*3+1] = color[i].green; screen->colourMap.data.shorts[i*3+2] = color[i].blue; @@ -12249,6 +12367,13 @@ void set_colormap(int reset) { prev[i].blue != color[i].blue ) { diffs++; } + + if (shift_cmap && k >= 0 && k < NCOLOR) { + /* kludge to copy the colors to higher pixel values */ + screen->colourMap.data.shorts[k*3+0] = color[i].red; + screen->colourMap.data.shorts[k*3+1] = color[i].green; + screen->colourMap.data.shorts[k*3+2] = color[i].blue; + } } if (diffs && ! first) { @@ -12256,12 +12381,57 @@ void set_colormap(int reset) { rfbLog("set_colormap: warning: sending cmap " "with uninitialized clients.\n"); } - rfbSetClientColourMaps(screen, 0, ncells); + if (shift_cmap) { + rfbSetClientColourMaps(screen, 0, NCOLOR); + } else { + rfbSetClientColourMaps(screen, 0, ncells); + } } first = 0; } +void debug_colormap(XImage *fb) { + static int debug_cmap = -1; + int i, k, histo[NCOLOR]; + + if (debug_cmap < 0) { + if (getenv("DEBUG_CMAP") != NULL) { + debug_cmap = 1; + } else { + debug_cmap = 0; + } + } + if (! debug_cmap) { + return; + } + if (! fb) { + return; + } + if (fb->bits_per_pixel != 8) { + return; + } + + for (i=0; i < NCOLOR; i++) { + histo[i] = 0; + } + for (k = 0; k < fb->width * fb->height; k++) { + unsigned char n; + char c = *(fb->data + k); + + n = (unsigned char) c; + histo[n]++; + } + fprintf(stderr, "\nColormap histogram for current screen contents:\n"); + for (i=0; i < NCOLOR; i++) { + fprintf(stderr, " %03d: %7d", i, histo[i]); + if ((i+1) % 4 == 0) { + fprintf(stderr, "\n"); + } + } + fprintf(stderr, "\n"); +} + /* * Experimental mode to force the visual of the window instead of querying * it. Used for testing, overriding some rare cases (win2vnc), and for @@ -13088,6 +13258,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { screen->serverFormat.trueColour = FALSE; indexed_color = 1; set_colormap(1); + debug_colormap(fb); } else { /* * general case, we call it truecolor, but could be direct @@ -18095,6 +18266,7 @@ static void watch_loop(void) { check_xevents(); check_connect_inputs(); check_padded_fb(); + check_xdamage_state(); if (started_as_root) { check_switched_user(); } @@ -18129,10 +18301,6 @@ static void watch_loop(void) { continue; } - if (use_xdamage) { - check_xdamage_state(); - } - if (button_mask && (!show_dragging || pointer_mode == 0)) { /* * if any button is pressed do not update rfb @@ -18247,6 +18415,13 @@ static void print_help(int mode) { "\n" "-flashcmap In 8bpp indexed color, let the installed colormap flash\n" " as the pointer moves from window to window (slow).\n" +"-shiftcmap n Rare problem, but some 8bpp displays use less than 256\n" +" colorcells (e.g. 16-color grayscale, perhaps the other\n" +" bits are used for double buffering) *and* also need to\n" +" shift the pixels values away from 0, .., ncells. \"n\"\n" +" indicates the shift to be applied to the pixel values.\n" +" To see the pixel values set DEBUG_CMAP=1 to print out\n" +" a colormap histogram. Example: -shiftcmap 240\n" "-notruecolor For 8bpp displays, force indexed color (i.e. a colormap)\n" " even if it looks like 8bpp TrueColor (rare problem).\n" "-visual n Experimental option: probably does not do what you\n" @@ -18330,6 +18505,11 @@ static void print_help(int mode) { " Note: if you are not redirecting stderr to a log file\n" " (via shell 2> or -o option) you must also specify the\n" " -q option, otherwise the stderr goes to the viewer.\n" +"-http Instead of using -httpdir (see below) to specify\n" +" where the Java vncviewer applet is, have x11vnc try\n" +" to *guess* where the directory is by looking relative\n" +" to the program location and in standard locations\n" +" (/usr/local/share/x11vnc/classes, etc).\n" "-connect string For use with \"vncviewer -listen\" reverse connections.\n" " If \"string\" has the form \"host\" or \"host:port\"\n" " the connection is made once at startup. Use commas\n" @@ -18880,7 +19060,7 @@ static void print_help(int mode) { "\n" " n=3 is basically the same as n=2 except with slightly\n" " tweaked parameters. We made this a new one so one\n" -" could use -pm 2 for the old behavior.\n" +" could use -pm 2 for the old behavior. NOT FINISHED.\n" "\n" " n=4 is basically a dynamic -nodragging mode: it detects\n" " when the mouse motion has paused and then refreshes\n" @@ -18911,7 +19091,7 @@ static void print_help(int mode) { "\n" "-speeds rd,bw,lat x11vnc tries to estimate some speed parameters that\n" " are used to optimize scheduling (e.g. -pointer_mode\n" -" 4) and other things. Use the -speeds option to set\n" +" 5) and other things. Use the -speeds option to set\n" " these manually. The triple \"rd,bw,lat\" corresponds\n" " to video h/w read rate in MB/sec, network bandwidth to\n" " clients in KB/sec, and network latency to clients in\n" @@ -19110,6 +19290,7 @@ static void print_help(int mode) { " clip:WxH+X+Y set -clip mode to \"WxH+X+Y\"\n" " flashcmap enable -flashcmap mode.\n" " noflashcmap disable -flashcmap mode.\n" +" shiftcmap:n set -shiftcmap to n.\n" " notruecolor enable -notruecolor mode.\n" " truecolor disable -notruecolor mode.\n" " overlay enable -overlay mode (if applicable).\n" @@ -19130,6 +19311,9 @@ static void print_help(int mode) { " timeout:n reset -timeout to n, if there are\n" " currently no clients, exit unless one\n" " connects in the next n secs.\n" +/* access */ +" http enable http client connections.\n" +" nohttp disable http client connections.\n" " deny deny any new connections, same as \"lock\"\n" " nodeny allow new connections, same as \"unlock\"\n" /* access, filename */ @@ -19269,8 +19453,6 @@ static void print_help(int mode) { " desktop:str set -desktop name to str for new clients.\n" " rfbport:n set -rfbport to n.\n" /* access */ -" http enable http client connections.\n" -" nohttp disable http client connections.\n" " httpport:n set -httpport to n.\n" " httpdir:dir set -httpdir to dir (and enable http).\n" " enablehttpproxy enable -enablehttpproxy mode.\n" @@ -19323,27 +19505,28 @@ static void print_help(int mode) { " the returned value corresponds to (hint: the ext_*\n" " variables correspond to the presence of X extensions):\n" "\n" -" ans= stop quit exit shutdown ping blacken zero refresh\n" -" reset close disconnect id sid waitmapped nowaitmapped\n" -" clip flashcmap noflashcmap truecolor notruecolor\n" -" overlay nooverlay overlay_cursor overlay_yescursor\n" -" nooverlay_nocursor nooverlay_cursor nooverlay_yescursor\n" -" overlay_nocursor visual scale scale_cursor viewonly\n" -" noviewonly shared noshared forever noforever once\n" -" timeout deny lock nodeny unlock connect allowonce allow\n" -" localhost nolocalhost listen lookup nolookup accept\n" -" gone shm noshm flipbyteorder noflipbyteorder onetile\n" -" noonetile solid_color solid nosolid blackout xinerama\n" -" noxinerama xrandr noxrandr xrandr_mode padgeom quiet\n" -" q noquiet modtweak nomodtweak xkb noxkb skip_keycodes\n" -" add_keysyms noadd_keysyms clear_mods noclear_mods\n" -" clear_keys noclear_keys remap repeat norepeat fb nofb\n" -" bell nobell sel nosel primary noprimary cursorshape\n" -" nocursorshape cursorpos nocursorpos cursor show_cursor\n" -" noshow_cursor nocursor arrow xfixes noxfixes xdamage\n" -" noxdamage xd_area xd_mem alphacut alphafrac alpharemove\n" -" noalpharemove alphablend noalphablend xwarp xwarppointer\n" -" noxwarp noxwarppointer buttonmap dragging nodragging\n" +" ans= stop quit exit shutdown ping blacken zero\n" +" refresh reset close disconnect id sid waitmapped\n" +" nowaitmapped clip flashcmap noflashcmap shiftcmap\n" +" truecolor notruecolor overlay nooverlay overlay_cursor\n" +" overlay_yescursor nooverlay_nocursor nooverlay_cursor\n" +" nooverlay_yescursor overlay_nocursor visual scale\n" +" scale_cursor viewonly noviewonly shared noshared\n" +" forever noforever once timeout deny lock nodeny unlock\n" +" connect allowonce allow localhost nolocalhost listen\n" +" lookup nolookup accept gone shm noshm flipbyteorder\n" +" noflipbyteorder onetile noonetile solid_color solid\n" +" nosolid blackout xinerama noxinerama xrandr noxrandr\n" +" xrandr_mode padgeom quiet q noquiet modtweak nomodtweak\n" +" xkb noxkb skip_keycodes add_keysyms noadd_keysyms\n" +" clear_mods noclear_mods clear_keys noclear_keys\n" +" remap repeat norepeat fb nofb bell nobell sel nosel\n" +" primary noprimary cursorshape nocursorshape cursorpos\n" +" nocursorpos cursor show_cursor noshow_cursor nocursor\n" +" arrow xfixes noxfixes xdamage noxdamage xd_area\n" +" xd_mem alphacut alphafrac alpharemove noalpharemove\n" +" alphablend noalphablend xwarp xwarppointer noxwarp\n" +" noxwarppointer buttonmap dragging nodragging\n" " pointer_mode pm input_skip input client_input speeds\n" " debug_pointer dp nodebug_pointer nodp debug_keyboard dk\n" " nodebug_keyboard nodk deferupdate defer wait rfbwait\n" @@ -19359,11 +19542,12 @@ static void print_help(int mode) { " scaling_nomult4 scaling_pad scaling_interpolate inetd\n" " safer unsafe passwdfile using_shm logfile o rc norc\n" " h help V version lastmod bg sigpipe threads clients\n" -" client_count pid ext_xtest ext_xkb ext_xshm ext_xinerama\n" -" ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin\n" -" num_buttons button_mask mouse_x mouse_y bpp depth\n" -" indexed_color dpy_x dpy_y wdpy_x wdpy_y off_x off_y\n" -" cdpy_x cdpy_y coff_x coff_y rfbauth passwd\n" +" client_count pid ext_xtest ext_xtrap ext_xkb ext_xshm\n" +" ext_xinerama ext_overlay ext_xfixes ext_xdamage\n" +" ext_xrandr rootwin num_buttons button_mask mouse_x\n" +" mouse_y bpp depth indexed_color dpy_x dpy_y wdpy_x\n" +" wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y rfbauth\n" +" passwd\n" "\n" "-sync By default -remote commands are run asynchronously, that\n" " is, the request is posted and the program immediately\n" @@ -19832,6 +20016,7 @@ int main(int argc, char* argv[]) { int vpw_loc = -1; int dt = 0, bg = 0; int got_rfbwait = 0, got_deferupdate = 0, got_defer = 0; + int got_httpdir = 0, try_http = 0; /* used to pass args we do not know about to rfbGetScreen(): */ int argc_vnc = 1; char *argv_vnc[128]; @@ -19922,6 +20107,9 @@ int main(int argc, char* argv[]) { clip_str = strdup(argv[++i]); } else if (!strcmp(arg, "-flashcmap")) { flash_cmap = 1; + } else if (!strcmp(arg, "-shiftcmap")) { + CHECK_ARGC + shift_cmap = atoi(argv[++i]); } else if (!strcmp(arg, "-notruecolor")) { force_indexed_color = 1; } else if (!strcmp(arg, "-overlay")) { @@ -19957,6 +20145,8 @@ int main(int argc, char* argv[]) { users_list = strdup(argv[++i]); } else if (!strcmp(arg, "-inetd")) { inetd = 1; + } else if (!strcmp(arg, "-http")) { + try_http = 1; } else if (!strcmp(arg, "-connect")) { CHECK_ARGC if (strchr(argv[++i], '/')) { @@ -20281,6 +20471,7 @@ int main(int argc, char* argv[]) { } else if (!strcmp(arg, "-httpdir")) { CHECK_ARGC http_dir = strdup(argv[++i]); + got_httpdir = 1; } else { if (!strcmp(arg, "-desktop") && i < argc-1) { dt = 1; @@ -20563,6 +20754,7 @@ int main(int argc, char* argv[]) { fprintf(stderr, " clip: %s\n", clip_str ? clip_str : "null"); fprintf(stderr, " flashcmap: %d\n", flash_cmap); + fprintf(stderr, " shiftcmap: %d\n", shift_cmap); fprintf(stderr, " force_idx: %d\n", force_indexed_color); fprintf(stderr, " visual: %s\n", visual_str ? visual_str : "null"); @@ -20908,13 +21100,23 @@ int main(int argc, char* argv[]) { } xtest_present = 0; use_xwarppointer = 1; + } else { + xtest_base_event_type = ev; } + + if (! XETrapQueryExtension_wr(dpy, &ev, &er, &maj)) { + xtrap_present = 0; + } else { + xtrap_base_event_type = ev; + } + /* - * Window managers will often grab the display during resize, etc. - * To avoid deadlock (our user resize input is not processed) - * we tell the server to process our requests during all grabs: + * Window managers will often grab the display during resize, + * etc, using XGrabServer(). To avoid deadlock (our user resize + * input is not processed) we tell the server to process our + * requests during all grabs: */ - XTestGrabControl_wr(dpy, True); + disable_grabserver(); /* set OS struct UT */ uname(&UT); @@ -20996,6 +21198,10 @@ int main(int argc, char* argv[]) { initialize_screen(&argc_vnc, argv_vnc, fb0); + if (try_http && ! got_httpdir && check_httpdir()) { + http_connections(1); + } + initialize_tiles(); /* rectangular blackout regions */ |