summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrunge <runge>2005-07-07 01:45:21 +0000
committerrunge <runge>2005-07-07 01:45:21 +0000
commit8fcf08613247c17aab767476fca6870bb45480a9 (patch)
tree27e5c932aeef9f47ee7e3a246da15b810f1401fb
parentc59929365c6b73d89fd0ccbdcb223c0ec44a4d40 (diff)
downloadlibtdevnc-8fcf0861.tar.gz
libtdevnc-8fcf0861.zip
x11vnc: -gui tray now embeds in systray; more improvements to gui.
-rw-r--r--ChangeLog3
-rw-r--r--x11vnc/ChangeLog4
-rw-r--r--x11vnc/README142
-rwxr-xr-xx11vnc/tkx11vnc1737
-rw-r--r--x11vnc/tkx11vnc.h1737
-rw-r--r--x11vnc/x11vnc.184
-rw-r--r--x11vnc/x11vnc.c682
7 files changed, 3577 insertions, 812 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a264a7..826d906 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2005-07-06 Karl Runge <runge@karlrunge.com>
+ * x11vnc: -gui tray now embeds in systray; more improvements to gui.
+
2005-07-01 Karl Runge <runge@karlrunge.com>
* libvncserver/httpd.c: make sure httpListenSock >=0 in rfbHttpCheckFds
* x11vnc: add simple "-gui tray" mode for small icon like x0rfbserver
diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog
index 42bb335..bb3eba8 100644
--- a/x11vnc/ChangeLog
+++ b/x11vnc/ChangeLog
@@ -1,3 +1,7 @@
+2005-07-06 Karl Runge <runge@karlrunge.com>
+ * many improvements to the gui. now embeds into system tray ok.
+ x11vnc -debug_grabs, -printgui, -nosync
+
2005-07-01 Karl Runge <runge@karlrunge.com>
* support for simple "-gui tray" mode (small icon like the original
x0rfbserver had). Can't figure how to get a tray to swallow it..
diff --git a/x11vnc/README b/x11vnc/README
index 8490252..ba771a8 100644
--- a/x11vnc/README
+++ b/x11vnc/README
@@ -1,5 +1,5 @@
-x11vnc README file Date: Fri Jul 1 21:48:07 EDT 2005
+x11vnc README file Date: Wed Jul 6 22:35:15 EDT 2005
The following information is taken from these URLs:
@@ -580,7 +580,7 @@ make
I'd like to release version 0.7.2 in Jun/Jul/2005 sometime, here is
the current tarball:
- RC-4 lastmod: 2005-06-25 [51]x11vnc-0.7.2beta.tar.gz
+ RC-6 lastmod: 2005-07-07 [51]x11vnc-0.7.2beta.tar.gz
There are also some Linux, Solaris, and other OS test binaries
[52]here. Please kick the tires and report bugs, performance
@@ -2363,10 +2363,16 @@ x11vnc -logfile $HOME/.x11vnc.log -rfbauth $HOME/.vnc/passwd -forever -bg
Continuously. Have x11vnc reattach each time the X server is
restarted (i.e. after each logout):
- To make x11vnc always attached to the the X server (please consider
- the security implications of this!) including the login screen you
- will need to add a command to a display manager startup script. The
- name of the script file depends on desktop used and seem to be:
+ To make x11vnc always attached to the the X server including the login
+ screen you will need to add a command to a display manager startup
+ script. Please consider the security implications of this! Besides
+ having the VNC display for the X session always available, there are
+ other issues: .e.g. if you run the tkx11vnc gui (via say -gui or -gui
+ tray), then the gui controls (insecure) are available on the physical
+ X display before anyone has logged in.
+
+ The name of the display manager startup script file depends on desktop
+ used and seem to be:
GNOME /etc/X11/gdm/Init/Default (or Init/:0)
KDE /etc/kde*/kdm/Xsetup
XDM /etc/X11/xdm/Xsetup (or xdm/Xsetup_0)
@@ -4542,7 +4548,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.7.2 lastmod: 2005-07-01
+x11vnc: allow VNC connections to real X11 displays. 0.7.2 lastmod: 2005-07-06
x11vnc options:
-display disp -auth file
@@ -4596,27 +4602,27 @@ x11vnc options:
-scr_keys list -scr_term list
-scr_keyrepeat lo-hi -scr_parms string
-fixscreen string -debug_scroll
- -noxrecord -pointer_mode n
- -input_skip n -speeds rd,bw,lat
- -wmdt string -debug_pointer
- -debug_keyboard -defer time
- -wait time -wait_ui factor
- -nowait_bog -readtimeout n
- -nap -nonap
- -sb time -noxdamage
- -xd_area A -xd_mem f
- -sigpipe string -threads
- -nothreads -fs f
- -gaps n -grow n
- -fuzz n -debug_tiles
- -snapfb -rawfb string
- -pipeinput cmd -gui [gui-opts]
- -remote command -query variable
- -sync -noremote
- -yesremote -unsafe
- -safer -privremote
- -nocmds -deny_all
-
+ -noxrecord -debug_grabs
+ -pointer_mode n -input_skip n
+ -speeds rd,bw,lat -wmdt string
+ -debug_pointer -debug_keyboard
+ -defer time -wait time
+ -wait_ui factor -nowait_bog
+ -readtimeout n -nap
+ -nonap -sb time
+ -noxdamage -xd_area A
+ -xd_mem f -sigpipe string
+ -threads -nothreads
+ -fs f -gaps n
+ -grow n -fuzz n
+ -debug_tiles -snapfb
+ -rawfb string -pipeinput cmd
+ -gui [gui-opts] -remote command
+ -query variable -sync
+ -noremote -yesremote
+ -unsafe -safer
+ -privremote -nocmds
+ -deny_all
libvncserver options:
-rfbport port TCP port for RFB protocol
@@ -4642,7 +4648,7 @@ libvncserver options:
% x11vnc -help
-x11vnc: allow VNC connections to real X11 displays. 0.7.2 lastmod: 2005-07-01
+x11vnc: allow VNC connections to real X11 displays. 0.7.2 lastmod: 2005-07-06
Typical usage is:
@@ -5724,6 +5730,9 @@ Options:
currently used by the -scrollcopyrect scheme and to
monitor X server grabs.
+-debug_grabs Turn on debugging info printout with respect to
+ XGrabServer() deadlock for -scrollcopyrect mode.
+
-pointer_mode n Various pointer motion update schemes. "-pm" is
an alias. The problem is pointer motion can cause
rapid changes on the screen: consider the rapid changes
@@ -5971,9 +5980,10 @@ Options:
up on the X display in the environment variable DISPLAY.
"gui-opts" can be a comma separated list of items.
- Currently there are these types of items: 1) a gui mode,
- a 2) gui "simplicity", 3) the X display the gui
- should display on, and 4) a "tray" (or icon) mode.
+ Currently there are these types of items: 1) a gui
+ mode, a 2) gui "simplicity", 3) the X display the
+ gui should display on, 4) a "tray" or "icon" mode,
+ and 5) a gui geometry.
1) The gui mode can be "start", "conn", or "wait"
"start" is the default mode above and is not required.
@@ -6006,22 +6016,44 @@ Options:
x11vnc polling :0 and display the gui on otherhost:0
The "tray" mode below reverses this preference.
- 4) When "tray" is specified, the gui presents itself
- as a small icon with behavior similar to a "system
- tray" or "dock" applet. The color of the icon
- indicates status (connected clients) and there is also a
- balloon status. Clicking on the icon gives a menu from
- which properties, etc, can be set and the full gui is
- available under "Advanced". To be fully functional,
- the gui mode should be "start" (the default). At some
- point it is hoped the icon can be automatically embedded
- in common destkop trays/docks. Currently one can only
- embed it in a window via, e.g., "tray=0x3600028".
- Otherwise the icon is just a normal standalone window.
-
- Examples: "x11vnc -gui", "x11vnc -gui ez"
- "x11vnc -gui localhost:10", "x11vnc -gui conn,host:0"
- "x11vnc -gui tray,ez"
+ 4) When "tray" or "icon" is specified, the gui
+ presents itself as a small icon with behavior typical
+ of a "system tray" or "dock" applet. The color
+ of the icon indicates status (connected clients) and
+ there is also a balloon status. Clicking on the icon
+ gives a menu from which properties, etc, can be set and
+ the full gui is available under "Advanced". To be
+ fully functional, the gui mode should be "start"
+ (the default).
+
+ For "icon" the gui just a small standalone window.
+ For "tray" it will attempt to embed itself in the
+ "system tray". If "=setpass" is appended then
+ at startup the X11 user will be prompted to set the
+ VNC session password. If =<hexnumber> is appended
+ that icon will attempt to embed itself in the window
+ given by hexnumber. Use =noadvanced to disable the
+ full gui. (To supply more than one, use "+" sign).
+ E.g. -gui tray=setpass and -gui icon=0x3600028
+
+ 5) When "geom=+X+Y" is specified, that geometry
+ is passed to the gui toplevel. This is the icon in
+ icon/tray mode, or the full gui otherwise. You can
+ also specify width and height, i.e. WxH+X+Y, but it
+ is not recommended. In "tray" mode the geometry is
+ ignored unless the system tray manager does not seem
+ to be running. One could imagine using something like
+ "-gui tray,geom=+4000+4000" with a display manager
+ to keep the gui invisible until someone logs in...
+
+ More icon tricks, "icon=minimal" gives an icon just
+ with the VNC display number. You can also set the font
+ with "iconfont=...". The following could be useful:
+ "-gui icon=minimal,iconfont=5x8,geom=24x10+0-0"
+
+ General examples of the -gui option: "x11vnc -gui",
+ "x11vnc -gui ez" "x11vnc -gui localhost:10",
+ "x11vnc -gui conn,host:0", "x11vnc -gui tray,ez"
If you do not intend to start x11vnc from the gui
(i.e. just remote control an existing one), then the
@@ -6286,6 +6318,8 @@ Options:
nodebug_scroll disable debugging scrollcopy mechanism.
debug_tiles enable -debug_tiles
nodebug_tiles disable -debug_tiles
+ debug_grabs enable -debug_grabs
+ nodebug_grabs disable -debug_grabs
dbg enable -dbg crash shell
nodbg disable -dbg crash shell
@@ -6326,10 +6360,10 @@ Options:
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
+ scale_cursor viewonly noviewonly shared noshared forever
+ noforever once timeout deny lock nodeny unlock connect
+ allowonce allow localhost nolocalhost listen lookup
+ nolookup accept popup gone shm noshm flipbyteorder
noflipbyteorder onetile noonetile solid_color solid
nosolid blackout xinerama noxinerama xtrap noxtrap
xrandr noxrandr xrandr_mode padgeom quiet q noquiet
@@ -6360,8 +6394,8 @@ Options:
debug_xevents debug_xdamage nodebug_xdamage
debug_xdamage debug_wireframe nodebug_wireframe
debug_wireframe debug_scroll nodebug_scroll debug_scroll
- debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg
- nodbg noremote
+ debug_tiles dbt nodebug_tiles nodbt debug_tiles
+ debug_grabs nodebug_grabs dbg nodbg noremote
aro= display vncdisplay desktopname guess_desktop
http_url auth users rootshift clipshift scale_str
diff --git a/x11vnc/tkx11vnc b/x11vnc/tkx11vnc
index 38ea77d..91a63cb 100755
--- a/x11vnc/tkx11vnc
+++ b/x11vnc/tkx11vnc
@@ -102,32 +102,41 @@ Displays
Screen
=DRA refresh
=RA reset
- =DRA blacken
+ =RA blacken
fixscreen:
-- D
- id:
- sid:
=D scale:
scale_cursor:
--
- overlay
- overlay_nocursor
- --
=D solid
solid_color:
- visual:
+ --
+ =GAL OverlayVisuals::
+ overlay
+ overlay_nocursor
+ =GAL LOFF
+ =GAL 8-Bit-Color::
flashcmap
shiftcmap:
notruecolor
+ =GAL LOFF
+ =GAL SubWindow::
+ id:
+ sid:
+ =GAL LOFF
+ =GAL ResizeRotate::
+ = xrandr
+ =-C:resize,newfbsize,exit xrandr_mode:
+ padgeom:
+ =GAL LOFF
--
=P blackout:
xinerama
clip:
- rawfb:
--
- = xrandr
- =-C:resize,newfbsize,exit xrandr_mode:
- padgeom:
+ visual:
+ rawfb:
+ pipeinput:
Keyboard
=D norepeat
@@ -135,12 +144,12 @@ Keyboard
modtweak
xkb
--
+ =FP remap:
+ --
skip_keycodes:
sloppy_keys
skip_dups
--
- =FP remap:
- --
clear_mods
clear_keys
@@ -152,53 +161,43 @@ Pointer
=D nocursorshape
--
noxfixes
+ =GAL AlphaBlending::
noalphablend
alphacut:
alphafrac:
alpharemove
+ =GAL LOFF
--
buttonmap:
--
xwarppointer
Misc
+ =GD-C:full,icon,tray WindowView:
=GD simple-gui
-- D
+ =GA all-settings
+ =RA remote-cmd:
+ --
=F rc:
norc
- nolookup
- --
nofb
- --
=D nobell
+ nolookup
+ =GAL Selection::
=D nosel
noprimary
seldir:
+ =GAL LOFF
--
xtrap
xrecord
- =RA reset_record
+ =RQA reset_record
--
bg
=-C:ignore,exit sigpipe:
=0 inetd
rfbwait:
- pipeinput:
- --
- =RA remote-cmd:
- =GA all-settings
- --
- =GAL Misc-Tuning::
- fs:
- gaps:
- grow:
- fuzz:
- wait_ui:
- nowait_bog
- readtimeout:
- snapfb
- threads
- wmdt:
Debugging
debug_pointer
@@ -208,65 +207,63 @@ Debugging
=GA tail-logfile
quiet
--
+ =GAL Misc-Debug::
debug_xevents
debug_xdamage
=-C:0,1,2,3 debug_wireframe:
debug_scroll
debug_tiles
+ debug_grabs
dbg
- --
+ =GAL LOFF
=GA show-start-cmd
=DG debug_gui
Permissions
=DRQA lock
=DRQA unlock
- =SQA deny_all
--
=DFP allow:
=D localhost
=RA allowonce:
listen:
-- D
- =RA noremote
- --
- =D viewonly
=D shared
=D forever
timeout:
--
+ =D viewonly
input:
--
- =S alwaysshared
- =S nevershared
- =S dontdisconnect
+ safer
+ unsafe
+ =RA noremote
--
+ =GAL Passwords::
+ passwd:
viewpasswd:
=F passwdfile:
- =0 storepasswd
=F rfbauth:
- passwd:
- --
- safer
- unsafe
+ =0 storepasswd
+ =GAL LOFF
+ =GAL Misc-Perms::
+ =S alwaysshared
+ =S nevershared
+ =S dontdisconnect
+ =SQA deny_all
+ =GAL LOFF
Tuning
=D-C:0,1,2,3,4 pointer_mode:
input_skip:
=D nodragging
--
- noshm
- flipbyteorder
- onetile
- --
- xdamage
- xd_area:
- xd_mem:
- --
+ =GAL WireFrame::
wireframe
wireframe_mode:
=-C:never,top,always wirecopyrect:
- --
+ =GAL LOFF
+ =GAL ScrollCopyRect::
=-C:never,keys,mouse,always scrollcopyrect:
scr_area:
scr_skip:
@@ -275,6 +272,12 @@ Tuning
scr_term:
scr_keyrepeat:
scr_parms:
+ =GAL LOFF
+ =GAL XDAMAGE::
+ xdamage
+ xd_area:
+ xd_mem:
+ =GAL LOFF
-- D
speeds:
=D wait:
@@ -282,7 +285,24 @@ Tuning
=D nap
screen_blank:
--
+ =GAL SharedMemory::
+ noshm
+ flipbyteorder
+ onetile
+ =GAL LOFF
+ =GAL Misc-Tuning::
progressive:
+ fs:
+ gaps:
+ grow:
+ fuzz:
+ wait_ui:
+ nowait_bog
+ readtimeout:
+ snapfb
+ threads
+ wmdt:
+ =GAL LOFF
"
}
@@ -414,26 +434,32 @@ and one for power users.
"
set helptext(Tray) "
-The tray/icon mode (started with \"x11vnc -gui tray ...\") presents a
-small icon that indicates the status of a running x11vnc server.
+The tray/icon mode (started with \"x11vnc -gui tray ...\", etc.) presents
+a small icon that indicates the status of the running x11vnc server.
Depending on your environment, this icon may be embedded in a system
-tray or applet dock, or simply be a standalone window.
+tray or applet dock, or simply be a standalone window. \"-gui tray\"
+will attempt to embed the icon in the system tray, while \"-gui icon\"
+is for a standalone window. Use \"-gui tray=setpass\" (or icon=setpass)
+to be prompted to set the session password at startup.
When the icon has a light background, that means no VNC viewers are
-currently connected to the display.
+currently connected to the VNC display.
When the icon has a dark background (i.e. reverse-video), that means at
-least one VNC viewer is connected to the display.
+least one VNC viewer is connected to the VNC display.
Moving the mouse pointer over the icon will popup a \"status balloon\"
-indicating the VNC display name and the names and other info of any
-connected VNC viewers.
+indicating the VNC display name and the names and info of any connected VNC
+viewers. Press the middle mouse button if the balloon does not appear.
-Clicking the right mouse button on the icon displays a menu of actions:
+Clicking the left or right mouse button on the icon displays a menu
+of actions:
- Properties - Brings up the Properties dialog. The full tkx11vnc
- GUI may be accessed via the \"Advanced ...\" button.
+ Properties - Brings up the Properties dialog to set some basic
+ parameters. The full tkx11vnc GUI may be accessed
+ via the \"Advanced ...\" button. Press \"Help ...\"
+ in the Properties dialog for more info.
Help - Displays this help text.
@@ -441,10 +467,17 @@ Clicking the right mouse button on the icon displays a menu of actions:
of a computer that is running a VNC viewer in
\"listen\" mode (e.g. vncviewer -listen). For a
non-standard listening port use \"host:port\".
+
Pressing \"OK\" will initiate the reverse
connection. Use a blank hostname to skip it.
Disconnect All - Disconnects all current VNC viewers.
+
+ Window View - Switch between the \"full\" gui (also known as
+ \"Advanced\"), \"icon\" mode (small icon window with
+ popups), or \"tray\" mode (small icon embedded in the
+ system tray). This is a shortcut for the action:
+ \"Properties -> Advanced -> Misc -> WindowView\".
Stop x11vnc - Directs the x11vnc server to disconnect all vncviewers
and then exit. The tray/icon GUI then exits as well.
@@ -453,7 +486,8 @@ Clicking the right mouse button on the icon displays a menu of actions:
If the x11vnc server stops for any reason, the tray/icon gui will exit.
If you delete the tray/icon (e.g. X out button), that is the same
-as the \"Stop x11vnc\" action in the menu.
+as the \"Stop x11vnc\" action in the menu. (This will disconnect any
+VNC viewer you are currently using to access the display).
"
set helptext(Properties) "
@@ -461,34 +495,34 @@ The Properties dialog allows you to set some basic parameters of a
running x11vnc server. After modifying them press \"OK\" or \"Apply\"
to apply the changes, or press \"Cancel\" to skip applying them.
-\"Accept Connections\" toggles whether VNC viewers are allowed
-to connect or not. It corresponds to the \"-R unlock\" and \"-R lock\"
-remote-control commands.
-
-\"Ask for Confirmation\" toggles whether a popup menu will be presented
-at the X display when a new VNC viewer attempts to connects. The person
-sitting at the X display can chose to accept or reject the connection
-or accept the connection in View-Only mode. It corresponds to the
-\"-R accept:popup\" and \"-R accept:\" remote-control commands.
-
-\"All Clients ViewOnly\" toggles whether the entire VNC desktop is
-view only. All clients will only be able to watch when this is set
-(regardless of how they logged in). It corresponds to the \"-R viewonly\"
-and \"-R noviewonly\" remote-control commands.
-
-\"Shared\" toggles whether multiple simultaneous connections are
-allowed or not. It corresponds to the \"-R shared\" and \"-R noshared\"
-remote-control commands.
-
-\"Password\" lets you set the session password viewers may use to gain full
-access to the display.
-
-\"ViewOnly Password\" lets you set the session password viewers may
-use to gain view only access to the display.
-
-NOTE: These passwords only last for the current x11vnc session (they are
-not remembered, see the -storepasswd, -passwdfile, and -rfbauth x11vnc
-options for using stored passwords).
+ - \"Accept Connections\" toggles whether VNC viewers are allowed
+ to connect or not. It corresponds to the \"-R unlock\" and \"-R lock\"
+ remote-control commands.
+
+ - \"Ask for Confirmation\" toggles whether a popup menu will be presented
+ at the X display when a new VNC viewer attempts to connects. The person
+ sitting at the X display can chose to accept or reject the connection
+ or accept the connection in View-Only mode. It corresponds to the
+ \"-R accept:popup\" and \"-R accept:\" remote-control commands.
+
+ - \"All Clients ViewOnly\" toggles whether the entire VNC desktop is
+ view only. All clients will only be able to watch when this is set
+ (regardless of how they logged in). It corresponds to the
+ \"-R viewonly\" and \"-R noviewonly\" remote-control commands.
+
+ - \"Shared\" toggles whether multiple simultaneous connections are
+ allowed or not. It corresponds to the \"-R shared\" and \"-R noshared\"
+ remote-control commands.
+
+ - \"Password\" lets you set the session password viewers may use to gain full
+ access to the display.
+
+ - \"ViewOnly Password\" lets you set the session password viewers may
+ use to gain view only access to the display.
+
+NOTE: These \"session\" passwords only last for the current x11vnc
+session (they are not remembered, see the -storepasswd, -passwdfile,
+and -rfbauth x11vnc options for using stored passwords).
If you set \"Password\" to the empty string that makes the \"View-Only
Password\" empty as well and removes the need for any password to log in.
@@ -496,17 +530,269 @@ Password\" empty as well and removes the need for any password to log in.
If you set \"ViewOnly Password\" to the empty string that just removes
the ViewOnly log in aspect: \"Password\" is still required to log in.
-The \"Help ...\" button shows this help text.
-
-The \"Advanced ...\" button replaces the Properties dialog with the full
-tkx11vnc GUI. Any dynamic settings can be modified in the full GUI.
+ - The \"Help ...\" button shows this help text.
+
+ - The \"Advanced ...\" button replaces the Properties dialog with the full
+ tkx11vnc GUI. All dynamic settings can be modified in the full GUI.
"
set helptext(all) $helpall
set helptext(Misc-Tuning:) "
-These contain some miscellaneous tuning parameters that are not
-often used. Placed here to avoid overcrowding in the Tuning menu.
+x11vnc has what seems like hundreds of tuning parameters. In this
+sub-menu we place some lesser used ones. Mostly likely you'll want to
+leave them at their default values, but you can try them out quickly
+with the gui to see if they improve things.
+"
+
+ set helptext(Passwords:) "
+The items in this sub-menu pertain to setting passwords. Note that x11vnc
+has two types of password files: RealVNC-style ones (you can create them
+with x11vnc -storepasswd or other VNC utility program) you use these
+via -rfbauth; and plain-text file passwords you use via -passwdfile.
+
+Normally passwords cannot be changed by remote-control (e.g. the gui),
+but for the case of the \"Icon\" and \"Tray\" modes this constraint has
+been relaxed.
+
+In neither the RealVNC-style nor the plain-text file cases should the
+password files be readable by users you do not want to access the VNC
+server. Contrary to popular belief, the RealVNC-style passwords are
+not encrypted, merely obscured.
+
+x11vnc has the even less secure -passwd and -viewpasswd supplied on
+the command line. Be careful with these since they could be read by
+users with something like the ps(1) command. On some operating systems
+x11vnc tries to quickly overwrite them on the command line but it doesn't
+work everywhere.
+
+Regarding ViewOnly passwords (where a VNC client using that password
+can only watch the screen, not interact with it), this is not available
+with -rfbauth, but only with -passwdfile, -passwd, and -viewpasswd.
+"
+
+ set helptext(Misc-Perms:) "
+In this sub-menu we provide some lesser used permission options.
+Regarding -alwaysshared, -nevershared, and -dontdisconnect, you probably
+should never use them and just use x11vnc's -shared and -forever options
+instead (these give basically the same functionality and if you mixed
+them too much unexpected things may happen).
+"
+
+ set helptext(AlphaBlending:) "
+In this sub-menu we provide some tweak parameters for cursors (little
+icon at the mouse pointer) that have transparency (i.e. an Alpha channel
+in addition to Red, Green, and Blue RGB channels). For these cursors,
+some of the graphics underneath the cursor is allowed to be blended in:
+e.g. a drop-shadow (a terrible effect IMNSHO).
+
+AlphaBlending for x11vnc is only available when the XFIXES X extension is
+present (since otherwise it cannot see the cursors at all and so applies
+heuristics to show some fake cursors). AlphaBlending is only a problem
+with x11vnc when the cursors are not opaque.
+
+Opaque cursors (e.g. bitmap or simply colored cursor) are rendered
+correctly by x11vnc. Only when there is transparency does x11vnc have
+to make some approximation to transform the cursor to be opaque (the
+VNC protocol does not provide for an alpha channel in cursors, only RGB).
+
+The items in this sub-menu let you tweak x11vnc's approximation scheme
+for cursors with transparency. Hopefully you won't have to use them.
+Certain cursor \"themes\" may require adjustment however.
+"
+ set helptext(OverlayVisuals:) "
+In this sub-menu are some options that involve fixing color problems
+for \"Overlay\" or \"Multi-Depth\" visuals. This problem is rare
+since overlay and multi-depth visual video hardware is rare.
+Some Sun, SGI, and HP machines are known to have them.
+
+The short answer is if you have a multi-depth visual display (e.g. 8 and
+24 bits), and you see messed up colors in x11vnc try the \"-overlay\"
+option on Solaris or IRIX.
+
+A brief Background on pixels, color, and visuals:
+
+ Pixels (picture elements) are kept in video memory as a certain number
+ of bits-per-pixel (bpp). Most common are 8bpp, 16bpp, and 32bpp.
+ Less common are 24bpp, 4bpp, and 1bpp (monochrome).
+
+ How pixel values (i.e. values of the bits) are rendered into colors on
+ the screen can be done via different \"Recipes\". These different
+ recipes are referred to as \"visuals\". E.g. for 8bpp there is
+ a PseudoColor visual that maintains a mapping (that can be changed
+ dynamically) of the pixel values (256 possible ones) into RGB values.
+ Other 8bpp visuals, e.g. StaticGrey and TrueColor have fixed, regular
+ mappings and so provide less variation in kinds of colors.
+
+ A visual's \"depth\" is how many of the pixels are used in the
+ actual recipe. This may sound wasteful (i.t. not using some of the
+ bits), but for 32bpp (4 billion colors) that is too much and nearly
+ always only 24 for them are used. The most common Visual seems to
+ be depth 24 TrueColor at 32bpp. This provides 16 million colors
+ which is more than the number of pixels on most screens (1280x1024 =
+ 1.3 million pixels). Another sometimes used visual that ignores some
+ bits is depth 15 TrueColor at 16bpp.
+
+OK, now, finally, to the Overlay Visuals. Some hardware (or software
+emulations) allow different depth visuals to be used on the display
+at the same time. The pixels of windows using different depth visuals
+may overlap.
+
+The most common seems to be both 8 and 24 depth visuals on a 32bpp setup.
+24 of the pixels can be used for one visual and the remaining 8 for the
+other. This is sometimes referred to as \"8+24\" mode. Furthermore,
+a speedup is achieved because writing graphics data to, say, the 8bit
+visual does not destroy the image data in the 24bit visual. Evidently
+popup menus can be done very quickly this way: they use the 8bit visual
+and when the popup goes away the graphics data in the 24bit visual is
+immediately reexposed without having the application redrawing it.
+
+Also, some legacy applications can only use 8bpp visuals. But in these
+days of high color graphics and web browsers one would like the rest
+of the desktop to use depth 24 visuals. They often work on the multi
+depth visuals.
+
+How does this effect x11vnc? x11vnc nearly always polls the root window
+(container of all other windows). The root window will be one depth,
+e.g. 8 or 24. Any windows using the *other* depth will appear to have
+messed up colors (or just be black or some other solid color) when viewed
+via x11vnc.
+
+How to fix? Solaris and IRIX provide an API to extract the full snapshot
+of the display with all the colors correct. It comes to x11vnc as depth
+24 TrueColor. To enable this use the \"-overlay\" option. Performance
+may be slower, but if the colors are correct that is a big improvement.
+"
+
+ set helptext(8-Bit-Color:) "
+Some older displays (e.g. with limited Video RAM) use 8 bits-per-pixel
+color. This allows for only 256 different colors on the screen at the
+same time. This sometimes leads to problems with viewing these 8bpp
+displays via x11vnc. This sub-menu has some options that correspond to
+workarounds for this case. If you can configure the machine to use 16bpp
+it may be worth it to avoid the color problems (e.g. color flashing
+as the 8bit colormap is switched).
+"
+ set helptext(SubWindow:) "
+This sub-menu has a couple options regarding having x11vnc poll a
+single window, not the entire display. This way just the window
+is shared.
+
+Note if the application pops up multiple windows they are not tracked
+and shared. So this is not application sharing. The application has to
+be very simple (e.g. a simple terminal or the image window on a webcam)
+for this mode to be useable.
+"
+ set helptext(ResizeRotate:) "
+This sub-menu has some options regarding screens that support the X
+Resize, Reflection, and Rotation Extension (RANDR), and one expects screen
+resizing, reflection, or rotation to take place during the x11vnc session.
+This is pretty rare, but x11vnc seems to handle it reasonably well using
+this X extension.
+
+This mode is on by default in -id mode to try to track the changing
+size of the SubWindow. It is not on by default for full-screen mode
+because of the extra overhead, etc.
+"
+
+ set helptext(WireFrame:) "
+This sub-menu has some options for the x11vnc wireframing speedup scheme.
+
+For x11vnc, Wireframing means to watch for toplevel windows being Opaquely
+Moved or Resized. When x11vnc detects this, it stops polling the screen
+and simply shows a \"wireframe\" outline of the window as it is being
+moved or resized. This avoids \"screen polling thrashing\" when the
+screen is changing so rapidly during this period. For various reasons
+this is usually much faster then letting the window manager do its
+own wireframing (you are encouraged to do Opaque moves and resizes
+when using x11vnc!)
+
+Also, once a moved window is released in its new position, x11vnc uses
+the VNC CopyRect encoding to very efficiently update the VNC viewers
+(each just copies the image data locally).
+
+This sort of scheme was used much in the 1990's on local displays because
+video hardware was slow at the time. x11vnc tries to use this same trick
+as a speedup for its activities (the network is much slower than video
+hardware writes, and the video hardware reads that x11vnc uses to poll
+the screen are still slow today).
+"
+
+ set helptext(ScrollCopyRect:) "
+This sub-menu has some options for the x11vnc Scroll detection and
+CopyRect speedup scheme.
+
+For this mode, x11vnc \"spies\" on communication be the X server and
+applications using the RECORD extension. It looks for various patterns
+to detect a scrolled window. This only works for some applications,
+fortunately some important ones.
+
+Once the scroll is detected it uses the VNC CopyRect encoding for a
+big speedup. Screen polling is also sped up for this scheme.
+
+There are many tweakable parameters for this mode and they are described
+in the sub-menu items.
+"
+
+ set helptext(XDAMAGE:) "
+The DAMAGE X extension allows the X server to send signals to x11vnc
+telling it which regions of the screen have been changed. This improves
+x11vnc's performance markedly. The DAMAGE extension must be available
+on the display for this to work.
+
+Unfortunately DAMAGE cannot be trusted completely for the changed regions,
+because often the reported changed region is much larger than the actual
+changed regions. Nevertheless, x11vnc uses the DAMAGE information very
+effectively as hints to improve its performance.
+
+The items in the sub-menu allow tweaking x11vnc's DAMAGE algorithm.
+"
+
+ set helptext(SharedMemory:) "
+This sub-menu provides some options regarding SYSV shared memory usage
+(shm) by x11vnc. Usually you want shm turned on because the x11vnc
+process is nearly always running on the same machine the X server process
+is running on. SharedMemory gives a performance speedup. However,
+if you need to modify this scenario these options allow you to.
+"
+
+ set helptext(Misc-Debug:) "
+This sub-menu contains a lot of debugging parameters usually used
+for debugging x11vnc itself. This is unlike the -debug_pointer and
+-debug_keyboard options that are useful in learning information, quirks,
+etc. about your local display and environment.
+"
+
+ set helptext(Selection:) "
+This sub-menu contains some options centering around the Selection
+(also referred to as the Clipboard, Cutbuffers, etc). x11vnc will try
+to exchange the selections between the VNC viewers and the X server.
+"
+
+ set helptext(WindowView) "
+Set the Window View Mode for the gui. There are three modes:
+
+ - full: Presents the full gui (Actions, Clients, etc, buttons,
+ and the Text area and Set/Entry box).
+
+ - icon: Presents a small icon instead of the full gui. Moving
+ the mouse over it shows the VNC display name and any
+ connected clients. Clicking on the icon pops up a menu
+ of actions to perform. Among them is \"Properties\" that
+ allows setting more parameters. Clicking on \"Advanced\"
+ in \"Properties\" brings up the full gui.
+
+ - tray: Attempt to embed the small icon in the system tray. If
+ this fails it will resort to icon mode where the small icon
+ is a standalone window.
+
+Note that in \"full\" mode if you delete the full gui window the gui
+terminates (but the x11vnc server keeps running). However under \"icon\"
+or \"tray\" mode if you bring up the full gui window via \"Properties ->
+Advanced\" and then delete it the gui does NOT terminate.
+
+Also note that by default in \"icon\" mode if you delete the icon
+window both the gui and the x11vnc server terminate.
"
set helptext(gui) "
@@ -514,23 +800,30 @@ tkx11vnc is a simple frontend to x11vnc. Nothing fancy, it merely
provides an interface to each of the many x11vnc command line options and
remote control commands. See \"Help -> all\" for much info about x11vnc.
+For a simplier gui, run x11vnc in \"tray\" or \"icon\" mode such as
+\"-gui tray\", \"-gui icon\", or \"-gui tray=setpass\". In that
+mode the full gui is only available under \"Advanced ...\".
+
+Also, \"-gui ez\" will show fewer menu items (toggle via Misc -> simple_gui)
+
All menu items have a (?) button one can click on to get more information
about the option or command.
There are two states tkx11vnc can be in:
1) Available to control a running x11vnc process.
+
2) Getting ready to start a x11vnc process.
+Most people will just use state 1).
+
In state 1) the Menu items available in the menus are those that
correspond to the x11vnc \"remote control\" commands. See the -remote
entry under \"Help -> all\" for a complete list. Also available is
the \"Actions -> stop\" item to shut down the running x11vnc server,
-thereby changing to state 2). One could also simply \"Actions -> detach\"
-leaving the x11vnc server running. \"Actions -> attach\" would
-reestablish the connection.
+thereby changing to state 2). There are other actions available too.
-In state 2) the Menu items available in the menus (Actions, Clients,
+In state 2) the Menu items available in the menus (\"Actions\", \"Clients\",
etc.) are those that correspond to command line options used in starting
an x11vnc process, and the \"Actions -> start\" item executes
x11vnc thereby changing to state 1). To see what x11vnc startup command
@@ -540,11 +833,13 @@ and it will show you what the command looks like.
There is much overlap between the menu items available in state 1)
and state 2), but it is worth keeping in mind it is not 100%.
For example, you cannot set passwords or password files in state 1).
+(update: simple password setting is now allowed in \"tray\" or \"icon\" mode).
Also note that there may be *two* separate X displays involved, not just
one: 1) the X display x11vnc will be polling (and making available to
VNC viewers), and 2) the X display this GUI is intended to display on.
+
For example, one might use ssh to access the remote machine where the
GUI would display on :11 and x11vnc would poll display :0. By default
the gui will display on the value in the DISPLAY env. variable followed
@@ -556,34 +851,36 @@ GUI components:
--- ----------
1) At the top of the gui is a info text label where information will
-be posted, e.g. when traversing menu items text indicating how to get
-help on the item and its current value will be displayed.
+ be posted, e.g. when traversing menu items text indicating how to get
+ help on the item and its current value will be displayed.
-2) Below the info label is the area where the menu buttons, Actions,
-Clients, etc., are presented. If a menu item has a checkbox,
-it corresponds to a boolean on/off variable. Otherwise it is
-either a string variable, or an action not associated with a
-variable (for the most part).
+2) Below the info label is the area where the menu buttons, \"Actions\",
+ \"Clients\", etc., are presented. If a menu item has a checkbox,
+ it corresponds to a boolean on/off variable. Otherwise it is
+ either a string variable, or an action not associated with a
+ variable (for the most part).
-3) Below the menu button area is a text label indicating the current x11vnc
-X display being polled and the corresponding VNC display name. Both
-will be \"(*none*)\" when there is no connection established.
+3) Below the menu button area is a label indicating the current x11vnc
+ X display being polled and the corresponding VNC display name. Both
+ will be \"(*none*)\" when there is no connection established.
-4) Below the x11 and vnc displays text label is a text area there scrolling
-information about actions being taken and commands being run is displayed.
-To scroll click in the area and use PageUp/PageDown or the arrow keys.
+4) Below the x11 and vnc displays label is a text area there scrolling
+ information about actions being taken and commands being run is displayed.
+ To scroll click in the area and use PageUp/PageDown or the arrow keys.
5) At the bottom is an entry area. When one selects a menu item that
-requires supplying a string value, the label will be set to the
-parameter name and one types in the new value. Then one presses the
-\"OK\" button or presses \"Enter\" to set the value. Or you can press
-\"Cancel\" or \"Escape\" to avoid changing the variable. Some variables
-are boolean toggles (for example, \"Permissions -> viewonly\") or Radio
-button selections. Selecting these menu items will not activate the
-entry area but rather toggle the variable directly.
+ requires supplying a string value, the label will be set to the
+ parameter name and one types in the new value. Then one presses the
+ \"OK\" button or presses \"Enter\" to set the value. Or you can press
+ \"Cancel\" or \"Escape\" to avoid changing the variable.
+ Many variables are boolean toggles (for example, \"Permissions ->
+ viewonly\") or Radio button selections. Selecting these menu items
+ will NOT activate the entry area but rather toggle the variable
+ immediately.
-Cascades Bug: There is a bug not yet worked around for the cascade menus
+
+CASCADES BUG: There is a bug not yet worked around for the cascade menus
where the (?) help button gets in the way. To get the mouse over to
the cascade menu click and release mouse to activate the cascade, then
you can click on its items. Dragging with a mouse button held down will
@@ -671,7 +968,7 @@ proc center_win {w} {
wm withdraw $w
set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2];
set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2];
- wm geom $w +$x+$y
+ wm geometry $w +$x+$y
wm deiconify $w
update
}
@@ -696,8 +993,21 @@ proc textheight {text} {
}
proc set_name {name} {
- global full_win
- if [info exists full_win] {
+ global full_win icon_mode
+ global saved_set_name
+
+ if {![info exists saved_set_name]} {
+ set saved_set_name "tkx11vnc"
+ }
+ if {$name == "RESTORE"} {
+ set name $saved_set_name
+ } else {
+ set saved_set_name $name
+ }
+ if {![info exists full_win]} {
+ return
+ }
+ if {$icon_mode} {
set w $full_win
} else {
set w "."
@@ -757,6 +1067,16 @@ proc textwin {name title text} {
proc active_when_connected {item} {
global helpremote helptext
+ global icon_mode
+
+ if {$icon_mode} {
+ if {$item == "passwd"} {
+ return 1
+ }
+ if {$item == "viewpasswd"} {
+ return 1
+ }
+ }
if {[opt_match G $item]} {
return 1
@@ -869,7 +1189,10 @@ proc help_win {item} {
append text "\n\n"
append text "==== current $item value: ====\n";
append text "\n"
- if {$menu_var($item) == ""} {
+
+ if {$item == "passwd" || $item == "viewpasswd"} {
+ ;
+ } elseif {$menu_var($item) == ""} {
append text "$unset_str\n"
} else {
append text "$menu_var($item)\n"
@@ -1107,6 +1430,9 @@ proc menus_state {state} {
foreach case [array names menu_b] {
set menu_button $menu_b($case)
+ if {![winfo exists $menu_button]} {
+ continue
+ }
$menu_button configure -state $state
}
}
@@ -1468,7 +1794,7 @@ proc insert_client_action_window {input} {
global ca_bk ca_bm ca_bb ca_bk ca_di
append_text "\nUse these checkboxes to set the input permissions "
- append_text "for this client\n-or- whether to disconnect it instead. "
+ append_text "for this client\n-OR- whether to disconnect it instead. "
append_text "Then press \"OK\" or \"Cancel\".\n\n"
set w "$text_area.ca_f"
catch {destroy $w}
@@ -1518,7 +1844,7 @@ proc cleanup_text_window {} {
# with entry = 0.
proc entry_dialog {item {entry 1}} {
global menu_var entry_str entry_set entry_dialog_item
- global unset_str connected_to_x11vnc
+ global unset_str connected_to_x11vnc entry_box
set entry_str "Set $item"
set entry_set 0
@@ -1527,6 +1853,10 @@ proc entry_dialog {item {entry 1}} {
entry_enable
menus_disable
+ if {$item == "passwd" || $item == "viewpasswd"} {
+ $entry_box configure -show "*"
+ }
+
if {$entry} {
entry_insert ""
if {[info exists menu_var($item)] &&
@@ -1584,6 +1914,9 @@ proc entry_dialog {item {entry 1}} {
append_text "skipped setting $item\n"
}
}
+
+ $entry_box configure -show ""
+
return $rc
}
@@ -1810,7 +2143,26 @@ proc set_info {str} {
}
proc append_text {str} {
- global text_area
+ global text_area text_area_str
+
+ if {![info exists text_area_str]} {
+ set text_area_str ""
+ }
+ append text_area_str $str
+
+ if {![info exists text_area]} {
+ puts stderr $str
+ return
+ }
+ if {$text_area == ""} {
+ puts stderr $str
+ return
+ }
+ if {![winfo exists $text_area]} {
+ puts stderr $str
+ return
+ }
+
$text_area insert end $str
$text_area see end
}
@@ -1922,6 +2274,7 @@ proc do_action {item} {
if {[in_debug_mode]} {
append_text "action: \"$item\"\n"
}
+#puts "action: \"$item\"\n"
if {$item == "ping"} {
if {$beginner_mode} {
@@ -1960,6 +2313,9 @@ proc do_action {item} {
} elseif {$item == "Misc-Tuning:"} {
menu_help "$item"
return
+ } elseif {$item == "WindowView"} {
+ change_view_state
+ return
} elseif {$item == "stop+quit"} {
do_stop_quit
}
@@ -2002,7 +2358,7 @@ proc do_var {item} {
set debug [in_debug_mode]
set string 0
- if {[is_action $item]} {
+ if {[is_action $item] || $item == "WindowView"} {
# Menu item is action:
if {$debug} {
ptime [time {do_action $item}]
@@ -2012,6 +2368,7 @@ proc do_var {item} {
return
}
+
if {[value_is_string $item]} {
# Menu item is a string:
if {$item_cascade($item) != ""} {
@@ -2158,8 +2515,12 @@ proc set_x11_display {name} {
set_name "tkx11vnc - $name"
}
proc set_vnc_display {name} {
- global vnc_display
+ global vnc_display icon_mode
set vnc_display "VNC display: $name"
+
+ if {$icon_mode} {
+ set_icon_label
+ }
}
proc set_vnc_url {name} {
global vnc_url
@@ -2176,6 +2537,22 @@ proc no_vnc_url {} {
set_vnc_url "(*none*)"
}
+proc get_vnc_display_number {} {
+ global vnc_display
+ if ![info exists vnc_display] {
+ return "none"
+ }
+ if {$vnc_display == ""} {
+ return "none"
+ }
+ set str $vnc_display
+ regsub {VNC display: *} $str "" str
+ if [regexp {:([0-9][0-9]*)} $str m0 n] {
+ return $n
+ }
+ return "none"
+}
+
proc fetch_displays {} {
set qargs [list "-Q" "display,vncdisplay"]
@@ -2350,14 +2727,34 @@ proc update_clients_and_repost {} {
proc update_clients_menu {list} {
global item_cascade ffont
+ global saved_clients_str
+
+ if {![info exists saved_clients_str]} {
+ set saved_clients_str ""
+ }
+ if {$list == "INIT"} {
+ set list $saved_clients_str
+ } else {
+ set saved_clients_str $list
+ }
+
set subm $item_cascade(current);
catch {destroy $subm}
menu $subm -tearoff 0 -font $ffont
$subm add command
- $subm add command -label "refresh-list" -command "update_clients_and_repost"
+ $subm add command -label "refresh-list" \
+ -command "update_clients_and_repost"
$subm add separator
set count 0
foreach client [split $list ","] {
+ if {![regexp {^[a-z0-9]*[a-z0-9]:} $client]} {
+ append_text "Skipping client line: "
+ append_text $client
+ append_text "\n"
+ continue
+ }
+ regsub -all {[{}()~!$&*|;'"`{}<>\[\]]} $client "" client
+ #'
if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \
$client m0 m1 m2 m3 m4 m5 m6 m7]} {
# id:ip:port:user:hostname:input:loginvo
@@ -2375,11 +2772,12 @@ proc update_clients_menu {list} {
}
proc set_widgets {} {
- global connected_to_x11vnc item_case item_entry menu_m
+ global connected_to_x11vnc item_case item_menu item_entry menu_m
foreach item [array names item_case] {
set case $item_case($item)
- set menu $menu_m($case)
+# set menu $menu_m($case)
+ set menu $item_menu($item)
set entry $item_entry($item)
if {$entry < 0} {
# skip case under beginner_mode
@@ -2389,21 +2787,20 @@ proc set_widgets {} {
if {$type == "separator" || $type == "tearoff"} {
continue
}
+ if {![winfo exists $menu]} {
+ continue
+ }
if {$connected_to_x11vnc} {
if {[active_when_connected $item]} {
$menu entryconfigure $entry -state normal
-#puts "n-1 $case / $item / $entry"
} else {
$menu entryconfigure $entry -state disabled
-#puts "I-1 $case / $item / $entry"
}
} else {
if {[active_when_starting $item]} {
$menu entryconfigure $entry -state normal
-#puts "n-2 $case / $item / $entry"
} else {
$menu entryconfigure $entry -state disabled
-#puts "I-2 $case / $item / $entry"
}
}
}
@@ -2411,7 +2808,7 @@ proc set_widgets {} {
proc toggle_simple_gui {} {
global beginner_mode simple_gui_created
- global connected_to_x11vnc
+ global connected_to_x11vnc make_gui_count
if {$beginner_mode} {
append_text "\nSwitching to simple-gui mode.\n"
@@ -2419,26 +2816,81 @@ proc toggle_simple_gui {} {
append_text "\nSwitching to power-user gui mode.\n"
}
+ if {$make_gui_count == 1} {
+ incr make_gui_count
+ }
set simple_gui_created 1
make_menu_items
set_widgets
set_internal_help
- if {$connected_to_x11vnc} {
- query_all
- }
+# if {$connected_to_x11vnc} {
+# query_all
+# }
append_text "\n"
}
+proc little_qs {m} {
+ global bfont ffont beginner_mode
+ global helpremote helptext helplabel
+ global tk_version
+
+ if {$tk_version < 8.0} {
+ return
+ }
+
+ set n [$m index end]
+
+ for {set i 0} {$i <= $n} {incr i} {
+ set type [$m type $i]
+#puts "$m - $i - $type"
+ if {$type == "separator"} {
+ $m add separator
+ } elseif {$type == "tearoff"} {
+ continue;
+ } else {
+ set label [$m entrycget $i -label]
+ set str ""
+ if {[info exists helpremote($label)]} {
+ set str "(?)"
+ } elseif {[info exists helptext($label)]} {
+ set str "(?)"
+ }
+ $m add command -label $str \
+ -font $ffont \
+ -command "menu_help $label";
+
+ if {$str == ""} {
+ $m entryconfigure end -state disabled
+ }
+ set arg "$m,$i"
+#puts "helplabel: $arg -> $label"
+ set helplabel($arg) $label
+ set j [$m index end]
+ set arg "$m,$j"
+ set helplabel($arg) $label
+ }
+ if {$i == 0} {
+ $m entryconfigure end -columnbreak 1
+ }
+ }
+
+ menu_bindings $m
+}
+
proc make_menu_items {} {
global template
global menu_b menu_m menu_count
- global item_opts item_bool item_case item_entry menu_var unset_str
+ global item_opts item_bool item_case item_menu item_entry menu_var unset_str
global item_cascade
global bfont ffont beginner_mode simple_gui_created
global helptext helpremote helplabel
- # Extract the menu items:
set case "";
+ set L_casc ""
+ set L_casc_count 0
+ set L_menus [list]
+
+ # Extract the menu items:
foreach line [split $template "\n"] {
if {[regexp {^Row:} $line]} {
continue
@@ -2448,10 +2900,9 @@ proc make_menu_items {} {
if {$simple_gui_created} {
set i0 0
- if {$case == "Misc"} {
- # kludge for simple_gui
- set i0 1
- }
+ #if {$case == "Misc"} { # kludge for simple_gui
+ # set i0 1
+ #}
catch {$menu_m($case) delete $i0 end}
}
set menu_count($case) 0
@@ -2479,6 +2930,11 @@ proc make_menu_items {} {
}
regsub {:$} $item {} item
+ if {$item == "LOFF"} {
+ set L_casc ""
+ continue
+ }
+
if {$item == "-- D"} {
set beginner_sep 1
set item "--"
@@ -2490,17 +2946,27 @@ proc make_menu_items {} {
set item_case($item) $case
set item_bool($item) $bool
set item_cascade($item) ""
- set item_entry($item) $menu_count($case)
+
+ if {$L_casc == ""} {
+ set item_entry($item) $menu_count($case)
+ set m $menu_m($case)
+ } else {
+ # hack for cascades for crowded menus. See =GAL opts.
+ set item_entry($item) $L_casc_count
+ set m $L_casc
+ }
set mvar 0
- set m $menu_m($case)
if {$beginner_mode && ! $beginner_sep && ![opt_match D $item]} {
set item_entry($item) "-1"
continue;
}
- if {0} { puts "ITEM: $item\t- $opts\t- $case\t- $bool\t- $menu_count($case)" }
+ set item_menu($item) $m
+
+ if {0} { puts "ITEM: $item\t- $opts\t- $case\t- \
+ $bool\t- $menu_count($case)" }
# Create the menu items, its variables, etc., etc.
@@ -2519,12 +2985,25 @@ proc make_menu_items {} {
-font $ffont \
-command "menu_help $item"
+ } elseif {[opt_match L $item]} {
+ # Special sub-menu cascade (=GAL ends with LOFF)
+ set subm $m.casc_L$menu_count($case)
+ catch {destroy $subm}
+ menu $subm -tearoff 0 -font $ffont
+ set item_cascade($item) $subm
+ $m add cascade -label "$item" \
+ -font $ffont \
+ -menu $subm
+ set L_casc $subm
+ set L_casc_count -1
+ lappend L_menus $L_casc
+
} elseif {$item == "current"} {
# Current clients cascade
set subm $m.current_cascade
catch {destroy $subm}
set item_cascade($item) $subm
- update_clients_menu ""
+ update_clients_menu "INIT"
$m add cascade -label "$item" \
-font $ffont \
-menu $subm
@@ -2534,7 +3013,9 @@ proc make_menu_items {} {
$m add command -label "$item" \
-font $ffont \
-command "do_var $item"
- set menu_var($item) ""; # for convenience
+ if {![info exists menu_var($item)]} {
+ set menu_var($item) ""; # for convenience
+ }
} elseif {! $item_bool($item)} {
# String
@@ -2563,25 +3044,34 @@ proc make_menu_items {} {
set mvar 1
} elseif {$item == "simple-gui"} {
- if {! $simple_gui_created} {
- $m add checkbutton -label "$item" \
- -command "toggle_simple_gui" \
- -font $ffont \
- -variable beginner_mode
- }
+ $m add checkbutton -label "$item" \
+ -command "toggle_simple_gui" \
+ -font $ffont \
+ -variable beginner_mode
} else {
# Boolean
$m add checkbutton -label "$item" \
-command "do_var $item" \
-font $ffont \
-variable menu_var($item)
- set menu_var($item) 0
+ if {![info exists menu_var($item)]} {
+ set menu_var($item) 0
+ }
}
- incr menu_count($case)
+ if {$L_casc_count == -1} {
+ incr menu_count($case)
+ incr L_casc_count
+ } elseif {$L_casc != ""} {
+ incr L_casc_count
+ } else {
+ incr menu_count($case)
+ }
if {$mvar} {
- set menu_var($item) $unset_str
+ if {![info exists menu_var($item)]} {
+ set menu_var($item) $unset_str
+ }
}
}
@@ -2590,52 +3080,28 @@ proc make_menu_items {} {
if {$case == "Help"} {
continue;
}
- set m $menu_m($case);
- set n [$m index end]
-
- for {set i 0} {$i <= $n} {incr i} {
- set type [$m type $i]
- if {$type == "separator"} {
- $m add separator
- } elseif {$type == "tearoff"} {
- continue;
- } else {
- set label [$m entrycget $i -label]
- set str ""
- if {[info exists helpremote($label)]} {
- set str "(?)"
- } elseif {[info exists helptext($label)]} {
- set str "(?)"
- }
- $m add command -label $str \
- -font $ffont \
- -command "menu_help $label";
-
- if {$str == ""} {
- $m entryconfigure end -state disabled
- }
- set arg "$m,$i"
- set helplabel($arg) $label
- set j [$m index end]
- set arg "$m,$j"
- set helplabel($arg) $label
- }
- if {$i == 0} {
- $m entryconfigure end -columnbreak 1
- }
- }
+ little_qs $menu_m($case);
+ }
+ foreach m $L_menus {
+ little_qs $m
}
}
proc menu_posted {} {
- global last_query_all_time query_all_freq
- global connected_to_x11vnc
+ global last_query_all_time query_all_freq icon_mode
+ global connected_to_x11vnc client_tail
+
set now [clock seconds]
+ if {$icon_mode && $client_tail != ""} {
+ set delay [expr 2 * $query_all_freq]
+ } else {
+ set delay $query_all_freq
+ }
if {$connected_to_x11vnc} {
set quiet 0
- set refresh [expr "$last_query_all_time + $query_all_freq"]
+ set refresh [expr "$last_query_all_time + $delay"]
# puts "menu_posted $now $last_query_all_time"
# puts "menu_posted $refresh"
@@ -2650,6 +3116,14 @@ proc menu_posted {} {
}
}
+proc props_widgets {state} {
+ global props_buttons
+ foreach w $props_buttons {
+ $w configure -state $state
+ }
+ update
+}
+
proc props_apply {} {
global props_accept props_confirm props_viewonly props_shared
global props_passwd props_viewpasswd
@@ -2657,6 +3131,8 @@ proc props_apply {} {
global prop0_passwd prop0_viewpasswd
global menu_var
+ props_widgets disabled
+
if {$props_accept != $prop0_accept} {
if {$props_accept} {
push_new_value "unlock" "unlock" 1 0
@@ -2726,13 +3202,13 @@ proc props_apply {} {
set prop0_viewpasswd $props_viewpasswd
after 500
}
+ props_widgets normal
}
proc props_advanced {} {
- global tray_mode icon_win props_win full_win
+ global icon_mode icon_win props_win full_win
global props_advanced_first
-
if ![info exists props_advanced_first] {
center_win $full_win
set props_advanced_first 1
@@ -2749,13 +3225,14 @@ proc props_advanced {} {
}
}
-proc do_props {} {
+proc do_props {{msg ""}} {
global props_accept props_confirm props_viewonly props_shared
global props_passwd props_viewpasswd
global prop0_accept prop0_confirm prop0_viewonly prop0_shared
global prop0_passwd prop0_viewpasswd
global menu_var unset_str
global have_labelframes ffont bfont
+ global props_buttons icon_noadvanced
if ![info exists props_accept] {
set props_accept 1
@@ -2812,10 +3289,15 @@ proc do_props {} {
}
set prop0_viewpasswd $props_viewpasswd
+ if [info exists props_buttons] {
+ catch {unset props_buttons}
+ }
+ set props_buttons [list]
+
set w .props
catch {destroy $w}
toplevel $w
- wm title $w "Properties"
+ wm title $w "x11vnc Properties"
set b1 "$w.buttons1"
frame $b1
button $b1.ok -text OK -command "props_apply; destroy $w" -font $bfont
@@ -2823,14 +3305,21 @@ proc do_props {} {
button $b1.apply -text Apply -command "props_apply" -font $bfont
pack $b1.apply $b1.cancel $b1.ok -side right -expand 1
+ lappend props_buttons $b1.apply $b1.cancel $b1.ok
set b2 "$w.buttons2"
frame $b2
button $b2.advanced -text "Advanced ..." \
-command "destroy $w; props_advanced" -font $bfont
+ if {! $icon_noadvanced} {
+ lappend props_buttons $b2.advanced
+ pack $b2.advanced -side right -expand 1
+ }
+
button $b2.help -text "Help ..." -command "menu_help Properties" -font $bfont
- pack $b2.advanced $b2.help -side right -expand 1
+ lappend props_buttons $b2.help
+ pack $b2.help -side right -expand 1
set vp "$w.viewpw"
if {$have_labelframes} {
@@ -2844,6 +3333,8 @@ proc do_props {} {
entry $vp.e -show "*" -textvariable props_viewpasswd -font $bfont
pack $vp.e -fill x -expand 1 -padx 1m -pady 1m -side top
+ lappend props_buttons $vp.e
+
set pw "$w.passwd"
if {$have_labelframes} {
labelframe $pw -text "Password" -font $bfont
@@ -2856,6 +3347,8 @@ proc do_props {} {
entry $pw.e -show "*" -textvariable props_passwd -font $bfont
pack $pw.e -fill x -expand 1 -padx 1m -pady 1m -side top
+ lappend props_buttons $pw.e
+
set sh "$w.shared"
frame $sh
checkbutton $sh.button -text "Shared" \
@@ -2880,14 +3373,27 @@ proc do_props {} {
-variable props_accept -anchor w -font $bfont
pack $ac.button -fill x -expand 1 -padx 1m -pady 1m
- pack $b1 -side bottom -fill x -pady 1m -padx 2m
- pack $b2 -side bottom -fill x -pady 1m -padx 2m
- pack $vp -side bottom -fill x -pady 1m -padx 2m
- pack $pw -side bottom -fill x -pady 1m -padx 2m
- pack $sh -side bottom -fill x -pady 0m -padx 2m
- pack $vo -side bottom -fill x -pady 0m -padx 2m
- pack $cf -side bottom -fill x -pady 0m -padx 2m
- pack $ac -side bottom -fill x -pady 0m -padx 2m
+ set px "6m"
+ pack $b1 -side bottom -fill x -pady 1m -padx $px
+ pack $b2 -side bottom -fill x -pady 1m -padx $px
+ pack $vp -side bottom -fill x -pady 1m -padx $px
+ pack $pw -side bottom -fill x -pady 1m -padx $px
+ pack $sh -side bottom -fill x -pady 0m -padx $px
+ pack $vo -side bottom -fill x -pady 0m -padx $px
+ pack $cf -side bottom -fill x -pady 0m -padx $px
+ pack $ac -side bottom -fill x -pady 0m -padx $px
+
+ if {$msg != ""} {
+ set tw [textwidth $msg]
+ set th [textheight $msg]
+ set th [expr $th - 1]
+ set ms "$w.msg"
+ text $ms -font $ffont -relief ridge -width $tw -height $th
+ $ms insert 1.0 $msg
+ pack $ms -side bottom -fill x -pady 1m -padx $px
+ }
+
+ lappend props_buttons $ac.button $cf.button $vo.button $sh.button
wm resizable $w 1 0
center_win $w
@@ -2916,6 +3422,8 @@ proc do_new_client {} {
tkwait window $w
+ regsub -all {[{}()~!$&*|;'"`{}<>\[\]]} $newclient "" newclient
+ #'
if {$newclient != ""} {
push_new_value "connect" "connect" "$newclient" 1
}
@@ -2926,6 +3434,9 @@ proc do_disconnect_all {} {
}
proc pmenu {m x y} {
+ if {![winfo exists $m]} {
+ return
+ }
set x [expr $x-10]
set y [expr $y-10]
$m post $x $y
@@ -2975,31 +3486,22 @@ proc set_client_balloon {str} {
proc read_client_info {} {
global x11vnc_client_file client_tail client_str
- global unlinked_x11vnc_client_file
+ global client_tail_read
+ set db 0
+
if {$client_tail != ""} {
after 100
set str ""
set count [gets $client_tail str]
+ if {$db} {puts stderr "read_client_info: $str"}
- # we can unlink the file early since both processes
- # have it open.
- if ![info exists unlinked_x11vnc_client_file] {
- set unlinked_x11vnc_client_file 0
- } elseif {$unlinked_x11vnc_client_file == ""} {
- set unlinked_x11vnc_client_file 0
- }
- if {! $unlinked_x11vnc_client_file} {
- after 500
- catch {file delete $x11vnc_client_file}
- set unlinked_x11vnc_client_file 1
- }
-
- if {$count == -1} {
+ if {$count == -1 || [eof $client_tail]} {
close $client_tail
catch {file delete $x11vnc_client_file}
clean_icon_exit
}
if {$count > 0 && ![regexp {^[ ]*$} $str]} {
+ set client_tail_read 1
if {$str == "quit"} {
catch {file delete $x11vnc_client_file}
clean_icon_exit
@@ -3016,14 +3518,16 @@ proc read_client_info {} {
}
proc show_client_balloon {} {
- global tray_mode icon_win props_win full_win
+ global icon_mode icon_win props_win full_win
global client_balloon ffont
+ set noinfo "tkx11vnc: no client information"
+ set noinfo "$noinfo\navailable from x11vnc ..."
if ![info exists client_balloon] {
- set client_balloon "tkx11vnc ..."
+ set client_balloon $noinfo
}
if {$client_balloon == ""} {
- set client_balloon "tkx11vnc ..."
+ set client_balloon $noinfo
}
set x [expr [winfo rootx $icon_win] + ([winfo width $icon_win]/2)]
@@ -3066,67 +3570,288 @@ proc kill_client_balloon {} {
}
proc icon_win_cfg {clients} {
- global icon_win
+ global icon_win client_tail client_tail_read
if {$clients > 0} {
$icon_win configure -bg black -fg white
} else {
$icon_win configure -bg white -fg black
}
+ if {$client_tail == "" || !$client_tail_read} {
+ $icon_win configure -fg red
+ }
+}
+
+proc server_accept {sock addr port} {
+ global socket_cookie server socket_got_callback
+ global client_tail
+ set db 0
+
+ if {$db} {puts stderr "sock=$sock addr=$addr port=$port"}
+
+ update; update idletasks
+ after 50
+ update; update idletasks
+ set count [gets $sock str]
+
+ if {$count >= 0} {
+ set str [string trim $str]
+ if {$db} {puts stderr "server_accept: \"$str\""}
+ if {$str == "COOKIE:$socket_cookie"} {
+ set client_tail $sock
+ if {$db} {puts stderr "cookie matched. $client_tail"}
+ } else {
+ if {$db} {puts stderr "cookie NO matched."}
+ }
+ }
+ catch {close $server}
+ set socket_got_callback 1
+ if {$db} {puts stderr "socket_got_callback $socket_got_callback"}
+}
+
+proc try_client_info_sock {} {
+ global socket_cookie server socket_got_callback
+ global x11vnc_started hostname
+ set start 13037
+ set tries 100
+ set socket_got_callback 0
+
+ if {$x11vnc_started} {
+ set myaddr "127.0.0.1"
+ } else {
+ set myaddr $hostname
+ }
+ set socket_cookie [clock clicks]
+
+ for {set i 0} {$i <= $tries} {incr i} {
+ set port [expr $start + $i]
+ set server [socket -server server_accept -myaddr $myaddr $port]
+ if {$server == ""} {
+ continue
+ }
+ if {[eof $server]} {
+ continue
+ }
+ set err ""
+ catch {set err [fconfigure $server -error]}
+ #puts "err: $server: $err"
+ if {$err == ""} {
+ break
+ }
+ }
+ if {$server == ""} {
+ append_text "try_client_info_sock: server socket failed.\n"
+ return
+ }
+ run_remote_cmd [list "-nosync" "-R" "noop"]
+ after 500
+ run_remote_cmd [list "-nosync" "-R" \
+ "client_info_sock:$myaddr:$port:$socket_cookie"]
+ after 500
+
+ set aftid ""
+ if {$socket_got_callback == 0} {
+ set aftid [after 10000 {set socket_got_callback 2}]
+ tkwait variable socket_got_callback
+ }
+
+ if {$aftid != ""} {
+ catch {after cancel $aftid}
+ }
+
+ if {$socket_got_callback != 1} {
+ puts stderr "try_client_info_sock failed: no callback\n"
+ catch {close $server}
+ } else {
+ setup_client_tail
+ }
+}
+
+proc set_icon_label {} {
+ global icon_win
+
+ set lab [get_icon_label]
+
+ if {[info exists icon_win]} {
+ $icon_win configure -text $lab
+ }
+}
+
+proc get_icon_label {{set 0}} {
+ global icon_minimal
+
+ set lab0 "x11\nvnc"
+
+ if {$icon_minimal} {
+ set lab [get_vnc_display_number]
+ if {$lab != "none"} {
+ set lab " :$lab"
+ }
+ } else {
+ set lab $lab0
+ }
+ return $lab
+}
+
+proc lmenu {menu} {
+ global window_view_posted
+ after 100
+ if {!$window_view_posted} {
+ after 100
+ if {!$window_view_posted} {
+ $menu unpost
+ return
+ }
+ }
+ # kludge for WindowView
+ focus $menu
+}
+
+proc old_balloon {} {
+ global client_str saved_client_str
+ set str ""
+ if {[info exists client_str]} {
+ if {$client_str != ""} {
+ set str $client_str
+ }
+ }
+ if {$str == ""} {
+ if {[info exists saved_client_str]} {
+ set str $saved_client_str
+ }
+ }
+ if {$str != ""} {
+ set_client_balloon $str
+ }
}
proc make_icon {} {
- global tray_mode tray_embed_id icon_win props_win full_win
- global x11vnc_client_file client_tail client_str
+ global icon_mode icon_embed_id icon_win props_win full_win
+ global tray_embed tray_running env
+ global x11vnc_client_file client_tail client_str saved_clients_str
global client_balloon_id
- global bfont ffont
+ global bfont sfont ffont
+ global icon_minimal gui_start_mode
+ global window_view_posted menu_var x11vnc_gui_geom
+ set min_x 24
+ set min_y 24
-# if {$tray_embed_id != ""} {
-# wm withdraw .
-# set top ".icon"
-# toplevel $top -use $tray_embed_id
-# }
+ set font $bfont
+ if {$tray_embed} {
+ set font $sfont
+ }
+ if {[info exists env(X11VNC_ICON_FONT)]} {
+ set font $env(X11VNC_ICON_FONT)
+ }
+ if {[regexp {([0-9][0-9]*)x([0-9][0-9]*)} $x11vnc_gui_geom m mx my]} {
+ if {$mx < $min_x} {
+ set min_x $mx
+ }
+ if {$my < $min_y} {
+ set min_y $my
+ }
+ }
+ wm minsize . $min_x $min_y
- set l .label
+ if {$tray_embed && $tray_running} {
+ wm withdraw .
+ }
+
+ set l .icon
set icon_win $l
- label $l -text "x11\nvnc" -borderwidth 5 -font $bfont
+ catch destroy {$icon_win}
+ if {$icon_minimal} {
+ set bw 1
+ } else {
+ set bw 5
+ }
+ set lab [get_icon_label]
+ label $l -text $lab -borderwidth $bw -font $font
icon_win_cfg 0
- pack $l
+ set window_view_posted 0
+ pack $l -fill both -expand 1
set menu "$l.menu"
- menu $menu -tearoff 0
- $menu add command -font $bfont -label "Properties" -command do_props
- $menu add command -font $bfont -label "Help" -command "menu_help Tray"
+ menu $menu -tearoff 0 -postcommand {set window_view_posted 0}
+ $menu add command -font $font -label "Properties" -command do_props
+ $menu add command -font $font -label "Help" -command "menu_help Tray"
$menu add separator
- $menu add command -font $bfont -label "New Client" -command do_new_client
- $menu add command -font $bfont -label "Disconnect All" -command do_disconnect_all
+ $menu add command -font $font -label "New Client" -command do_new_client
+ $menu add command -font $font -label "Disconnect All" -command do_disconnect_all
$menu add separator
- $menu add command -font $bfont -label "Stop x11vnc" -command clean_icon_exit
- bind . <Button-1> "pmenu $menu %X %Y"
- bind . <Button-3> "pmenu $menu %X %Y"
- bind $menu <Leave> "after 200; $menu unpost"
-
- if {$x11vnc_client_file != "" } {
- if ![file exists $x11vnc_client_file] {
- set fh [open $x11vnc_client_file "w"]
- puts $fh "skip"
- close $fh
- }
- if [file exists $x11vnc_client_file] {
- set client_tail [open "|tail -f $x11vnc_client_file" "r"]
- }
+ set wv "$menu.casc1"
+ catch {destroy $wv}
+ menu $wv -tearoff 0 -font $ffont \
+ -postcommand {set window_view_posted 1}
+ foreach val {full icon tray} {
+ $wv add radiobutton -label "$val" \
+ -value "$val" -font $ffont \
+ -command "do_var WindowView" \
+ -variable menu_var(WindowView)
}
+ $menu add cascade -font $font -label "Window View" -menu $wv
+ $menu add command -font $font -label "Stop x11vnc" -command clean_icon_exit
+
+ bind $icon_win <ButtonPress-1> "pmenu $menu %X %Y"
+ bind $icon_win <ButtonPress-3> "pmenu $menu %X %Y"
bind $icon_win <Enter> {set client_balloon_id [after 500 show_client_balloon]}
bind $icon_win <Button> {kill_client_balloon}
bind $icon_win <Leave> {kill_client_balloon}
+ bind $icon_win <ButtonPress-2> {kill_client_balloon; show_client_balloon}
+ bind $menu <Leave> "lmenu $menu"
+ bind $menu <KeyPress-Escape> "$menu unpost"
+
+ if {!$tray_embed || !$tray_running} {
+ global x11vnc_gui_geom
+ if {$x11vnc_gui_geom != ""} {
+ set doit 1
+ if {[regexp {x} $x11vnc_gui_geom]} {
+ if {$gui_start_mode == "full"} {
+ set doit 0
+ }
+ }
+ if {$doit} {
+ wm geometry . $x11vnc_gui_geom
+ }
+ }
+ }
+ wm deiconify .
+
+ if {$client_tail == "" } {
+ stop_watch on
+ try_client_info_sock
+ if {$client_tail == "" } {
+ after 500
+ try_client_info_sock
+ }
+ stop_watch off
+ }
+ if {$client_tail == "" } {
+ set m "\n"
+ set m "${m}tkx11vnc:\n"
+ set m "${m}\n"
+ set m "${m} Warning -- running in icon/tray mode but the\n"
+ set m "${m} connected client info channel from x11vnc is\n"
+ set m "${m} not working. The viewer client list and icon\n"
+ set m "${m} color indicator will not be accurate.\n"
+ set m "${m}\n"
+ set m "${m} You may need to restart \"x11vnc -gui tray ...\"\n"
+ set m "${m} for this to work properly.\n"
+ set m "${m}\n"
+ textwin "Warning" "Warning" $m
+ update
+ }
+
+ old_balloon
}
-proc clean_icon_exit {} {
- global client_tail
+proc clean_client_tail {} {
+ global client_tail client_tail_read
if [info exists client_tail] {
if {$client_tail != ""} {
- set p [pid $client_tail]
+ set p ""
+ catch {set p [pid $client_tail]}
if {$p != ""} {
catch {exec kill -TERM $p >/dev/null 2>/dev/null}
}
@@ -3134,6 +3859,11 @@ proc clean_icon_exit {} {
set client_tail ""
}
}
+ set client_tail_read 0
+}
+
+proc clean_icon_exit {} {
+ clean_client_tail
push_new_value "stop" "stop" 1 0
set_connected no
update
@@ -3141,31 +3871,122 @@ proc clean_icon_exit {} {
exit
}
-proc make_widgets {} {
- global template
+proc make_gui {mode} {
+ global icon_mode tray_embed full_win icon_win
+ global top_widget_names x11vnc_gui_geom
+ global gui_current_state make_gui_count
+ global x11vnc_connect connected_to_x11vnc
+ global x11_display
+ global gui_start_mode
+
+ incr make_gui_count
+
+ if {$gui_start_mode == ""} {
+ set gui_start_mode $mode
+ }
+
+ wm withdraw .
+
+ set full_geom ""
+ if {[winfo exists .full]} {
+ catch {set full_geom [wm geometry .full]}
+ }
+
+ set fw .full
+ set full_win $fw
+ catch {pack forget $full_win}
+ catch {pack forget $icon_win}
+ catch {destroy $full_win}
+ catch {destroy $icon_win}
+
+ wm minsize . 1 1
+
+ if {$mode == "full"} {
+ frame $fw
+ set icon_mode 0
+
+ wm protocol . WM_DELETE_WINDOW "destroy .; exit"
+ make_widgets $fw
+
+ set w "."
+ wm geometry $w ""
+ if {$x11vnc_gui_geom != ""} {
+ set doit 1
+ if {[regexp {x} $x11vnc_gui_geom]} {
+ if {$gui_start_mode != $mode} {
+ set doit 0
+ }
+ }
+ if {$doit} {
+ wm geometry $w $x11vnc_gui_geom
+ }
+ }
+ pack $fw -fill both -expand 1
+
+ } elseif {$mode == "icon" || $mode == "tray"} {
+
+ toplevel $fw
+ wm withdraw $fw
+
+ wm protocol $fw WM_DELETE_WINDOW "wm withdraw .full"
+ wm protocol . WM_DELETE_WINDOW "clean_icon_exit"
+
+ if {$mode == "icon"} {
+ set tray_embed 0
+ } elseif {$mode == "tray"} {
+ set tray_embed 1
+ }
+ set icon_mode 1
+ make_widgets $fw
+ set w $fw
+ make_icon
+ wm geometry $fw ""
+ wm geometry . ""
+ } else {
+ return
+ }
+ set_view_variable $mode
+ set gui_current_state $mode
+
+
+ wm deiconify .
+ update idletasks
+ wm minsize $w [winfo width $w] [winfo height $w]
+ if {$mode == "full" && $make_gui_count > 1} {
+ center_win .
+ }
+
+ if {$make_gui_count == 1} {
+ if {$x11vnc_connect} {
+ try_connect_and_query_all
+ }
+ } else {
+ set_name "RESTORE"
+ }
+ set_widgets
+
+ if {$mode == "icon" || $mode == "tray"} {
+ setup_client_tail
+ if {$mode == "tray"} {
+ setup_tray_embed
+ }
+ }
+}
+
+proc make_widgets {top} {
+ global template make_gui_count
global menu_b menu_m menu_count
- global item_opts item_bool item_case item_entry menu_var unset_str
+ global item_opts item_bool item_case item_menu item_entry menu_var unset_str
global item_cascade
global info_label info_str x11_display vnc_display
- global text_area
+ global text_area text_area_str
global entry_box entry_str entry_set entry_label entry_ok entry_browse
global entry_help entry_skip
global bfont ffont beginner_mode
global helptext helpremote helplabel
- global tray_mode icon_win props_win full_win
-
- if {$tray_mode} {
- set top ".advanced"
- toplevel $top
- wm withdraw $top
- set full_win $top
- wm protocol $top WM_DELETE_WINDOW "wm withdraw $top"
- wm protocol . WM_DELETE_WINDOW "clean_icon_exit"
- make_icon
- } else {
- set top ""
- set full_win "."
- }
+ global icon_mode icon_win props_win full_win
+ global top_widget_names
+
# Make the top label
set label_width 80
@@ -3174,6 +3995,8 @@ proc make_widgets {} {
-anchor w -width $label_width -font $ffont
pack $info_label -side top -fill x -expand 0
+ set top_widget_names(info) $info_label
+
# Extract the Rows:
set row 0;
set colmax 0;
@@ -3235,22 +4058,29 @@ proc make_widgets {} {
}
}
pack $f -side top -fill x
+ set top_widget_names(menuframe) $f
make_menu_items
# Make the x11 and vnc display label bar:
set df "$top.displayframe"
frame $df -bd 1 -relief groove
+ set top_widget_names(displayframe) $df
set df_x11 "$df.xdisplay"
- no_x11_display
+ if {$make_gui_count == 1} {
+ no_x11_display
+ }
set lw [expr {$label_width / 2}]
label $df_x11 -textvariable x11_display -width $lw -anchor w \
-font $ffont
set df_vnc "$df.vdisplay"
- no_vnc_display
+
+ if {$make_gui_count == 1} {
+ no_vnc_display
+ }
label $df_vnc -textvariable vnc_display -width $lw -anchor w \
-font $ffont
@@ -3261,14 +4091,20 @@ proc make_widgets {} {
set text_area "$top.text"
text $text_area -height 12 -relief ridge -font $ffont
pack $text_area -side top -fill both -expand 1
+ set top_widget_names(text) $text_area
- set str "Click Help -> gui for overview."
- append_text "\n$str\n\n"
+ if {$text_area_str == ""} {
+ set str "Click Help -> gui for overview."
+ append_text "\n$str\n\n"
+ } else {
+ append_text $text_area_str
+ }
# Make entry box stuff
set ef "$top.entryframe"
frame $ef -bd 1 -relief groove
+ set top_widget_names(entryframe) $ef
# Entry Label
set ef_label "$ef.label"
@@ -3322,24 +4158,24 @@ proc make_widgets {} {
set entry_label $ef_label
entry_disable
- if {$top == ""} {
- set w "."
- } else {
- set w $top
- }
- update idletasks
- wm minsize $w [winfo width $w] [winfo height $w]
}
-proc menu_bindings {} {
- bind Menu <<MenuSelect>> {
+proc menu_bindings {m} {
+ set db 0
+ if {$db} {puts "menu_bindings $m"}
+
+ bind $m <<MenuSelect>> {
#syntax hilite bug \
MenuSelect>>
set n [%W index active]
+ set db 0
+ if {$db} {puts stderr "menu_bindings %W $n"}
set label " "
if {$n != "none"} {
set str %W,$n
set which ""
+
+ if {$db} {puts "menu_bindings $str"}
if {[info exists helplabel($str)]} {
set vname [format %%-16s $helplabel($str)]
set label "Click (?) for help on: $vname"
@@ -3347,6 +4183,8 @@ MenuSelect>>
}
if {$which == ""} {
;
+ } elseif {$which == "passwd" || $which == "viewpasswd"} {
+ ;
} elseif {[is_action $which]} {
if {[info exists menu_var($which)]
&& $menu_var($which) != ""} {
@@ -3397,14 +4235,30 @@ proc key_bindings {} {
proc stop_watch {onoff} {
global orig_cursor text_area entry_box
- set widgets [list . $text_area $entry_box]
+ set widgets [list .]
+ if [info exists text_area] {
+ if {$text_area != ""} {
+ lappend widgets $text_area
+ }
+ }
+ if [info exists entry_box] {
+ if {$entry_box != ""} {
+ lappend widgets $entry_box
+ }
+ }
if {$onoff == "on"} {
foreach item $widgets {
+ if {![winfo exists $item]} {
+ continue
+ }
$item config -cursor {watch}
}
} else {
foreach item $widgets {
+ if {![winfo exists $item]} {
+ continue
+ }
$item config -cursor {}
}
}
@@ -3615,6 +4469,7 @@ proc run_remote_cmd {opts} {
}
lappend cmd "2>"
lappend cmd "/dev/null"
+# lappend cmd "/tmp/nono"
if {0} {
set str [join $cmd]
@@ -3626,9 +4481,12 @@ proc run_remote_cmd {opts} {
set output ""
menus_disable
+
stop_watch on
catch {set output [eval exec $cmd]}
stop_watch off
+#puts stderr [exec cat /tmp/nono]
+
menus_enable
if {$debug} {
if {[string length $output] > 100} {
@@ -3693,13 +4551,150 @@ proc try_connect {} {
}
}
+proc set_view_variable {val} {
+ global menu_var
+ set menu_var(WindowView) $val
+}
+proc get_view_variable {} {
+ global menu_var
+ if {![info exists menu_var(WindowView)]} {
+ set menu_var(WindowView) "none"
+ }
+ return $menu_var(WindowView)
+}
+
+proc change_view_state {} {
+ global menu_var gui_current_state
+
+ set new [get_view_variable]
+
+ set old $gui_current_state
+ #puts "$old -> $new"
+
+ if {$old == $new} {
+ return
+ }
+
+ if {$old == "full" || $old == "icon" || $old == "tray"} {
+ ;
+ } else {
+ set old "none"
+ }
+
+ if {$new == "full" || $new == "icon" || $new == "tray"} {
+ if {$old == "tray"} {
+ # sigh XReparentWindow would be too easy...
+ # undo_tray_embed
+ restart_everything $new
+ destroy .
+ exit
+ }
+ make_gui $new
+ } else {
+ set_view_variable $old
+ }
+}
+
+proc setup_client_tail {} {
+ global client_tail
+ if {$client_tail != ""} {
+ fileevent $client_tail readable read_client_info
+ }
+}
+
+proc setup_tray_embed {} {
+ global icon_win
+ update
+ set w [winfo width .]
+ set h [winfo height .]
+ if {$w < 24} {
+ set w 24
+ }
+ if {$h < 24} {
+ set h 24
+ }
+ wm minsize . $w $h
+ set wid [winfo id .]
+ push_new_value "remote-cmd" "remote-cmd" "trayembed:$wid" 0
+}
+
+proc restart_everything {gui_mode} {
+ global env gui_argv0 x11vnc_prog full_win
+ if {$gui_mode == "full"} {
+ set env(X11VNC_ICON_MODE) 0
+ } elseif {$gui_mode == "icon"} {
+ set env(X11VNC_ICON_MODE) 1
+ } elseif {$gui_mode == "tray"} {
+ if {![regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)]} {
+ set env(X11VNC_ICON_MODE) "TRAY"
+ }
+ }
+ puts stderr ""
+ puts stderr "tkx11vnc: restarting gui to leave tray mode."
+ puts stderr " new gui will be running in the background."
+ puts stderr " use kill(1) rather than Ctrl-C to kill it."
+ puts stderr ""
+ if {[info exists env(X11VNC_RESTART_DEPTH)]} {
+ set n $env(X11VNC_RESTART_DEPTH)
+ incr n
+ set env(X11VNC_RESTART_DEPTH) $n
+ } else {
+ set env(X11VNC_RESTART_DEPTH) 0
+ }
+ set env(X11VNC_ICON_SETPASS) ""
+
+ if {![info exists env(X11VNC_WISHCMD)]} {
+ puts stderr "failure in restart_everything."
+ exit 1;
+ }
+
+ set code [exec $x11vnc_prog -printgui]
+ if {[string length $code] < 20000} {
+ puts stderr "failure in restart_everything."
+ exit 1;
+ }
+ set tmp "/tmp/x11vnc[pid]"
+ file delete -force $tmp
+ if {[file exists $tmp]} {
+ puts stderr "failure in restart_everything."
+ exit 1;
+ }
+ set fh [open $tmp "a"]
+ if {![file owned $tmp]} {
+ puts stderr "failure in restart_everything."
+ exit 1;
+ }
+ file attributes $tmp -permissions "0400"
+ puts $fh $code
+ close $fh
+
+ #puts stderr [exec ls -l $tmp]
+
+ wm withdraw .
+ catch {wm withdraw $full_win}
+ update
+
+ exec $env(X11VNC_WISHCMD) $tmp &
+ after 2000
+ file delete -force $tmp
+
+ destroy .
+ exit
+}
+
+proc undo_tray_embed {} {
+ global icon_win
+ set wid [winfo id .]
+ push_new_value "remote-cmd" "remote-cmd" "trayunembed:$wid" 0
+}
+
############################################################################
# main:
global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;
-global x11vnc_client_file
+global x11vnc_client_file x11vnc_gui_geom x11vnc_started vnc_url
global x11vnc_auth_file x11vnc_connect_file beginner_mode simple_gui_created
-global helpall helptext helpremote helplabel hostname;
+global helpall helptext helpremote helplabel hostname osname
global all_settings reply_xdisplay always_update
global max_text_height max_text_width
global menu_var unset_str menus_disabled
@@ -3707,15 +4702,21 @@ global bfont ffont old_labels have_labelframes
global connected_to_x11vnc
global delay_sleep extra_sleep extra_sleep_split
global cache_all_query_vars
-global last_query_all_time query_all_freq
-global tray_mode tray_embed_id client_tail
+global last_query_all_time query_all_freq client_tail client_tail_read
+global icon_mode tray_embed tray_running icon_setpasswd icon_embed_id
+global icon_noadvanced icon_minimal
+global make_gui_count text_area_str
+global gui_argv0 gui_start_mode
set unset_str "(unset)"
+set vnc_url $unset_str
set connected_to_x11vnc 0
set menus_disabled 0
set max_text_height 40
set max_text_width 90
set bfont "-adobe-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*"
+set sfont "-adobe-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*"
+set snfont "-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*"
set ffont "fixed"
set help_indent 24;
set reply_xdisplay ""
@@ -3725,12 +4726,23 @@ set cache_all_query_vars ""
set query_all_freq 120
set last_query_all_time [clock seconds]
set client_tail ""
+set client_tail_read 0
+set make_gui_count 0
+set text_area_str ""
+set gui_argv0 $argv0
+set gui_start_mode ""
# these are no longer used under x11vnc -sync:
set delay_sleep 350
set extra_sleep 1000
set extra_sleep_split 4
+if {$tk_version < 8.0} {
+ puts stderr ""
+ puts stderr "*** tkx11vnc: tk version is old $tk_version, please use 8.0 or higher."
+ puts stderr "*** will try to continue with reduced functionality..."
+ puts stderr ""
+}
if {[regexp {^[34]} $tk_version] || $tk_version == "8.0"} {
set old_labels 1
} else {
@@ -3759,7 +4771,34 @@ if {"$argv" == "-spit"} {
exit 0
}
+
+set_view_variable "full"
+
+#puts [exec env | grep X11VNC]
+
# Read environment for clues:
+
+set x11vnc_client_file "";
+if {[info exists env(X11VNC_CLIENT_FILE)]} {
+ set x11vnc_client_file $env(X11VNC_CLIENT_FILE);
+ set file $x11vnc_client_file
+
+ set client_tail ""
+ if {[file exists $file] && [file isfile $file]} {
+ if {[file readable $file] && [file owned $file]} {
+ set client_tail [open "|tail -f $x11vnc_client_file" "r"]
+ }
+ }
+ if {$client_tail != ""} {
+ gets $client_tail tmp
+ if [eof $client_tail] {
+ clean_client_tail
+ set client_tail ""
+ }
+ }
+ catch {file delete -force $x11vnc_client_file}
+}
+
if {[info exists env(X11VNC_PROG)]} {
set x11vnc_prog $env(X11VNC_PROG);
} else {
@@ -3778,16 +4817,21 @@ if {[info exists env(X11VNC_CONNECT)]} {
set x11vnc_connect 0;
}
+if {[info exists env(X11VNC_GUI_GEOM)]} {
+ set x11vnc_gui_geom $env(X11VNC_GUI_GEOM);
+} else {
+ set x11vnc_gui_geom ""
+}
+
if {[info exists env(X11VNC_CONNECT_FILE)]} {
set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);
} else {
set x11vnc_connect_file "";
}
-if {[info exists env(X11VNC_CLIENT_FILE)]} {
- set x11vnc_client_file $env(X11VNC_CLIENT_FILE);
-} else {
- set x11vnc_client_file "";
+set x11vnc_started 0
+if {[info exists env(X11VNC_STARTED)]} {
+ set x11vnc_started 1
}
if {[info exists env(X11VNC_XDISPLAY)]} {
@@ -3795,6 +4839,7 @@ if {[info exists env(X11VNC_XDISPLAY)]} {
set x11vnc_connect 1
} elseif {$argv != "" && [regexp {:[0-9]} $argv]} {
+ set env(X11VNC_XDISPLAY) "$argv"
set x11vnc_xdisplay "$argv"
set x11vnc_connect 1
@@ -3817,21 +4862,55 @@ if {[info exists env(X11VNC_SIMPLE_GUI)]} {
set beginner_mode 0
}
-set tray_mode 0
-if {[info exists env(X11VNC_TRAY_MODE)]} {
- set tray_mode 1
+set icon_mode 0
+set tray_embed 0
+set tray_running 0
+if {![info exists env(X11VNC_ICON_MODE)]} {
+ set icon_mode 0
+} elseif {$env(X11VNC_ICON_MODE) == "" || $env(X11VNC_ICON_MODE) == "0"} {
+ set icon_mode 0
} else {
- set tray_mode 0
+ set icon_mode 1
+ set_view_variable "icon"
+ if [regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)] {
+ set tray_embed 1
+ }
+ if [regexp -nocase {RUNNING} $env(X11VNC_ICON_MODE)] {
+ set tray_running 1
+ }
+}
+set icon_setpasswd 0
+if {[info exists env(X11VNC_ICON_SETPASS)]} {
+ if {$env(X11VNC_ICON_SETPASS) != ""} {
+ set icon_setpasswd 1
+ }
}
-set tray_mode 1
-if {[info exists env(X11VNC_TRAY_EMBED_ID)]} {
- set tray_embed_id $env(X11VNC_TRAY_EMBED_ID)
+set icon_noadvanced 0
+if {[info exists env(X11VNC_ICON_NOADVANCED)]} {
+ set icon_noadvanced 1
+}
+
+set icon_minimal 0
+if {[info exists env(X11VNC_ICON_MINIMAL)]} {
+ set icon_minimal 1
+}
+
+if {[info exists env(X11VNC_ICON_EMBED_ID)]} {
+ set icon_embed_id $env(X11VNC_ICON_EMBED_ID)
} else {
- set tray_embed_id ""
+ set icon_embed_id ""
}
+
set hostname [exec uname -n]
+set osname [exec uname]
+
+if {[regexp -nocase {IRIX} $osname]} {
+ # IRIX "fixed" font is huge and doublespaced...
+ set ffont $snfont
+}
+
#puts [exec env]
#puts "x11vnc_xdisplay: $x11vnc_xdisplay"
@@ -3854,18 +4933,28 @@ tweak_both screen_blank sb
set_template
set_name "tkx11vnc"
-make_widgets;
-menu_bindings;
key_bindings;
-if {$x11vnc_connect} {
- try_connect_and_query_all
-}
-set_widgets
-
-if {$tray_mode && $client_tail != ""} {
- fileevent $client_tail readable read_client_info
+if {$icon_mode} {
+ if {$tray_embed} {
+ make_gui "tray"
+ } else {
+ make_gui "icon"
+ }
+ old_balloon
+ if {$icon_setpasswd} {
+ set m "You must specify a Session\n"
+ set m "${m}Password before VNC clients can\n"
+ set m "${m}connect. Enter one in the Password\n"
+ set m "${m}field and then Press \"OK\". This\n"
+ set m "${m}password is not stored, it is only\n"
+ set m "${m}used for this x11vnc session.\n"
+ do_props $m
+ push_new_value "unlock" "unlock" 1 0
+ }
+} else {
+ make_gui "full"
}
# main loop.
diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h
index 2f52f9c..ddff298 100644
--- a/x11vnc/tkx11vnc.h
+++ b/x11vnc/tkx11vnc.h
@@ -108,32 +108,41 @@
"Screen\n"
" =DRA refresh\n"
" =RA reset\n"
-" =DRA blacken\n"
+" =RA blacken\n"
" fixscreen:\n"
" -- D\n"
-" id:\n"
-" sid:\n"
" =D scale:\n"
" scale_cursor:\n"
" --\n"
-" overlay\n"
-" overlay_nocursor\n"
-" --\n"
" =D solid\n"
" solid_color:\n"
-" visual:\n"
+" --\n"
+" =GAL OverlayVisuals::\n"
+" overlay\n"
+" overlay_nocursor\n"
+" =GAL LOFF\n"
+" =GAL 8-Bit-Color::\n"
" flashcmap\n"
" shiftcmap:\n"
" notruecolor\n"
+" =GAL LOFF\n"
+" =GAL SubWindow::\n"
+" id:\n"
+" sid:\n"
+" =GAL LOFF\n"
+" =GAL ResizeRotate::\n"
+" = xrandr\n"
+" =-C:resize,newfbsize,exit xrandr_mode:\n"
+" padgeom:\n"
+" =GAL LOFF\n"
" --\n"
" =P blackout:\n"
" xinerama\n"
" clip:\n"
-" rawfb:\n"
" --\n"
-" = xrandr\n"
-" =-C:resize,newfbsize,exit xrandr_mode:\n"
-" padgeom:\n"
+" visual:\n"
+" rawfb:\n"
+" pipeinput:\n"
"\n"
"Keyboard\n"
" =D norepeat\n"
@@ -141,12 +150,12 @@
" modtweak\n"
" xkb\n"
" --\n"
+" =FP remap:\n"
+" --\n"
" skip_keycodes:\n"
" sloppy_keys\n"
" skip_dups\n"
" --\n"
-" =FP remap:\n"
-" --\n"
" clear_mods\n"
" clear_keys\n"
"\n"
@@ -158,53 +167,43 @@
" =D nocursorshape\n"
" --\n"
" noxfixes\n"
+" =GAL AlphaBlending::\n"
" noalphablend\n"
" alphacut:\n"
" alphafrac:\n"
" alpharemove\n"
+" =GAL LOFF\n"
" --\n"
" buttonmap:\n"
" --\n"
" xwarppointer\n"
"\n"
"Misc\n"
+" =GD-C:full,icon,tray WindowView:\n"
" =GD simple-gui\n"
" -- D\n"
+" =GA all-settings\n"
+" =RA remote-cmd:\n"
+" --\n"
" =F rc:\n"
" norc\n"
-" nolookup\n"
-" --\n"
" nofb\n"
-" --\n"
" =D nobell\n"
+" nolookup\n"
+" =GAL Selection::\n"
" =D nosel\n"
" noprimary\n"
" seldir:\n"
+" =GAL LOFF\n"
" --\n"
" xtrap\n"
" xrecord\n"
-" =RA reset_record\n"
+" =RQA reset_record\n"
" --\n"
" bg\n"
" =-C:ignore,exit sigpipe:\n"
" =0 inetd\n"
" rfbwait:\n"
-" pipeinput:\n"
-" --\n"
-" =RA remote-cmd:\n"
-" =GA all-settings\n"
-" --\n"
-" =GAL Misc-Tuning::\n"
-" fs:\n"
-" gaps:\n"
-" grow:\n"
-" fuzz:\n"
-" wait_ui:\n"
-" nowait_bog\n"
-" readtimeout:\n"
-" snapfb\n"
-" threads\n"
-" wmdt:\n"
"\n"
"Debugging\n"
" debug_pointer\n"
@@ -214,65 +213,63 @@
" =GA tail-logfile\n"
" quiet\n"
" --\n"
+" =GAL Misc-Debug::\n"
" debug_xevents\n"
" debug_xdamage\n"
" =-C:0,1,2,3 debug_wireframe:\n"
" debug_scroll\n"
" debug_tiles\n"
+" debug_grabs\n"
" dbg\n"
-" --\n"
+" =GAL LOFF\n"
" =GA show-start-cmd\n"
" =DG debug_gui\n"
"\n"
"Permissions\n"
" =DRQA lock\n"
" =DRQA unlock\n"
-" =SQA deny_all\n"
" --\n"
" =DFP allow:\n"
" =D localhost\n"
" =RA allowonce:\n"
" listen:\n"
" -- D\n"
-" =RA noremote\n"
-" --\n"
-" =D viewonly\n"
" =D shared\n"
" =D forever\n"
" timeout:\n"
" --\n"
+" =D viewonly\n"
" input:\n"
" --\n"
-" =S alwaysshared\n"
-" =S nevershared\n"
-" =S dontdisconnect\n"
+" safer\n"
+" unsafe\n"
+" =RA noremote\n"
" --\n"
+" =GAL Passwords::\n"
+" passwd:\n"
" viewpasswd:\n"
" =F passwdfile:\n"
-" =0 storepasswd\n"
" =F rfbauth:\n"
-" passwd:\n"
-" --\n"
-" safer\n"
-" unsafe\n"
+" =0 storepasswd\n"
+" =GAL LOFF\n"
+" =GAL Misc-Perms::\n"
+" =S alwaysshared\n"
+" =S nevershared\n"
+" =S dontdisconnect\n"
+" =SQA deny_all\n"
+" =GAL LOFF\n"
"\n"
"Tuning\n"
" =D-C:0,1,2,3,4 pointer_mode:\n"
" input_skip:\n"
" =D nodragging\n"
" --\n"
-" noshm\n"
-" flipbyteorder\n"
-" onetile\n"
-" --\n"
-" xdamage\n"
-" xd_area:\n"
-" xd_mem:\n"
-" --\n"
+" =GAL WireFrame::\n"
" wireframe\n"
" wireframe_mode:\n"
" =-C:never,top,always wirecopyrect:\n"
-" --\n"
+" =GAL LOFF\n"
+" =GAL ScrollCopyRect::\n"
" =-C:never,keys,mouse,always scrollcopyrect:\n"
" scr_area:\n"
" scr_skip:\n"
@@ -281,6 +278,12 @@
" scr_term:\n"
" scr_keyrepeat:\n"
" scr_parms:\n"
+" =GAL LOFF\n"
+" =GAL XDAMAGE::\n"
+" xdamage\n"
+" xd_area:\n"
+" xd_mem:\n"
+" =GAL LOFF\n"
" -- D\n"
" speeds:\n"
" =D wait:\n"
@@ -288,7 +291,24 @@
" =D nap\n"
" screen_blank:\n"
" --\n"
+" =GAL SharedMemory::\n"
+" noshm\n"
+" flipbyteorder\n"
+" onetile\n"
+" =GAL LOFF\n"
+" =GAL Misc-Tuning::\n"
" progressive:\n"
+" fs:\n"
+" gaps:\n"
+" grow:\n"
+" fuzz:\n"
+" wait_ui:\n"
+" nowait_bog\n"
+" readtimeout:\n"
+" snapfb\n"
+" threads\n"
+" wmdt:\n"
+" =GAL LOFF\n"
"\"\n"
"}\n"
"\n"
@@ -420,26 +440,32 @@
"\"\n"
"\n"
" set helptext(Tray) \"\n"
-"The tray/icon mode (started with \\\"x11vnc -gui tray ...\\\") presents a\n"
-"small icon that indicates the status of a running x11vnc server.\n"
+"The tray/icon mode (started with \\\"x11vnc -gui tray ...\\\", etc.) presents\n"
+"a small icon that indicates the status of the running x11vnc server.\n"
"\n"
"Depending on your environment, this icon may be embedded in a system\n"
-"tray or applet dock, or simply be a standalone window.\n"
+"tray or applet dock, or simply be a standalone window. \\\"-gui tray\\\"\n"
+"will attempt to embed the icon in the system tray, while \\\"-gui icon\\\"\n"
+"is for a standalone window. Use \\\"-gui tray=setpass\\\" (or icon=setpass)\n"
+"to be prompted to set the session password at startup.\n"
"\n"
"When the icon has a light background, that means no VNC viewers are\n"
-"currently connected to the display.\n"
+"currently connected to the VNC display.\n"
"\n"
"When the icon has a dark background (i.e. reverse-video), that means at\n"
-"least one VNC viewer is connected to the display.\n"
+"least one VNC viewer is connected to the VNC display.\n"
"\n"
"Moving the mouse pointer over the icon will popup a \\\"status balloon\\\"\n"
-"indicating the VNC display name and the names and other info of any\n"
-"connected VNC viewers.\n"
+"indicating the VNC display name and the names and info of any connected VNC\n"
+"viewers. Press the middle mouse button if the balloon does not appear.\n"
"\n"
-"Clicking the right mouse button on the icon displays a menu of actions:\n"
+"Clicking the left or right mouse button on the icon displays a menu\n"
+"of actions:\n"
"\n"
-" Properties - Brings up the Properties dialog. The full tkx11vnc\n"
-" GUI may be accessed via the \\\"Advanced ...\\\" button.\n"
+" Properties - Brings up the Properties dialog to set some basic\n"
+" parameters. The full tkx11vnc GUI may be accessed\n"
+" via the \\\"Advanced ...\\\" button. Press \\\"Help ...\\\"\n"
+" in the Properties dialog for more info.\n"
" \n"
" Help - Displays this help text.\n"
" \n"
@@ -447,10 +473,17 @@
" of a computer that is running a VNC viewer in\n"
" \\\"listen\\\" mode (e.g. vncviewer -listen). For a\n"
" non-standard listening port use \\\"host:port\\\".\n"
+"\n"
" Pressing \\\"OK\\\" will initiate the reverse\n"
" connection. Use a blank hostname to skip it.\n"
" \n"
" Disconnect All - Disconnects all current VNC viewers.\n"
+"\n"
+" Window View - Switch between the \\\"full\\\" gui (also known as\n"
+" \\\"Advanced\\\"), \\\"icon\\\" mode (small icon window with\n"
+" popups), or \\\"tray\\\" mode (small icon embedded in the\n"
+" system tray). This is a shortcut for the action:\n"
+" \\\"Properties -> Advanced -> Misc -> WindowView\\\".\n"
" \n"
" Stop x11vnc - Directs the x11vnc server to disconnect all vncviewers\n"
" and then exit. The tray/icon GUI then exits as well.\n"
@@ -459,7 +492,8 @@
"If the x11vnc server stops for any reason, the tray/icon gui will exit.\n"
"\n"
"If you delete the tray/icon (e.g. X out button), that is the same\n"
-"as the \\\"Stop x11vnc\\\" action in the menu.\n"
+"as the \\\"Stop x11vnc\\\" action in the menu. (This will disconnect any\n"
+"VNC viewer you are currently using to access the display).\n"
"\"\n"
"\n"
" set helptext(Properties) \"\n"
@@ -467,34 +501,34 @@
"running x11vnc server. After modifying them press \\\"OK\\\" or \\\"Apply\\\"\n"
"to apply the changes, or press \\\"Cancel\\\" to skip applying them.\n"
"\n"
-"\\\"Accept Connections\\\" toggles whether VNC viewers are allowed\n"
-"to connect or not. It corresponds to the \\\"-R unlock\\\" and \\\"-R lock\\\"\n"
-"remote-control commands.\n"
-"\n"
-"\\\"Ask for Confirmation\\\" toggles whether a popup menu will be presented\n"
-"at the X display when a new VNC viewer attempts to connects. The person\n"
-"sitting at the X display can chose to accept or reject the connection\n"
-"or accept the connection in View-Only mode. It corresponds to the \n"
-"\\\"-R accept:popup\\\" and \\\"-R accept:\\\" remote-control commands.\n"
-"\n"
-"\\\"All Clients ViewOnly\\\" toggles whether the entire VNC desktop is\n"
-"view only. All clients will only be able to watch when this is set\n"
-"(regardless of how they logged in). It corresponds to the \\\"-R viewonly\\\"\n"
-"and \\\"-R noviewonly\\\" remote-control commands.\n"
-"\n"
-"\\\"Shared\\\" toggles whether multiple simultaneous connections are\n"
-"allowed or not. It corresponds to the \\\"-R shared\\\" and \\\"-R noshared\\\"\n"
-"remote-control commands.\n"
-"\n"
-"\\\"Password\\\" lets you set the session password viewers may use to gain full\n"
-"access to the display.\n"
-"\n"
-"\\\"ViewOnly Password\\\" lets you set the session password viewers may\n"
-"use to gain view only access to the display.\n"
-"\n"
-"NOTE: These passwords only last for the current x11vnc session (they are\n"
-"not remembered, see the -storepasswd, -passwdfile, and -rfbauth x11vnc\n"
-"options for using stored passwords).\n"
+" - \\\"Accept Connections\\\" toggles whether VNC viewers are allowed\n"
+" to connect or not. It corresponds to the \\\"-R unlock\\\" and \\\"-R lock\\\"\n"
+" remote-control commands.\n"
+" \n"
+" - \\\"Ask for Confirmation\\\" toggles whether a popup menu will be presented\n"
+" at the X display when a new VNC viewer attempts to connects. The person\n"
+" sitting at the X display can chose to accept or reject the connection\n"
+" or accept the connection in View-Only mode. It corresponds to the \n"
+" \\\"-R accept:popup\\\" and \\\"-R accept:\\\" remote-control commands.\n"
+" \n"
+" - \\\"All Clients ViewOnly\\\" toggles whether the entire VNC desktop is\n"
+" view only. All clients will only be able to watch when this is set\n"
+" (regardless of how they logged in). It corresponds to the\n"
+" \\\"-R viewonly\\\" and \\\"-R noviewonly\\\" remote-control commands.\n"
+" \n"
+" - \\\"Shared\\\" toggles whether multiple simultaneous connections are\n"
+" allowed or not. It corresponds to the \\\"-R shared\\\" and \\\"-R noshared\\\"\n"
+" remote-control commands.\n"
+"\n"
+" - \\\"Password\\\" lets you set the session password viewers may use to gain full\n"
+" access to the display.\n"
+" \n"
+" - \\\"ViewOnly Password\\\" lets you set the session password viewers may\n"
+" use to gain view only access to the display.\n"
+"\n"
+"NOTE: These \\\"session\\\" passwords only last for the current x11vnc\n"
+"session (they are not remembered, see the -storepasswd, -passwdfile,\n"
+"and -rfbauth x11vnc options for using stored passwords).\n"
"\n"
"If you set \\\"Password\\\" to the empty string that makes the \\\"View-Only\n"
"Password\\\" empty as well and removes the need for any password to log in.\n"
@@ -502,17 +536,269 @@
"If you set \\\"ViewOnly Password\\\" to the empty string that just removes\n"
"the ViewOnly log in aspect: \\\"Password\\\" is still required to log in.\n"
"\n"
-"The \\\"Help ...\\\" button shows this help text.\n"
-"\n"
-"The \\\"Advanced ...\\\" button replaces the Properties dialog with the full\n"
-"tkx11vnc GUI. Any dynamic settings can be modified in the full GUI.\n"
+" - The \\\"Help ...\\\" button shows this help text.\n"
+" \n"
+" - The \\\"Advanced ...\\\" button replaces the Properties dialog with the full\n"
+" tkx11vnc GUI. All dynamic settings can be modified in the full GUI.\n"
"\" \n"
"\n"
" set helptext(all) $helpall\n"
"\n"
" set helptext(Misc-Tuning:) \"\n"
-"These contain some miscellaneous tuning parameters that are not\n"
-"often used. Placed here to avoid overcrowding in the Tuning menu.\n"
+"x11vnc has what seems like hundreds of tuning parameters. In this\n"
+"sub-menu we place some lesser used ones. Mostly likely you'll want to\n"
+"leave them at their default values, but you can try them out quickly\n"
+"with the gui to see if they improve things.\n"
+"\"\n"
+"\n"
+" set helptext(Passwords:) \"\n"
+"The items in this sub-menu pertain to setting passwords. Note that x11vnc\n"
+"has two types of password files: RealVNC-style ones (you can create them\n"
+"with x11vnc -storepasswd or other VNC utility program) you use these\n"
+"via -rfbauth; and plain-text file passwords you use via -passwdfile.\n"
+"\n"
+"Normally passwords cannot be changed by remote-control (e.g. the gui),\n"
+"but for the case of the \\\"Icon\\\" and \\\"Tray\\\" modes this constraint has\n"
+"been relaxed.\n"
+"\n"
+"In neither the RealVNC-style nor the plain-text file cases should the\n"
+"password files be readable by users you do not want to access the VNC\n"
+"server. Contrary to popular belief, the RealVNC-style passwords are\n"
+"not encrypted, merely obscured.\n"
+"\n"
+"x11vnc has the even less secure -passwd and -viewpasswd supplied on\n"
+"the command line. Be careful with these since they could be read by\n"
+"users with something like the ps(1) command. On some operating systems\n"
+"x11vnc tries to quickly overwrite them on the command line but it doesn't\n"
+"work everywhere.\n"
+"\n"
+"Regarding ViewOnly passwords (where a VNC client using that password\n"
+"can only watch the screen, not interact with it), this is not available\n"
+"with -rfbauth, but only with -passwdfile, -passwd, and -viewpasswd.\n"
+"\"\n"
+"\n"
+" set helptext(Misc-Perms:) \"\n"
+"In this sub-menu we provide some lesser used permission options.\n"
+"Regarding -alwaysshared, -nevershared, and -dontdisconnect, you probably\n"
+"should never use them and just use x11vnc's -shared and -forever options\n"
+"instead (these give basically the same functionality and if you mixed\n"
+"them too much unexpected things may happen).\n"
+"\"\n"
+"\n"
+" set helptext(AlphaBlending:) \"\n"
+"In this sub-menu we provide some tweak parameters for cursors (little\n"
+"icon at the mouse pointer) that have transparency (i.e. an Alpha channel\n"
+"in addition to Red, Green, and Blue RGB channels). For these cursors,\n"
+"some of the graphics underneath the cursor is allowed to be blended in:\n"
+"e.g. a drop-shadow (a terrible effect IMNSHO).\n"
+"\n"
+"AlphaBlending for x11vnc is only available when the XFIXES X extension is\n"
+"present (since otherwise it cannot see the cursors at all and so applies\n"
+"heuristics to show some fake cursors). AlphaBlending is only a problem\n"
+"with x11vnc when the cursors are not opaque.\n"
+"\n"
+"Opaque cursors (e.g. bitmap or simply colored cursor) are rendered\n"
+"correctly by x11vnc. Only when there is transparency does x11vnc have\n"
+"to make some approximation to transform the cursor to be opaque (the\n"
+"VNC protocol does not provide for an alpha channel in cursors, only RGB).\n"
+"\n"
+"The items in this sub-menu let you tweak x11vnc's approximation scheme\n"
+"for cursors with transparency. Hopefully you won't have to use them.\n"
+"Certain cursor \\\"themes\\\" may require adjustment however.\n"
+"\"\n"
+" set helptext(OverlayVisuals:) \"\n"
+"In this sub-menu are some options that involve fixing color problems\n"
+"for \\\"Overlay\\\" or \\\"Multi-Depth\\\" visuals. This problem is rare\n"
+"since overlay and multi-depth visual video hardware is rare. \n"
+"Some Sun, SGI, and HP machines are known to have them.\n"
+"\n"
+"The short answer is if you have a multi-depth visual display (e.g. 8 and\n"
+"24 bits), and you see messed up colors in x11vnc try the \\\"-overlay\\\"\n"
+"option on Solaris or IRIX.\n"
+"\n"
+"A brief Background on pixels, color, and visuals:\n"
+"\n"
+" Pixels (picture elements) are kept in video memory as a certain number\n"
+" of bits-per-pixel (bpp). Most common are 8bpp, 16bpp, and 32bpp.\n"
+" Less common are 24bpp, 4bpp, and 1bpp (monochrome).\n"
+"\n"
+" How pixel values (i.e. values of the bits) are rendered into colors on\n"
+" the screen can be done via different \\\"Recipes\\\". These different\n"
+" recipes are referred to as \\\"visuals\\\". E.g. for 8bpp there is\n"
+" a PseudoColor visual that maintains a mapping (that can be changed\n"
+" dynamically) of the pixel values (256 possible ones) into RGB values.\n"
+" Other 8bpp visuals, e.g. StaticGrey and TrueColor have fixed, regular\n"
+" mappings and so provide less variation in kinds of colors.\n"
+"\n"
+" A visual's \\\"depth\\\" is how many of the pixels are used in the\n"
+" actual recipe. This may sound wasteful (i.t. not using some of the\n"
+" bits), but for 32bpp (4 billion colors) that is too much and nearly\n"
+" always only 24 for them are used. The most common Visual seems to\n"
+" be depth 24 TrueColor at 32bpp. This provides 16 million colors\n"
+" which is more than the number of pixels on most screens (1280x1024 =\n"
+" 1.3 million pixels). Another sometimes used visual that ignores some\n"
+" bits is depth 15 TrueColor at 16bpp.\n"
+"\n"
+"OK, now, finally, to the Overlay Visuals. Some hardware (or software\n"
+"emulations) allow different depth visuals to be used on the display\n"
+"at the same time. The pixels of windows using different depth visuals\n"
+"may overlap.\n"
+"\n"
+"The most common seems to be both 8 and 24 depth visuals on a 32bpp setup.\n"
+"24 of the pixels can be used for one visual and the remaining 8 for the\n"
+"other. This is sometimes referred to as \\\"8+24\\\" mode. Furthermore,\n"
+"a speedup is achieved because writing graphics data to, say, the 8bit\n"
+"visual does not destroy the image data in the 24bit visual. Evidently\n"
+"popup menus can be done very quickly this way: they use the 8bit visual\n"
+"and when the popup goes away the graphics data in the 24bit visual is\n"
+"immediately reexposed without having the application redrawing it.\n"
+"\n"
+"Also, some legacy applications can only use 8bpp visuals. But in these\n"
+"days of high color graphics and web browsers one would like the rest\n"
+"of the desktop to use depth 24 visuals. They often work on the multi\n"
+"depth visuals.\n"
+"\n"
+"How does this effect x11vnc? x11vnc nearly always polls the root window\n"
+"(container of all other windows). The root window will be one depth,\n"
+"e.g. 8 or 24. Any windows using the *other* depth will appear to have\n"
+"messed up colors (or just be black or some other solid color) when viewed\n"
+"via x11vnc.\n"
+"\n"
+"How to fix? Solaris and IRIX provide an API to extract the full snapshot\n"
+"of the display with all the colors correct. It comes to x11vnc as depth\n"
+"24 TrueColor. To enable this use the \\\"-overlay\\\" option. Performance\n"
+"may be slower, but if the colors are correct that is a big improvement.\n"
+"\"\n"
+"\n"
+" set helptext(8-Bit-Color:) \"\n"
+"Some older displays (e.g. with limited Video RAM) use 8 bits-per-pixel\n"
+"color. This allows for only 256 different colors on the screen at the\n"
+"same time. This sometimes leads to problems with viewing these 8bpp\n"
+"displays via x11vnc. This sub-menu has some options that correspond to\n"
+"workarounds for this case. If you can configure the machine to use 16bpp\n"
+"it may be worth it to avoid the color problems (e.g. color flashing\n"
+"as the 8bit colormap is switched).\n"
+"\"\n"
+" set helptext(SubWindow:) \"\n"
+"This sub-menu has a couple options regarding having x11vnc poll a \n"
+"single window, not the entire display. This way just the window\n"
+"is shared.\n"
+"\n"
+"Note if the application pops up multiple windows they are not tracked\n"
+"and shared. So this is not application sharing. The application has to\n"
+"be very simple (e.g. a simple terminal or the image window on a webcam)\n"
+"for this mode to be useable.\n"
+"\"\n"
+" set helptext(ResizeRotate:) \"\n"
+"This sub-menu has some options regarding screens that support the X\n"
+"Resize, Reflection, and Rotation Extension (RANDR), and one expects screen\n"
+"resizing, reflection, or rotation to take place during the x11vnc session.\n"
+"This is pretty rare, but x11vnc seems to handle it reasonably well using\n"
+"this X extension.\n"
+"\n"
+"This mode is on by default in -id mode to try to track the changing\n"
+"size of the SubWindow. It is not on by default for full-screen mode\n"
+"because of the extra overhead, etc.\n"
+"\"\n"
+"\n"
+" set helptext(WireFrame:) \"\n"
+"This sub-menu has some options for the x11vnc wireframing speedup scheme.\n"
+"\n"
+"For x11vnc, Wireframing means to watch for toplevel windows being Opaquely\n"
+"Moved or Resized. When x11vnc detects this, it stops polling the screen\n"
+"and simply shows a \\\"wireframe\\\" outline of the window as it is being\n"
+"moved or resized. This avoids \\\"screen polling thrashing\\\" when the\n"
+"screen is changing so rapidly during this period. For various reasons\n"
+"this is usually much faster then letting the window manager do its\n"
+"own wireframing (you are encouraged to do Opaque moves and resizes\n"
+"when using x11vnc!)\n"
+"\n"
+"Also, once a moved window is released in its new position, x11vnc uses\n"
+"the VNC CopyRect encoding to very efficiently update the VNC viewers\n"
+"(each just copies the image data locally).\n"
+"\n"
+"This sort of scheme was used much in the 1990's on local displays because\n"
+"video hardware was slow at the time. x11vnc tries to use this same trick\n"
+"as a speedup for its activities (the network is much slower than video\n"
+"hardware writes, and the video hardware reads that x11vnc uses to poll\n"
+"the screen are still slow today).\n"
+"\"\n"
+"\n"
+" set helptext(ScrollCopyRect:) \"\n"
+"This sub-menu has some options for the x11vnc Scroll detection and\n"
+"CopyRect speedup scheme.\n"
+"\n"
+"For this mode, x11vnc \\\"spies\\\" on communication be the X server and\n"
+"applications using the RECORD extension. It looks for various patterns\n"
+"to detect a scrolled window. This only works for some applications,\n"
+"fortunately some important ones.\n"
+"\n"
+"Once the scroll is detected it uses the VNC CopyRect encoding for a\n"
+"big speedup. Screen polling is also sped up for this scheme.\n"
+"\n"
+"There are many tweakable parameters for this mode and they are described\n"
+"in the sub-menu items.\n"
+"\"\n"
+"\n"
+" set helptext(XDAMAGE:) \"\n"
+"The DAMAGE X extension allows the X server to send signals to x11vnc\n"
+"telling it which regions of the screen have been changed. This improves\n"
+"x11vnc's performance markedly. The DAMAGE extension must be available\n"
+"on the display for this to work.\n"
+"\n"
+"Unfortunately DAMAGE cannot be trusted completely for the changed regions,\n"
+"because often the reported changed region is much larger than the actual\n"
+"changed regions. Nevertheless, x11vnc uses the DAMAGE information very\n"
+"effectively as hints to improve its performance.\n"
+"\n"
+"The items in the sub-menu allow tweaking x11vnc's DAMAGE algorithm.\n"
+"\"\n"
+"\n"
+" set helptext(SharedMemory:) \"\n"
+"This sub-menu provides some options regarding SYSV shared memory usage\n"
+"(shm) by x11vnc. Usually you want shm turned on because the x11vnc\n"
+"process is nearly always running on the same machine the X server process\n"
+"is running on. SharedMemory gives a performance speedup. However,\n"
+"if you need to modify this scenario these options allow you to.\n"
+"\"\n"
+"\n"
+" set helptext(Misc-Debug:) \"\n"
+"This sub-menu contains a lot of debugging parameters usually used\n"
+"for debugging x11vnc itself. This is unlike the -debug_pointer and\n"
+"-debug_keyboard options that are useful in learning information, quirks,\n"
+"etc. about your local display and environment.\n"
+"\"\n"
+"\n"
+" set helptext(Selection:) \"\n"
+"This sub-menu contains some options centering around the Selection\n"
+"(also referred to as the Clipboard, Cutbuffers, etc). x11vnc will try\n"
+"to exchange the selections between the VNC viewers and the X server.\n"
+"\"\n"
+"\n"
+" set helptext(WindowView) \"\n"
+"Set the Window View Mode for the gui. There are three modes:\n"
+"\n"
+" - full: Presents the full gui (Actions, Clients, etc, buttons,\n"
+" and the Text area and Set/Entry box).\n"
+"\n"
+" - icon: Presents a small icon instead of the full gui. Moving\n"
+" the mouse over it shows the VNC display name and any\n"
+" connected clients. Clicking on the icon pops up a menu\n"
+" of actions to perform. Among them is \\\"Properties\\\" that\n"
+" allows setting more parameters. Clicking on \\\"Advanced\\\"\n"
+" in \\\"Properties\\\" brings up the full gui.\n"
+"\n"
+" - tray: Attempt to embed the small icon in the system tray. If\n"
+" this fails it will resort to icon mode where the small icon\n"
+" is a standalone window.\n"
+"\n"
+"Note that in \\\"full\\\" mode if you delete the full gui window the gui\n"
+"terminates (but the x11vnc server keeps running). However under \\\"icon\\\"\n"
+"or \\\"tray\\\" mode if you bring up the full gui window via \\\"Properties ->\n"
+"Advanced\\\" and then delete it the gui does NOT terminate.\n"
+"\n"
+"Also note that by default in \\\"icon\\\" mode if you delete the icon\n"
+"window both the gui and the x11vnc server terminate.\n"
"\"\n"
"\n"
" set helptext(gui) \"\n"
@@ -520,23 +806,30 @@
"provides an interface to each of the many x11vnc command line options and\n"
"remote control commands. See \\\"Help -> all\\\" for much info about x11vnc.\n"
"\n"
+"For a simplier gui, run x11vnc in \\\"tray\\\" or \\\"icon\\\" mode such as\n"
+"\\\"-gui tray\\\", \\\"-gui icon\\\", or \\\"-gui tray=setpass\\\". In that\n"
+"mode the full gui is only available under \\\"Advanced ...\\\".\n"
+"\n"
+"Also, \\\"-gui ez\\\" will show fewer menu items (toggle via Misc -> simple_gui)\n"
+"\n"
"All menu items have a (?) button one can click on to get more information\n"
"about the option or command.\n"
"\n"
"There are two states tkx11vnc can be in:\n"
"\n"
" 1) Available to control a running x11vnc process.\n"
+"\n"
" 2) Getting ready to start a x11vnc process.\n"
"\n"
+"Most people will just use state 1).\n"
+"\n"
"In state 1) the Menu items available in the menus are those that\n"
"correspond to the x11vnc \\\"remote control\\\" commands. See the -remote\n"
"entry under \\\"Help -> all\\\" for a complete list. Also available is\n"
"the \\\"Actions -> stop\\\" item to shut down the running x11vnc server,\n"
-"thereby changing to state 2). One could also simply \\\"Actions -> detach\\\"\n"
-"leaving the x11vnc server running. \\\"Actions -> attach\\\" would\n"
-"reestablish the connection.\n"
+"thereby changing to state 2). There are other actions available too.\n"
"\n"
-"In state 2) the Menu items available in the menus (Actions, Clients,\n"
+"In state 2) the Menu items available in the menus (\\\"Actions\\\", \\\"Clients\\\",\n"
"etc.) are those that correspond to command line options used in starting\n"
"an x11vnc process, and the \\\"Actions -> start\\\" item executes\n"
"x11vnc thereby changing to state 1). To see what x11vnc startup command\n"
@@ -546,11 +839,13 @@
"There is much overlap between the menu items available in state 1)\n"
"and state 2), but it is worth keeping in mind it is not 100%.\n"
"For example, you cannot set passwords or password files in state 1).\n"
+"(update: simple password setting is now allowed in \\\"tray\\\" or \\\"icon\\\" mode).\n"
"\n"
"\n"
"Also note that there may be *two* separate X displays involved, not just\n"
"one: 1) the X display x11vnc will be polling (and making available to\n"
"VNC viewers), and 2) the X display this GUI is intended to display on.\n"
+"\n"
"For example, one might use ssh to access the remote machine where the\n"
"GUI would display on :11 and x11vnc would poll display :0. By default\n"
"the gui will display on the value in the DISPLAY env. variable followed\n"
@@ -562,34 +857,36 @@
"--- ----------\n"
"\n"
"1) At the top of the gui is a info text label where information will\n"
-"be posted, e.g. when traversing menu items text indicating how to get\n"
-"help on the item and its current value will be displayed.\n"
+" be posted, e.g. when traversing menu items text indicating how to get\n"
+" help on the item and its current value will be displayed.\n"
"\n"
-"2) Below the info label is the area where the menu buttons, Actions,\n"
-"Clients, etc., are presented. If a menu item has a checkbox,\n"
-"it corresponds to a boolean on/off variable. Otherwise it is\n"
-"either a string variable, or an action not associated with a\n"
-"variable (for the most part).\n"
+"2) Below the info label is the area where the menu buttons, \\\"Actions\\\",\n"
+" \\\"Clients\\\", etc., are presented. If a menu item has a checkbox,\n"
+" it corresponds to a boolean on/off variable. Otherwise it is\n"
+" either a string variable, or an action not associated with a\n"
+" variable (for the most part).\n"
"\n"
-"3) Below the menu button area is a text label indicating the current x11vnc\n"
-"X display being polled and the corresponding VNC display name. Both\n"
-"will be \\\"(*none*)\\\" when there is no connection established.\n"
+"3) Below the menu button area is a label indicating the current x11vnc\n"
+" X display being polled and the corresponding VNC display name. Both\n"
+" will be \\\"(*none*)\\\" when there is no connection established.\n"
"\n"
-"4) Below the x11 and vnc displays text label is a text area there scrolling\n"
-"information about actions being taken and commands being run is displayed.\n"
-"To scroll click in the area and use PageUp/PageDown or the arrow keys.\n"
+"4) Below the x11 and vnc displays label is a text area there scrolling\n"
+" information about actions being taken and commands being run is displayed.\n"
+" To scroll click in the area and use PageUp/PageDown or the arrow keys.\n"
"\n"
"5) At the bottom is an entry area. When one selects a menu item that\n"
-"requires supplying a string value, the label will be set to the\n"
-"parameter name and one types in the new value. Then one presses the\n"
-"\\\"OK\\\" button or presses \\\"Enter\\\" to set the value. Or you can press\n"
-"\\\"Cancel\\\" or \\\"Escape\\\" to avoid changing the variable. Some variables\n"
-"are boolean toggles (for example, \\\"Permissions -> viewonly\\\") or Radio\n"
-"button selections. Selecting these menu items will not activate the\n"
-"entry area but rather toggle the variable directly.\n"
+" requires supplying a string value, the label will be set to the\n"
+" parameter name and one types in the new value. Then one presses the\n"
+" \\\"OK\\\" button or presses \\\"Enter\\\" to set the value. Or you can press\n"
+" \\\"Cancel\\\" or \\\"Escape\\\" to avoid changing the variable.\n"
"\n"
+" Many variables are boolean toggles (for example, \\\"Permissions ->\n"
+" viewonly\\\") or Radio button selections. Selecting these menu items\n"
+" will NOT activate the entry area but rather toggle the variable\n"
+" immediately.\n"
"\n"
-"Cascades Bug: There is a bug not yet worked around for the cascade menus\n"
+"\n"
+"CASCADES BUG: There is a bug not yet worked around for the cascade menus\n"
"where the (?) help button gets in the way. To get the mouse over to\n"
"the cascade menu click and release mouse to activate the cascade, then\n"
"you can click on its items. Dragging with a mouse button held down will\n"
@@ -677,7 +974,7 @@
" wm withdraw $w\n"
" set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2];\n"
" set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2];\n"
-" wm geom $w +$x+$y\n"
+" wm geometry $w +$x+$y\n"
" wm deiconify $w\n"
" update\n"
"}\n"
@@ -702,8 +999,21 @@
"}\n"
"\n"
"proc set_name {name} {\n"
-" global full_win\n"
-" if [info exists full_win] {\n"
+" global full_win icon_mode\n"
+" global saved_set_name\n"
+"\n"
+" if {![info exists saved_set_name]} {\n"
+" set saved_set_name \"tkx11vnc\"\n"
+" }\n"
+" if {$name == \"RESTORE\"} {\n"
+" set name $saved_set_name\n"
+" } else {\n"
+" set saved_set_name $name\n"
+" }\n"
+" if {![info exists full_win]} {\n"
+" return\n"
+" }\n"
+" if {$icon_mode} {\n"
" set w $full_win\n"
" } else {\n"
" set w \".\"\n"
@@ -763,6 +1073,16 @@
"\n"
"proc active_when_connected {item} {\n"
" global helpremote helptext\n"
+" global icon_mode\n"
+"\n"
+" if {$icon_mode} {\n"
+" if {$item == \"passwd\"} {\n"
+" return 1\n"
+" }\n"
+" if {$item == \"viewpasswd\"} {\n"
+" return 1\n"
+" }\n"
+" }\n"
"\n"
" if {[opt_match G $item]} {\n"
" return 1\n"
@@ -875,7 +1195,10 @@
" append text \"\\n\\n\"\n"
" append text \"==== current $item value: ====\\n\";\n"
" append text \"\\n\"\n"
-" if {$menu_var($item) == \"\"} {\n"
+"\n"
+" if {$item == \"passwd\" || $item == \"viewpasswd\"} {\n"
+" ;\n"
+" } elseif {$menu_var($item) == \"\"} {\n"
" append text \"$unset_str\\n\"\n"
" } else {\n"
" append text \"$menu_var($item)\\n\"\n"
@@ -1113,6 +1436,9 @@
"\n"
" foreach case [array names menu_b] {\n"
" set menu_button $menu_b($case)\n"
+" if {![winfo exists $menu_button]} {\n"
+" continue\n"
+" }\n"
" $menu_button configure -state $state\n"
" }\n"
"}\n"
@@ -1474,7 +1800,7 @@
" global ca_bk ca_bm ca_bb ca_bk ca_di\n"
"\n"
" append_text \"\\nUse these checkboxes to set the input permissions \"\n"
-" append_text \"for this client\\n-or- whether to disconnect it instead. \"\n"
+" append_text \"for this client\\n-OR- whether to disconnect it instead. \"\n"
" append_text \"Then press \\\"OK\\\" or \\\"Cancel\\\".\\n\\n\"\n"
" set w \"$text_area.ca_f\"\n"
" catch {destroy $w}\n"
@@ -1524,7 +1850,7 @@
"# with entry = 0.\n"
"proc entry_dialog {item {entry 1}} {\n"
" global menu_var entry_str entry_set entry_dialog_item\n"
-" global unset_str connected_to_x11vnc\n"
+" global unset_str connected_to_x11vnc entry_box\n"
"\n"
" set entry_str \"Set $item\"\n"
" set entry_set 0\n"
@@ -1533,6 +1859,10 @@
" entry_enable\n"
" menus_disable\n"
"\n"
+" if {$item == \"passwd\" || $item == \"viewpasswd\"} {\n"
+" $entry_box configure -show \"*\"\n"
+" }\n"
+"\n"
" if {$entry} {\n"
" entry_insert \"\"\n"
" if {[info exists menu_var($item)] &&\n"
@@ -1590,6 +1920,9 @@
" append_text \"skipped setting $item\\n\"\n"
" }\n"
" }\n"
+"\n"
+" $entry_box configure -show \"\"\n"
+"\n"
" return $rc\n"
"}\n"
"\n"
@@ -1816,7 +2149,26 @@
"}\n"
"\n"
"proc append_text {str} {\n"
-" global text_area\n"
+" global text_area text_area_str\n"
+"\n"
+" if {![info exists text_area_str]} {\n"
+" set text_area_str \"\"\n"
+" }\n"
+" append text_area_str $str\n"
+"\n"
+" if {![info exists text_area]} {\n"
+" puts stderr $str\n"
+" return\n"
+" }\n"
+" if {$text_area == \"\"} {\n"
+" puts stderr $str\n"
+" return\n"
+" }\n"
+" if {![winfo exists $text_area]} {\n"
+" puts stderr $str\n"
+" return\n"
+" }\n"
+" \n"
" $text_area insert end $str\n"
" $text_area see end\n"
"}\n"
@@ -1928,6 +2280,7 @@
" if {[in_debug_mode]} {\n"
" append_text \"action: \\\"$item\\\"\\n\"\n"
" }\n"
+"#puts \"action: \\\"$item\\\"\\n\"\n"
"\n"
" if {$item == \"ping\"} {\n"
" if {$beginner_mode} {\n"
@@ -1966,6 +2319,9 @@
" } elseif {$item == \"Misc-Tuning:\"} {\n"
" menu_help \"$item\"\n"
" return\n"
+" } elseif {$item == \"WindowView\"} {\n"
+" change_view_state\n"
+" return\n"
" } elseif {$item == \"stop+quit\"} {\n"
" do_stop_quit\n"
" }\n"
@@ -2008,7 +2364,7 @@
" set debug [in_debug_mode]\n"
"\n"
" set string 0\n"
-" if {[is_action $item]} {\n"
+" if {[is_action $item] || $item == \"WindowView\"} {\n"
" # Menu item is action:\n"
" if {$debug} {\n"
" ptime [time {do_action $item}]\n"
@@ -2018,6 +2374,7 @@
" return\n"
" }\n"
"\n"
+"\n"
" if {[value_is_string $item]} {\n"
" # Menu item is a string:\n"
" if {$item_cascade($item) != \"\"} {\n"
@@ -2164,8 +2521,12 @@
" set_name \"tkx11vnc - $name\"\n"
"}\n"
"proc set_vnc_display {name} {\n"
-" global vnc_display\n"
+" global vnc_display icon_mode\n"
" set vnc_display \"VNC display: $name\"\n"
+"\n"
+" if {$icon_mode} {\n"
+" set_icon_label\n"
+" }\n"
"}\n"
"proc set_vnc_url {name} {\n"
" global vnc_url\n"
@@ -2182,6 +2543,22 @@
" set_vnc_url \"(*none*)\"\n"
"}\n"
"\n"
+"proc get_vnc_display_number {} {\n"
+" global vnc_display\n"
+" if ![info exists vnc_display] {\n"
+" return \"none\"\n"
+" }\n"
+" if {$vnc_display == \"\"} {\n"
+" return \"none\"\n"
+" }\n"
+" set str $vnc_display\n"
+" regsub {VNC display: *} $str \"\" str\n"
+" if [regexp {:([0-9][0-9]*)} $str m0 n] {\n"
+" return $n\n"
+" }\n"
+" return \"none\"\n"
+"}\n"
+"\n"
"proc fetch_displays {} {\n"
"\n"
" set qargs [list \"-Q\" \"display,vncdisplay\"]\n"
@@ -2356,14 +2733,34 @@
"\n"
"proc update_clients_menu {list} {\n"
" global item_cascade ffont\n"
+" global saved_clients_str\n"
+"\n"
+" if {![info exists saved_clients_str]} {\n"
+" set saved_clients_str \"\"\n"
+" }\n"
+" if {$list == \"INIT\"} {\n"
+" set list $saved_clients_str\n"
+" } else {\n"
+" set saved_clients_str $list\n"
+" }\n"
+"\n"
" set subm $item_cascade(current);\n"
" catch {destroy $subm}\n"
" menu $subm -tearoff 0 -font $ffont\n"
" $subm add command\n"
-" $subm add command -label \"refresh-list\" -command \"update_clients_and_repost\"\n"
+" $subm add command -label \"refresh-list\" \\\n"
+" -command \"update_clients_and_repost\"\n"
" $subm add separator\n"
" set count 0\n"
" foreach client [split $list \",\"] {\n"
+" if {![regexp {^[a-z0-9]*[a-z0-9]:} $client]} {\n"
+" append_text \"Skipping client line: \"\n"
+" append_text $client\n"
+" append_text \"\\n\"\n"
+" continue\n"
+" }\n"
+" regsub -all {[{}()~!$&*|;'\"`{}<>\\[\\]]} $client \"\" client\n"
+" #'\n"
" if {[regexp {^(.*):(.*):(.*):(.*):(.*):(.*):(.*)$} \\\n"
" $client m0 m1 m2 m3 m4 m5 m6 m7]} {\n"
" # id:ip:port:user:hostname:input:loginvo\n"
@@ -2381,11 +2778,12 @@
"}\n"
"\n"
"proc set_widgets {} {\n"
-" global connected_to_x11vnc item_case item_entry menu_m\n"
+" global connected_to_x11vnc item_case item_menu item_entry menu_m\n"
"\n"
" foreach item [array names item_case] {\n"
" set case $item_case($item)\n"
-" set menu $menu_m($case)\n"
+"# set menu $menu_m($case)\n"
+" set menu $item_menu($item)\n"
" set entry $item_entry($item)\n"
" if {$entry < 0} {\n"
" # skip case under beginner_mode \n"
@@ -2395,21 +2793,20 @@
" if {$type == \"separator\" || $type == \"tearoff\"} {\n"
" continue\n"
" }\n"
+" if {![winfo exists $menu]} {\n"
+" continue\n"
+" }\n"
" if {$connected_to_x11vnc} {\n"
" if {[active_when_connected $item]} {\n"
" $menu entryconfigure $entry -state normal\n"
-"#puts \"n-1 $case / $item / $entry\"\n"
" } else {\n"
" $menu entryconfigure $entry -state disabled\n"
-"#puts \"I-1 $case / $item / $entry\"\n"
" }\n"
" } else {\n"
" if {[active_when_starting $item]} {\n"
" $menu entryconfigure $entry -state normal\n"
-"#puts \"n-2 $case / $item / $entry\"\n"
" } else {\n"
" $menu entryconfigure $entry -state disabled\n"
-"#puts \"I-2 $case / $item / $entry\"\n"
" }\n"
" }\n"
" }\n"
@@ -2417,7 +2814,7 @@
"\n"
"proc toggle_simple_gui {} {\n"
" global beginner_mode simple_gui_created\n"
-" global connected_to_x11vnc\n"
+" global connected_to_x11vnc make_gui_count\n"
"\n"
" if {$beginner_mode} {\n"
" append_text \"\\nSwitching to simple-gui mode.\\n\"\n"
@@ -2425,26 +2822,81 @@
" append_text \"\\nSwitching to power-user gui mode.\\n\"\n"
" }\n"
"\n"
+" if {$make_gui_count == 1} {\n"
+" incr make_gui_count\n"
+" }\n"
" set simple_gui_created 1\n"
" make_menu_items\n"
" set_widgets\n"
" set_internal_help\n"
-" if {$connected_to_x11vnc} {\n"
-" query_all\n"
-" }\n"
+"# if {$connected_to_x11vnc} {\n"
+"# query_all\n"
+"# }\n"
" append_text \"\\n\"\n"
"}\n"
"\n"
+"proc little_qs {m} {\n"
+" global bfont ffont beginner_mode\n"
+" global helpremote helptext helplabel\n"
+" global tk_version\n"
+"\n"
+" if {$tk_version < 8.0} {\n"
+" return\n"
+" }\n"
+"\n"
+" set n [$m index end]\n"
+"\n"
+" for {set i 0} {$i <= $n} {incr i} {\n"
+" set type [$m type $i]\n"
+"#puts \"$m - $i - $type\"\n"
+" if {$type == \"separator\"} {\n"
+" $m add separator\n"
+" } elseif {$type == \"tearoff\"} {\n"
+" continue;\n"
+" } else {\n"
+" set label [$m entrycget $i -label]\n"
+" set str \"\"\n"
+" if {[info exists helpremote($label)]} {\n"
+" set str \"(?)\"\n"
+" } elseif {[info exists helptext($label)]} {\n"
+" set str \"(?)\"\n"
+" }\n"
+" $m add command -label $str \\\n"
+" -font $ffont \\\n"
+" -command \"menu_help $label\";\n"
+"\n"
+" if {$str == \"\"} {\n"
+" $m entryconfigure end -state disabled\n"
+" }\n"
+" set arg \"$m,$i\"\n"
+"#puts \"helplabel: $arg -> $label\"\n"
+" set helplabel($arg) $label\n"
+" set j [$m index end]\n"
+" set arg \"$m,$j\"\n"
+" set helplabel($arg) $label\n"
+" }\n"
+" if {$i == 0} {\n"
+" $m entryconfigure end -columnbreak 1\n"
+" }\n"
+" }\n"
+"\n"
+" menu_bindings $m\n"
+"}\n"
+"\n"
"proc make_menu_items {} {\n"
" global template \n"
" global menu_b menu_m menu_count\n"
-" global item_opts item_bool item_case item_entry menu_var unset_str\n"
+" global item_opts item_bool item_case item_menu item_entry menu_var unset_str\n"
" global item_cascade\n"
" global bfont ffont beginner_mode simple_gui_created\n"
" global helptext helpremote helplabel\n"
"\n"
-" # Extract the menu items:\n"
" set case \"\";\n"
+" set L_casc \"\"\n"
+" set L_casc_count 0\n"
+" set L_menus [list]\n"
+"\n"
+" # Extract the menu items:\n"
" foreach line [split $template \"\\n\"] {\n"
" if {[regexp {^Row:} $line]} {\n"
" continue\n"
@@ -2454,10 +2906,9 @@
"\n"
" if {$simple_gui_created} {\n"
" set i0 0\n"
-" if {$case == \"Misc\"} {\n"
-" # kludge for simple_gui\n"
-" set i0 1\n"
-" }\n"
+" #if {$case == \"Misc\"} { # kludge for simple_gui\n"
+" # set i0 1\n"
+" #}\n"
" catch {$menu_m($case) delete $i0 end}\n"
" }\n"
" set menu_count($case) 0\n"
@@ -2485,6 +2936,11 @@
" }\n"
" regsub {:$} $item {} item\n"
"\n"
+" if {$item == \"LOFF\"} {\n"
+" set L_casc \"\"\n"
+" continue\n"
+" }\n"
+"\n"
" if {$item == \"-- D\"} {\n"
" set beginner_sep 1\n"
" set item \"--\"\n"
@@ -2496,17 +2952,27 @@
" set item_case($item) $case\n"
" set item_bool($item) $bool\n"
" set item_cascade($item) \"\"\n"
-" set item_entry($item) $menu_count($case)\n"
+"\n"
+" if {$L_casc == \"\"} {\n"
+" set item_entry($item) $menu_count($case)\n"
+" set m $menu_m($case)\n"
+" } else {\n"
+" # hack for cascades for crowded menus. See =GAL opts.\n"
+" set item_entry($item) $L_casc_count\n"
+" set m $L_casc\n"
+" }\n"
"\n"
" set mvar 0 \n"
-" set m $menu_m($case)\n"
"\n"
" if {$beginner_mode && ! $beginner_sep && ![opt_match D $item]} {\n"
" set item_entry($item) \"-1\"\n"
" continue;\n"
" }\n"
"\n"
-" if {0} { puts \"ITEM: $item\\t- $opts\\t- $case\\t- $bool\\t- $menu_count($case)\" }\n"
+" set item_menu($item) $m\n"
+"\n"
+" if {0} { puts \"ITEM: $item\\t- $opts\\t- $case\\t- \\\n"
+" $bool\\t- $menu_count($case)\" }\n"
"\n"
" # Create the menu items, its variables, etc., etc.\n"
"\n"
@@ -2525,12 +2991,25 @@
" -font $ffont \\\n"
" -command \"menu_help $item\"\n"
"\n"
+" } elseif {[opt_match L $item]} {\n"
+" # Special sub-menu cascade (=GAL ends with LOFF)\n"
+" set subm $m.casc_L$menu_count($case)\n"
+" catch {destroy $subm}\n"
+" menu $subm -tearoff 0 -font $ffont\n"
+" set item_cascade($item) $subm\n"
+" $m add cascade -label \"$item\" \\\n"
+" -font $ffont \\\n"
+" -menu $subm\n"
+" set L_casc $subm\n"
+" set L_casc_count -1\n"
+" lappend L_menus $L_casc\n"
+"\n"
" } elseif {$item == \"current\"} {\n"
" # Current clients cascade\n"
" set subm $m.current_cascade\n"
" catch {destroy $subm}\n"
" set item_cascade($item) $subm\n"
-" update_clients_menu \"\"\n"
+" update_clients_menu \"INIT\"\n"
" $m add cascade -label \"$item\" \\\n"
" -font $ffont \\\n"
" -menu $subm\n"
@@ -2540,7 +3019,9 @@
" $m add command -label \"$item\" \\\n"
" -font $ffont \\\n"
" -command \"do_var $item\"\n"
-" set menu_var($item) \"\"; # for convenience\n"
+" if {![info exists menu_var($item)]} {\n"
+" set menu_var($item) \"\"; # for convenience\n"
+" }\n"
"\n"
" } elseif {! $item_bool($item)} {\n"
" # String\n"
@@ -2569,25 +3050,34 @@
" set mvar 1\n"
"\n"
" } elseif {$item == \"simple-gui\"} {\n"
-" if {! $simple_gui_created} {\n"
-" $m add checkbutton -label \"$item\" \\\n"
-" -command \"toggle_simple_gui\" \\\n"
-" -font $ffont \\\n"
-" -variable beginner_mode\n"
-" }\n"
+" $m add checkbutton -label \"$item\" \\\n"
+" -command \"toggle_simple_gui\" \\\n"
+" -font $ffont \\\n"
+" -variable beginner_mode\n"
" } else {\n"
" # Boolean\n"
" $m add checkbutton -label \"$item\" \\\n"
" -command \"do_var $item\" \\\n"
" -font $ffont \\\n"
" -variable menu_var($item)\n"
-" set menu_var($item) 0\n"
+" if {![info exists menu_var($item)]} {\n"
+" set menu_var($item) 0\n"
+" }\n"
" }\n"
"\n"
-" incr menu_count($case)\n"
+" if {$L_casc_count == -1} {\n"
+" incr menu_count($case)\n"
+" incr L_casc_count\n"
+" } elseif {$L_casc != \"\"} {\n"
+" incr L_casc_count\n"
+" } else {\n"
+" incr menu_count($case)\n"
+" }\n"
"\n"
" if {$mvar} {\n"
-" set menu_var($item) $unset_str\n"
+" if {![info exists menu_var($item)]} {\n"
+" set menu_var($item) $unset_str\n"
+" }\n"
" }\n"
" }\n"
"\n"
@@ -2596,52 +3086,28 @@
" if {$case == \"Help\"} {\n"
" continue;\n"
" }\n"
-" set m $menu_m($case);\n"
-" set n [$m index end]\n"
-"\n"
-" for {set i 0} {$i <= $n} {incr i} {\n"
-" set type [$m type $i]\n"
-" if {$type == \"separator\"} {\n"
-" $m add separator\n"
-" } elseif {$type == \"tearoff\"} {\n"
-" continue;\n"
-" } else {\n"
-" set label [$m entrycget $i -label]\n"
-" set str \"\"\n"
-" if {[info exists helpremote($label)]} {\n"
-" set str \"(?)\"\n"
-" } elseif {[info exists helptext($label)]} {\n"
-" set str \"(?)\"\n"
-" }\n"
-" $m add command -label $str \\\n"
-" -font $ffont \\\n"
-" -command \"menu_help $label\";\n"
-"\n"
-" if {$str == \"\"} {\n"
-" $m entryconfigure end -state disabled\n"
-" }\n"
-" set arg \"$m,$i\"\n"
-" set helplabel($arg) $label\n"
-" set j [$m index end]\n"
-" set arg \"$m,$j\"\n"
-" set helplabel($arg) $label\n"
-" }\n"
-" if {$i == 0} {\n"
-" $m entryconfigure end -columnbreak 1\n"
-" }\n"
-" }\n"
+" little_qs $menu_m($case);\n"
+" }\n"
+" foreach m $L_menus {\n"
+" little_qs $m\n"
" }\n"
"}\n"
"\n"
"proc menu_posted {} {\n"
-" global last_query_all_time query_all_freq\n"
-" global connected_to_x11vnc\n"
+" global last_query_all_time query_all_freq icon_mode\n"
+" global connected_to_x11vnc client_tail\n"
+"\n"
" set now [clock seconds]\n"
"\n"
+" if {$icon_mode && $client_tail != \"\"} {\n"
+" set delay [expr 2 * $query_all_freq]\n"
+" } else {\n"
+" set delay $query_all_freq\n"
+" }\n"
"\n"
" if {$connected_to_x11vnc} {\n"
" set quiet 0\n"
-" set refresh [expr \"$last_query_all_time + $query_all_freq\"]\n"
+" set refresh [expr \"$last_query_all_time + $delay\"]\n"
"\n"
" # puts \"menu_posted $now $last_query_all_time\"\n"
" # puts \"menu_posted $refresh\"\n"
@@ -2656,6 +3122,14 @@
" }\n"
"}\n"
"\n"
+"proc props_widgets {state} {\n"
+" global props_buttons\n"
+" foreach w $props_buttons {\n"
+" $w configure -state $state \n"
+" }\n"
+" update\n"
+"}\n"
+"\n"
"proc props_apply {} {\n"
" global props_accept props_confirm props_viewonly props_shared\n"
" global props_passwd props_viewpasswd\n"
@@ -2663,6 +3137,8 @@
" global prop0_passwd prop0_viewpasswd\n"
" global menu_var\n"
"\n"
+" props_widgets disabled\n"
+"\n"
" if {$props_accept != $prop0_accept} {\n"
" if {$props_accept} {\n"
" push_new_value \"unlock\" \"unlock\" 1 0\n"
@@ -2732,13 +3208,13 @@
" set prop0_viewpasswd $props_viewpasswd\n"
" after 500\n"
" }\n"
+" props_widgets normal\n"
"}\n"
"\n"
"proc props_advanced {} {\n"
-" global tray_mode icon_win props_win full_win\n"
+" global icon_mode icon_win props_win full_win\n"
" global props_advanced_first\n"
"\n"
-"\n"
" if ![info exists props_advanced_first] {\n"
" center_win $full_win\n"
" set props_advanced_first 1\n"
@@ -2755,13 +3231,14 @@
" }\n"
"}\n"
"\n"
-"proc do_props {} {\n"
+"proc do_props {{msg \"\"}} {\n"
" global props_accept props_confirm props_viewonly props_shared\n"
" global props_passwd props_viewpasswd\n"
" global prop0_accept prop0_confirm prop0_viewonly prop0_shared\n"
" global prop0_passwd prop0_viewpasswd\n"
" global menu_var unset_str\n"
" global have_labelframes ffont bfont\n"
+" global props_buttons icon_noadvanced\n"
"\n"
" if ![info exists props_accept] {\n"
" set props_accept 1\n"
@@ -2818,10 +3295,15 @@
" }\n"
" set prop0_viewpasswd $props_viewpasswd\n"
"\n"
+" if [info exists props_buttons] {\n"
+" catch {unset props_buttons}\n"
+" }\n"
+" set props_buttons [list]\n"
+"\n"
" set w .props\n"
" catch {destroy $w}\n"
" toplevel $w\n"
-" wm title $w \"Properties\"\n"
+" wm title $w \"x11vnc Properties\"\n"
" set b1 \"$w.buttons1\"\n"
" frame $b1\n"
" button $b1.ok -text OK -command \"props_apply; destroy $w\" -font $bfont\n"
@@ -2829,14 +3311,21 @@
" button $b1.apply -text Apply -command \"props_apply\" -font $bfont\n"
"\n"
" pack $b1.apply $b1.cancel $b1.ok -side right -expand 1\n"
+" lappend props_buttons $b1.apply $b1.cancel $b1.ok\n"
"\n"
" set b2 \"$w.buttons2\"\n"
" frame $b2\n"
"\n"
" button $b2.advanced -text \"Advanced ...\" \\\n"
" -command \"destroy $w; props_advanced\" -font $bfont\n"
+" if {! $icon_noadvanced} {\n"
+" lappend props_buttons $b2.advanced\n"
+" pack $b2.advanced -side right -expand 1\n"
+" }\n"
+"\n"
" button $b2.help -text \"Help ...\" -command \"menu_help Properties\" -font $bfont\n"
-" pack $b2.advanced $b2.help -side right -expand 1\n"
+" lappend props_buttons $b2.help\n"
+" pack $b2.help -side right -expand 1\n"
"\n"
" set vp \"$w.viewpw\"\n"
" if {$have_labelframes} {\n"
@@ -2850,6 +3339,8 @@
" entry $vp.e -show \"*\" -textvariable props_viewpasswd -font $bfont\n"
" pack $vp.e -fill x -expand 1 -padx 1m -pady 1m -side top\n"
"\n"
+" lappend props_buttons $vp.e\n"
+"\n"
" set pw \"$w.passwd\"\n"
" if {$have_labelframes} {\n"
" labelframe $pw -text \"Password\" -font $bfont\n"
@@ -2862,6 +3353,8 @@
" entry $pw.e -show \"*\" -textvariable props_passwd -font $bfont\n"
" pack $pw.e -fill x -expand 1 -padx 1m -pady 1m -side top\n"
"\n"
+" lappend props_buttons $pw.e\n"
+"\n"
" set sh \"$w.shared\"\n"
" frame $sh\n"
" checkbutton $sh.button -text \"Shared\" \\\n"
@@ -2886,14 +3379,27 @@
" -variable props_accept -anchor w -font $bfont\n"
" pack $ac.button -fill x -expand 1 -padx 1m -pady 1m\n"
"\n"
-" pack $b1 -side bottom -fill x -pady 1m -padx 2m\n"
-" pack $b2 -side bottom -fill x -pady 1m -padx 2m\n"
-" pack $vp -side bottom -fill x -pady 1m -padx 2m\n"
-" pack $pw -side bottom -fill x -pady 1m -padx 2m\n"
-" pack $sh -side bottom -fill x -pady 0m -padx 2m\n"
-" pack $vo -side bottom -fill x -pady 0m -padx 2m\n"
-" pack $cf -side bottom -fill x -pady 0m -padx 2m\n"
-" pack $ac -side bottom -fill x -pady 0m -padx 2m\n"
+" set px \"6m\"\n"
+" pack $b1 -side bottom -fill x -pady 1m -padx $px\n"
+" pack $b2 -side bottom -fill x -pady 1m -padx $px\n"
+" pack $vp -side bottom -fill x -pady 1m -padx $px\n"
+" pack $pw -side bottom -fill x -pady 1m -padx $px\n"
+" pack $sh -side bottom -fill x -pady 0m -padx $px\n"
+" pack $vo -side bottom -fill x -pady 0m -padx $px\n"
+" pack $cf -side bottom -fill x -pady 0m -padx $px\n"
+" pack $ac -side bottom -fill x -pady 0m -padx $px\n"
+"\n"
+" if {$msg != \"\"} {\n"
+" set tw [textwidth $msg]\n"
+" set th [textheight $msg]\n"
+" set th [expr $th - 1]\n"
+" set ms \"$w.msg\"\n"
+" text $ms -font $ffont -relief ridge -width $tw -height $th\n"
+" $ms insert 1.0 $msg\n"
+" pack $ms -side bottom -fill x -pady 1m -padx $px\n"
+" }\n"
+"\n"
+" lappend props_buttons $ac.button $cf.button $vo.button $sh.button\n"
"\n"
" wm resizable $w 1 0\n"
" center_win $w\n"
@@ -2922,6 +3428,8 @@
" \n"
" tkwait window $w\n"
"\n"
+" regsub -all {[{}()~!$&*|;'\"`{}<>\\[\\]]} $newclient \"\" newclient\n"
+" #'\n"
" if {$newclient != \"\"} {\n"
" push_new_value \"connect\" \"connect\" \"$newclient\" 1\n"
" }\n"
@@ -2932,6 +3440,9 @@
"}\n"
"\n"
"proc pmenu {m x y} {\n"
+" if {![winfo exists $m]} {\n"
+" return\n"
+" }\n"
" set x [expr $x-10]\n"
" set y [expr $y-10]\n"
" $m post $x $y\n"
@@ -2981,31 +3492,22 @@
"\n"
"proc read_client_info {} {\n"
" global x11vnc_client_file client_tail client_str\n"
-" global unlinked_x11vnc_client_file\n"
+" global client_tail_read\n"
+" set db 0\n"
+"\n"
" if {$client_tail != \"\"} {\n"
" after 100\n"
" set str \"\"\n"
" set count [gets $client_tail str]\n"
+" if {$db} {puts stderr \"read_client_info: $str\"}\n"
"\n"
-" # we can unlink the file early since both processes\n"
-" # have it open.\n"
-" if ![info exists unlinked_x11vnc_client_file] {\n"
-" set unlinked_x11vnc_client_file 0\n"
-" } elseif {$unlinked_x11vnc_client_file == \"\"} {\n"
-" set unlinked_x11vnc_client_file 0\n"
-" }\n"
-" if {! $unlinked_x11vnc_client_file} {\n"
-" after 500\n"
-" catch {file delete $x11vnc_client_file}\n"
-" set unlinked_x11vnc_client_file 1\n"
-" }\n"
-"\n"
-" if {$count == -1} {\n"
+" if {$count == -1 || [eof $client_tail]} {\n"
" close $client_tail\n"
" catch {file delete $x11vnc_client_file}\n"
" clean_icon_exit\n"
" }\n"
" if {$count > 0 && ![regexp {^[ ]*$} $str]} {\n"
+" set client_tail_read 1\n"
" if {$str == \"quit\"} {\n"
" catch {file delete $x11vnc_client_file}\n"
" clean_icon_exit\n"
@@ -3022,14 +3524,16 @@
"}\n"
"\n"
"proc show_client_balloon {} {\n"
-" global tray_mode icon_win props_win full_win\n"
+" global icon_mode icon_win props_win full_win\n"
" global client_balloon ffont\n"
"\n"
+" set noinfo \"tkx11vnc: no client information\"\n"
+" set noinfo \"$noinfo\\navailable from x11vnc ...\"\n"
" if ![info exists client_balloon] {\n"
-" set client_balloon \"tkx11vnc ...\"\n"
+" set client_balloon $noinfo\n"
" }\n"
" if {$client_balloon == \"\"} {\n"
-" set client_balloon \"tkx11vnc ...\"\n"
+" set client_balloon $noinfo\n"
" }\n"
"\n"
" set x [expr [winfo rootx $icon_win] + ([winfo width $icon_win]/2)]\n"
@@ -3072,67 +3576,288 @@
"}\n"
"\n"
"proc icon_win_cfg {clients} {\n"
-" global icon_win\n"
+" global icon_win client_tail client_tail_read\n"
" if {$clients > 0} {\n"
" $icon_win configure -bg black -fg white\n"
" } else {\n"
" $icon_win configure -bg white -fg black\n"
" }\n"
+" if {$client_tail == \"\" || !$client_tail_read} {\n"
+" $icon_win configure -fg red\n"
+" }\n"
+"}\n"
+"\n"
+"proc server_accept {sock addr port} {\n"
+" global socket_cookie server socket_got_callback\n"
+" global client_tail\n"
+" set db 0\n"
+"\n"
+" if {$db} {puts stderr \"sock=$sock addr=$addr port=$port\"}\n"
+"\n"
+" update; update idletasks\n"
+" after 50\n"
+" update; update idletasks\n"
+" set count [gets $sock str]\n"
+"\n"
+" if {$count >= 0} {\n"
+" set str [string trim $str]\n"
+" if {$db} {puts stderr \"server_accept: \\\"$str\\\"\"}\n"
+" if {$str == \"COOKIE:$socket_cookie\"} {\n"
+" set client_tail $sock\n"
+" if {$db} {puts stderr \"cookie matched. $client_tail\"}\n"
+" } else {\n"
+" if {$db} {puts stderr \"cookie NO matched.\"}\n"
+" }\n"
+" }\n"
+" catch {close $server}\n"
+" set socket_got_callback 1\n"
+" if {$db} {puts stderr \"socket_got_callback $socket_got_callback\"}\n"
+"}\n"
+"\n"
+"proc try_client_info_sock {} {\n"
+" global socket_cookie server socket_got_callback\n"
+" global x11vnc_started hostname\n"
+" set start 13037\n"
+" set tries 100\n"
+" set socket_got_callback 0\n"
+"\n"
+" if {$x11vnc_started} {\n"
+" set myaddr \"127.0.0.1\"\n"
+" } else {\n"
+" set myaddr $hostname\n"
+" }\n"
+" set socket_cookie [clock clicks]\n"
+" \n"
+" for {set i 0} {$i <= $tries} {incr i} {\n"
+" set port [expr $start + $i]\n"
+" set server [socket -server server_accept -myaddr $myaddr $port]\n"
+" if {$server == \"\"} {\n"
+" continue\n"
+" }\n"
+" if {[eof $server]} {\n"
+" continue\n"
+" }\n"
+" set err \"\"\n"
+" catch {set err [fconfigure $server -error]}\n"
+" #puts \"err: $server: $err\"\n"
+" if {$err == \"\"} {\n"
+" break\n"
+" }\n"
+" }\n"
+" if {$server == \"\"} {\n"
+" append_text \"try_client_info_sock: server socket failed.\\n\"\n"
+" return\n"
+" }\n"
+" run_remote_cmd [list \"-nosync\" \"-R\" \"noop\"]\n"
+" after 500\n"
+" run_remote_cmd [list \"-nosync\" \"-R\" \\\n"
+" \"client_info_sock:$myaddr:$port:$socket_cookie\"]\n"
+" after 500\n"
+"\n"
+" set aftid \"\"\n"
+" if {$socket_got_callback == 0} {\n"
+" set aftid [after 10000 {set socket_got_callback 2}]\n"
+" tkwait variable socket_got_callback\n"
+" }\n"
+"\n"
+" if {$aftid != \"\"} {\n"
+" catch {after cancel $aftid}\n"
+" }\n"
+"\n"
+" if {$socket_got_callback != 1} {\n"
+" puts stderr \"try_client_info_sock failed: no callback\\n\"\n"
+" catch {close $server}\n"
+" } else {\n"
+" setup_client_tail\n"
+" }\n"
+"}\n"
+"\n"
+"proc set_icon_label {} {\n"
+" global icon_win\n"
+"\n"
+" set lab [get_icon_label]\n"
+" \n"
+" if {[info exists icon_win]} {\n"
+" $icon_win configure -text $lab\n"
+" }\n"
+"}\n"
+"\n"
+"proc get_icon_label {{set 0}} {\n"
+" global icon_minimal \n"
+"\n"
+" set lab0 \"x11\\nvnc\"\n"
+" \n"
+" if {$icon_minimal} {\n"
+" set lab [get_vnc_display_number]\n"
+" if {$lab != \"none\"} {\n"
+" set lab \" :$lab\"\n"
+" }\n"
+" } else {\n"
+" set lab $lab0\n"
+" }\n"
+" return $lab\n"
+"}\n"
+"\n"
+"proc lmenu {menu} {\n"
+" global window_view_posted\n"
+" after 100\n"
+" if {!$window_view_posted} {\n"
+" after 100\n"
+" if {!$window_view_posted} {\n"
+" $menu unpost\n"
+" return\n"
+" }\n"
+" }\n"
+" # kludge for WindowView\n"
+" focus $menu\n"
+"}\n"
+"\n"
+"proc old_balloon {} {\n"
+" global client_str saved_client_str\n"
+" set str \"\"\n"
+" if {[info exists client_str]} {\n"
+" if {$client_str != \"\"} {\n"
+" set str $client_str\n"
+" }\n"
+" }\n"
+" if {$str == \"\"} {\n"
+" if {[info exists saved_client_str]} {\n"
+" set str $saved_client_str\n"
+" }\n"
+" }\n"
+" if {$str != \"\"} {\n"
+" set_client_balloon $str\n"
+" }\n"
"}\n"
"\n"
"proc make_icon {} {\n"
-" global tray_mode tray_embed_id icon_win props_win full_win\n"
-" global x11vnc_client_file client_tail client_str\n"
+" global icon_mode icon_embed_id icon_win props_win full_win\n"
+" global tray_embed tray_running env\n"
+" global x11vnc_client_file client_tail client_str saved_clients_str\n"
" global client_balloon_id\n"
-" global bfont ffont\n"
+" global bfont sfont ffont\n"
+" global icon_minimal gui_start_mode\n"
+" global window_view_posted menu_var x11vnc_gui_geom\n"
+" set min_x 24\n"
+" set min_y 24\n"
" \n"
-"# if {$tray_embed_id != \"\"} {\n"
-"# wm withdraw .\n"
-"# set top \".icon\"\n"
-"# toplevel $top -use $tray_embed_id\n"
-"# }\n"
+" set font $bfont\n"
+" if {$tray_embed} {\n"
+" set font $sfont\n"
+" }\n"
+" if {[info exists env(X11VNC_ICON_FONT)]} {\n"
+" set font $env(X11VNC_ICON_FONT)\n"
+" }\n"
+" if {[regexp {([0-9][0-9]*)x([0-9][0-9]*)} $x11vnc_gui_geom m mx my]} {\n"
+" if {$mx < $min_x} {\n"
+" set min_x $mx\n"
+" }\n"
+" if {$my < $min_y} {\n"
+" set min_y $my\n"
+" }\n"
+" }\n"
+" wm minsize . $min_x $min_y\n"
"\n"
-" set l .label\n"
+" if {$tray_embed && $tray_running} {\n"
+" wm withdraw .\n"
+" }\n"
+"\n"
+" set l .icon\n"
" set icon_win $l\n"
-" label $l -text \"x11\\nvnc\" -borderwidth 5 -font $bfont\n"
+" catch destroy {$icon_win}\n"
+" if {$icon_minimal} {\n"
+" set bw 1\n"
+" } else {\n"
+" set bw 5\n"
+" }\n"
+" set lab [get_icon_label]\n"
+" label $l -text $lab -borderwidth $bw -font $font\n"
" icon_win_cfg 0\n"
"\n"
-" pack $l\n"
+" set window_view_posted 0\n"
+" pack $l -fill both -expand 1\n"
" set menu \"$l.menu\"\n"
-" menu $menu -tearoff 0\n"
-" $menu add command -font $bfont -label \"Properties\" -command do_props\n"
-" $menu add command -font $bfont -label \"Help\" -command \"menu_help Tray\"\n"
+" menu $menu -tearoff 0 -postcommand {set window_view_posted 0}\n"
+" $menu add command -font $font -label \"Properties\" -command do_props\n"
+" $menu add command -font $font -label \"Help\" -command \"menu_help Tray\"\n"
" $menu add separator\n"
-" $menu add command -font $bfont -label \"New Client\" -command do_new_client\n"
-" $menu add command -font $bfont -label \"Disconnect All\" -command do_disconnect_all\n"
+" $menu add command -font $font -label \"New Client\" -command do_new_client\n"
+" $menu add command -font $font -label \"Disconnect All\" -command do_disconnect_all\n"
" $menu add separator\n"
-" $menu add command -font $bfont -label \"Stop x11vnc\" -command clean_icon_exit\n"
"\n"
-" bind . <Button-1> \"pmenu $menu %X %Y\"\n"
-" bind . <Button-3> \"pmenu $menu %X %Y\"\n"
-" bind $menu <Leave> \"after 200; $menu unpost\"\n"
-"\n"
-" if {$x11vnc_client_file != \"\" } {\n"
-" if ![file exists $x11vnc_client_file] {\n"
-" set fh [open $x11vnc_client_file \"w\"]\n"
-" puts $fh \"skip\"\n"
-" close $fh\n"
-" }\n"
-" if [file exists $x11vnc_client_file] {\n"
-" set client_tail [open \"|tail -f $x11vnc_client_file\" \"r\"]\n"
-" }\n"
+" set wv \"$menu.casc1\"\n"
+" catch {destroy $wv}\n"
+" menu $wv -tearoff 0 -font $ffont \\\n"
+" -postcommand {set window_view_posted 1}\n"
+" foreach val {full icon tray} {\n"
+" $wv add radiobutton -label \"$val\" \\\n"
+" -value \"$val\" -font $ffont \\\n"
+" -command \"do_var WindowView\" \\\n"
+" -variable menu_var(WindowView)\n"
" }\n"
+" $menu add cascade -font $font -label \"Window View\" -menu $wv\n"
"\n"
+" $menu add command -font $font -label \"Stop x11vnc\" -command clean_icon_exit\n"
+"\n"
+" bind $icon_win <ButtonPress-1> \"pmenu $menu %X %Y\"\n"
+" bind $icon_win <ButtonPress-3> \"pmenu $menu %X %Y\"\n"
" bind $icon_win <Enter> {set client_balloon_id [after 500 show_client_balloon]}\n"
" bind $icon_win <Button> {kill_client_balloon}\n"
" bind $icon_win <Leave> {kill_client_balloon}\n"
+" bind $icon_win <ButtonPress-2> {kill_client_balloon; show_client_balloon}\n"
+" bind $menu <Leave> \"lmenu $menu\"\n"
+" bind $menu <KeyPress-Escape> \"$menu unpost\"\n"
+"\n"
+" if {!$tray_embed || !$tray_running} {\n"
+" global x11vnc_gui_geom\n"
+" if {$x11vnc_gui_geom != \"\"} {\n"
+" set doit 1\n"
+" if {[regexp {x} $x11vnc_gui_geom]} {\n"
+" if {$gui_start_mode == \"full\"} {\n"
+" set doit 0\n"
+" }\n"
+" } \n"
+" if {$doit} {\n"
+" wm geometry . $x11vnc_gui_geom\n"
+" }\n"
+" }\n"
+" }\n"
+" wm deiconify .\n"
+"\n"
+" if {$client_tail == \"\" } {\n"
+" stop_watch on\n"
+" try_client_info_sock\n"
+" if {$client_tail == \"\" } {\n"
+" after 500\n"
+" try_client_info_sock\n"
+" }\n"
+" stop_watch off\n"
+" }\n"
+" if {$client_tail == \"\" } {\n"
+" set m \"\\n\"\n"
+" set m \"${m}tkx11vnc:\\n\"\n"
+" set m \"${m}\\n\"\n"
+" set m \"${m} Warning -- running in icon/tray mode but the\\n\"\n"
+" set m \"${m} connected client info channel from x11vnc is\\n\"\n"
+" set m \"${m} not working. The viewer client list and icon\\n\"\n"
+" set m \"${m} color indicator will not be accurate.\\n\"\n"
+" set m \"${m}\\n\"\n"
+" set m \"${m} You may need to restart \\\"x11vnc -gui tray ...\\\"\\n\"\n"
+" set m \"${m} for this to work properly.\\n\"\n"
+" set m \"${m}\\n\"\n"
+" textwin \"Warning\" \"Warning\" $m\n"
+" update\n"
+" }\n"
+"\n"
+" old_balloon\n"
"}\n"
"\n"
-"proc clean_icon_exit {} {\n"
-" global client_tail\n"
+"proc clean_client_tail {} {\n"
+" global client_tail client_tail_read\n"
" if [info exists client_tail] {\n"
" if {$client_tail != \"\"} {\n"
-" set p [pid $client_tail]\n"
+" set p \"\"\n"
+" catch {set p [pid $client_tail]}\n"
" if {$p != \"\"} {\n"
" catch {exec kill -TERM $p >/dev/null 2>/dev/null}\n"
" }\n"
@@ -3140,6 +3865,11 @@
" set client_tail \"\"\n"
" }\n"
" }\n"
+" set client_tail_read 0\n"
+"}\n"
+"\n"
+"proc clean_icon_exit {} {\n"
+" clean_client_tail\n"
" push_new_value \"stop\" \"stop\" 1 0\n"
" set_connected no\n"
" update\n"
@@ -3147,31 +3877,122 @@
" exit\n"
"}\n"
"\n"
-"proc make_widgets {} {\n"
-" global template \n"
+"proc make_gui {mode} {\n"
+" global icon_mode tray_embed full_win icon_win\n"
+" global top_widget_names x11vnc_gui_geom\n"
+" global gui_current_state make_gui_count\n"
+" global x11vnc_connect connected_to_x11vnc\n"
+" global x11_display\n"
+" global gui_start_mode\n"
+"\n"
+" incr make_gui_count\n"
+"\n"
+" if {$gui_start_mode == \"\"} {\n"
+" set gui_start_mode $mode\n"
+" }\n"
+"\n"
+" wm withdraw .\n"
+"\n"
+" set full_geom \"\"\n"
+" if {[winfo exists .full]} {\n"
+" catch {set full_geom [wm geometry .full]}\n"
+" }\n"
+"\n"
+" set fw .full\n"
+" set full_win $fw\n"
+" catch {pack forget $full_win}\n"
+" catch {pack forget $icon_win}\n"
+" catch {destroy $full_win}\n"
+" catch {destroy $icon_win}\n"
+"\n"
+" wm minsize . 1 1\n"
+"\n"
+" if {$mode == \"full\"} {\n"
+" frame $fw\n"
+" set icon_mode 0\n"
+"\n"
+" wm protocol . WM_DELETE_WINDOW \"destroy .; exit\"\n"
+" make_widgets $fw\n"
+"\n"
+" set w \".\"\n"
+" wm geometry $w \"\"\n"
+" if {$x11vnc_gui_geom != \"\"} {\n"
+" set doit 1\n"
+" if {[regexp {x} $x11vnc_gui_geom]} {\n"
+" if {$gui_start_mode != $mode} {\n"
+" set doit 0\n"
+" }\n"
+" }\n"
+" if {$doit} {\n"
+" wm geometry $w $x11vnc_gui_geom\n"
+" }\n"
+" }\n"
+" pack $fw -fill both -expand 1\n"
+"\n"
+" } elseif {$mode == \"icon\" || $mode == \"tray\"} {\n"
+"\n"
+" toplevel $fw\n"
+" wm withdraw $fw\n"
+"\n"
+" wm protocol $fw WM_DELETE_WINDOW \"wm withdraw .full\"\n"
+" wm protocol . WM_DELETE_WINDOW \"clean_icon_exit\"\n"
+" \n"
+" if {$mode == \"icon\"} {\n"
+" set tray_embed 0\n"
+" } elseif {$mode == \"tray\"} {\n"
+" set tray_embed 1\n"
+" }\n"
+" set icon_mode 1\n"
+" make_widgets $fw\n"
+" set w $fw\n"
+" make_icon\n"
+" wm geometry $fw \"\"\n"
+" wm geometry . \"\"\n"
+" } else {\n"
+" return\n"
+" }\n"
+" set_view_variable $mode\n"
+" set gui_current_state $mode\n"
+"\n"
+"\n"
+" wm deiconify .\n"
+" update idletasks\n"
+" wm minsize $w [winfo width $w] [winfo height $w]\n"
+" if {$mode == \"full\" && $make_gui_count > 1} {\n"
+" center_win .\n"
+" }\n"
+"\n"
+" if {$make_gui_count == 1} {\n"
+" if {$x11vnc_connect} {\n"
+" try_connect_and_query_all\n"
+" }\n"
+" } else {\n"
+" set_name \"RESTORE\"\n"
+" }\n"
+" set_widgets\n"
+"\n"
+" if {$mode == \"icon\" || $mode == \"tray\"} {\n"
+" setup_client_tail\n"
+" if {$mode == \"tray\"} {\n"
+" setup_tray_embed\n"
+" }\n"
+" }\n"
+"}\n"
+"\n"
+"proc make_widgets {top} {\n"
+" global template make_gui_count\n"
" global menu_b menu_m menu_count\n"
-" global item_opts item_bool item_case item_entry menu_var unset_str\n"
+" global item_opts item_bool item_case item_menu item_entry menu_var unset_str\n"
" global item_cascade\n"
" global info_label info_str x11_display vnc_display\n"
-" global text_area\n"
+" global text_area text_area_str\n"
" global entry_box entry_str entry_set entry_label entry_ok entry_browse\n"
" global entry_help entry_skip\n"
" global bfont ffont beginner_mode\n"
" global helptext helpremote helplabel\n"
-" global tray_mode icon_win props_win full_win\n"
-"\n"
-" if {$tray_mode} {\n"
-" set top \".advanced\"\n"
-" toplevel $top\n"
-" wm withdraw $top\n"
-" set full_win $top\n"
-" wm protocol $top WM_DELETE_WINDOW \"wm withdraw $top\"\n"
-" wm protocol . WM_DELETE_WINDOW \"clean_icon_exit\"\n"
-" make_icon\n"
-" } else {\n"
-" set top \"\"\n"
-" set full_win \".\"\n"
-" }\n"
+" global icon_mode icon_win props_win full_win\n"
+" global top_widget_names\n"
+"\n"
"\n"
" # Make the top label\n"
" set label_width 80\n"
@@ -3180,6 +4001,8 @@
" -anchor w -width $label_width -font $ffont\n"
" pack $info_label -side top -fill x -expand 0\n"
"\n"
+" set top_widget_names(info) $info_label\n"
+"\n"
" # Extract the Rows:\n"
" set row 0;\n"
" set colmax 0;\n"
@@ -3241,22 +4064,29 @@
" }\n"
" }\n"
" pack $f -side top -fill x\n"
+" set top_widget_names(menuframe) $f\n"
"\n"
" make_menu_items\n"
"\n"
" # Make the x11 and vnc display label bar:\n"
" set df \"$top.displayframe\"\n"
" frame $df -bd 1 -relief groove\n"
+" set top_widget_names(displayframe) $df\n"
"\n"
" set df_x11 \"$df.xdisplay\"\n"
-" no_x11_display\n"
"\n"
+" if {$make_gui_count == 1} {\n"
+" no_x11_display\n"
+" }\n"
" set lw [expr {$label_width / 2}]\n"
" label $df_x11 -textvariable x11_display -width $lw -anchor w \\\n"
" -font $ffont\n"
"\n"
" set df_vnc \"$df.vdisplay\"\n"
-" no_vnc_display\n"
+"\n"
+" if {$make_gui_count == 1} {\n"
+" no_vnc_display\n"
+" }\n"
" label $df_vnc -textvariable vnc_display -width $lw -anchor w \\\n"
" -font $ffont\n"
"\n"
@@ -3267,14 +4097,20 @@
" set text_area \"$top.text\"\n"
" text $text_area -height 12 -relief ridge -font $ffont\n"
" pack $text_area -side top -fill both -expand 1\n"
+" set top_widget_names(text) $text_area\n"
"\n"
"\n"
-" set str \"Click Help -> gui for overview.\"\n"
-" append_text \"\\n$str\\n\\n\"\n"
+" if {$text_area_str == \"\"} {\n"
+" set str \"Click Help -> gui for overview.\"\n"
+" append_text \"\\n$str\\n\\n\"\n"
+" } else {\n"
+" append_text $text_area_str\n"
+" }\n"
"\n"
" # Make entry box stuff\n"
" set ef \"$top.entryframe\"\n"
" frame $ef -bd 1 -relief groove\n"
+" set top_widget_names(entryframe) $ef\n"
"\n"
" # Entry Label\n"
" set ef_label \"$ef.label\"\n"
@@ -3328,24 +4164,24 @@
" set entry_label $ef_label\n"
" entry_disable\n"
"\n"
-" if {$top == \"\"} {\n"
-" set w \".\"\n"
-" } else {\n"
-" set w $top\n"
-" }\n"
-" update idletasks\n"
-" wm minsize $w [winfo width $w] [winfo height $w]\n"
"}\n"
"\n"
-"proc menu_bindings {} {\n"
-" bind Menu <<MenuSelect>> {\n"
+"proc menu_bindings {m} {\n"
+" set db 0\n"
+" if {$db} {puts \"menu_bindings $m\"}\n"
+"\n"
+" bind $m <<MenuSelect>> {\n"
"#syntax hilite bug \\\n"
"MenuSelect>>\n"
" set n [%W index active]\n"
+" set db 0\n"
+" if {$db} {puts stderr \"menu_bindings %W $n\"}\n"
" set label \" \"\n"
" if {$n != \"none\"} {\n"
" set str %W,$n\n"
" set which \"\"\n"
+"\n"
+" if {$db} {puts \"menu_bindings $str\"}\n"
" if {[info exists helplabel($str)]} {\n"
" set vname [format %%-16s $helplabel($str)]\n"
" set label \"Click (?) for help on: $vname\"\n"
@@ -3353,6 +4189,8 @@
" }\n"
" if {$which == \"\"} {\n"
" ;\n"
+" } elseif {$which == \"passwd\" || $which == \"viewpasswd\"} {\n"
+" ;\n"
" } elseif {[is_action $which]} {\n"
" if {[info exists menu_var($which)] \n"
" && $menu_var($which) != \"\"} {\n"
@@ -3403,14 +4241,30 @@
"proc stop_watch {onoff} {\n"
" global orig_cursor text_area entry_box\n"
"\n"
-" set widgets [list . $text_area $entry_box] \n"
+" set widgets [list .]\n"
+" if [info exists text_area] {\n"
+" if {$text_area != \"\"} {\n"
+" lappend widgets $text_area\n"
+" }\n"
+" }\n"
+" if [info exists entry_box] {\n"
+" if {$entry_box != \"\"} {\n"
+" lappend widgets $entry_box\n"
+" }\n"
+" }\n"
"\n"
" if {$onoff == \"on\"} {\n"
" foreach item $widgets {\n"
+" if {![winfo exists $item]} {\n"
+" continue\n"
+" }\n"
" $item config -cursor {watch}\n"
" }\n"
" } else {\n"
" foreach item $widgets {\n"
+" if {![winfo exists $item]} {\n"
+" continue\n"
+" }\n"
" $item config -cursor {}\n"
" }\n"
" }\n"
@@ -3621,6 +4475,7 @@
" }\n"
" lappend cmd \"2>\"\n"
" lappend cmd \"/dev/null\"\n"
+"# lappend cmd \"/tmp/nono\"\n"
"\n"
" if {0} {\n"
" set str [join $cmd]\n"
@@ -3632,9 +4487,12 @@
"\n"
" set output \"\"\n"
" menus_disable\n"
+"\n"
" stop_watch on\n"
" catch {set output [eval exec $cmd]}\n"
" stop_watch off\n"
+"#puts stderr [exec cat /tmp/nono]\n"
+"\n"
" menus_enable\n"
" if {$debug} {\n"
" if {[string length $output] > 100} {\n"
@@ -3699,13 +4557,150 @@
" }\n"
"}\n"
"\n"
+"proc set_view_variable {val} {\n"
+" global menu_var\n"
+" set menu_var(WindowView) $val\n"
+"}\n"
+"proc get_view_variable {} {\n"
+" global menu_var\n"
+" if {![info exists menu_var(WindowView)]} {\n"
+" set menu_var(WindowView) \"none\"\n"
+" }\n"
+" return $menu_var(WindowView)\n"
+"}\n"
+"\n"
+"proc change_view_state {} {\n"
+" global menu_var gui_current_state\n"
+"\n"
+" set new [get_view_variable]\n"
+"\n"
+" set old $gui_current_state\n"
+" #puts \"$old -> $new\"\n"
+"\n"
+" if {$old == $new} {\n"
+" return\n"
+" }\n"
+"\n"
+" if {$old == \"full\" || $old == \"icon\" || $old == \"tray\"} {\n"
+" ;\n"
+" } else {\n"
+" set old \"none\"\n"
+" }\n"
+"\n"
+" if {$new == \"full\" || $new == \"icon\" || $new == \"tray\"} {\n"
+" if {$old == \"tray\"} {\n"
+" # sigh XReparentWindow would be too easy...\n"
+" # undo_tray_embed\n"
+" restart_everything $new\n"
+" destroy .\n"
+" exit\n"
+" }\n"
+" make_gui $new\n"
+" } else {\n"
+" set_view_variable $old\n"
+" }\n"
+"}\n"
+"\n"
+"proc setup_client_tail {} {\n"
+" global client_tail\n"
+" if {$client_tail != \"\"} {\n"
+" fileevent $client_tail readable read_client_info\n"
+" }\n"
+"}\n"
+"\n"
+"proc setup_tray_embed {} {\n"
+" global icon_win\n"
+" update\n"
+" set w [winfo width .]\n"
+" set h [winfo height .]\n"
+" if {$w < 24} {\n"
+" set w 24\n"
+" }\n"
+" if {$h < 24} {\n"
+" set h 24\n"
+" }\n"
+" wm minsize . $w $h\n"
+" set wid [winfo id .] \n"
+" push_new_value \"remote-cmd\" \"remote-cmd\" \"trayembed:$wid\" 0\n"
+"}\n"
+"\n"
+"proc restart_everything {gui_mode} {\n"
+" global env gui_argv0 x11vnc_prog full_win\n"
+" if {$gui_mode == \"full\"} {\n"
+" set env(X11VNC_ICON_MODE) 0\n"
+" } elseif {$gui_mode == \"icon\"} {\n"
+" set env(X11VNC_ICON_MODE) 1\n"
+" } elseif {$gui_mode == \"tray\"} {\n"
+" if {![regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)]} {\n"
+" set env(X11VNC_ICON_MODE) \"TRAY\"\n"
+" }\n"
+" }\n"
+" puts stderr \"\"\n"
+" puts stderr \"tkx11vnc: restarting gui to leave tray mode.\"\n"
+" puts stderr \" new gui will be running in the background.\"\n"
+" puts stderr \" use kill(1) rather than Ctrl-C to kill it.\"\n"
+" puts stderr \"\"\n"
+" if {[info exists env(X11VNC_RESTART_DEPTH)]} {\n"
+" set n $env(X11VNC_RESTART_DEPTH)\n"
+" incr n\n"
+" set env(X11VNC_RESTART_DEPTH) $n\n"
+" } else {\n"
+" set env(X11VNC_RESTART_DEPTH) 0\n"
+" }\n"
+" set env(X11VNC_ICON_SETPASS) \"\"\n"
+"\n"
+" if {![info exists env(X11VNC_WISHCMD)]} {\n"
+" puts stderr \"failure in restart_everything.\"\n"
+" exit 1;\n"
+" }\n"
+"\n"
+" set code [exec $x11vnc_prog -printgui]\n"
+" if {[string length $code] < 20000} {\n"
+" puts stderr \"failure in restart_everything.\"\n"
+" exit 1;\n"
+" }\n"
+" set tmp \"/tmp/x11vnc[pid]\"\n"
+" file delete -force $tmp\n"
+" if {[file exists $tmp]} {\n"
+" puts stderr \"failure in restart_everything.\"\n"
+" exit 1;\n"
+" }\n"
+" set fh [open $tmp \"a\"]\n"
+" if {![file owned $tmp]} {\n"
+" puts stderr \"failure in restart_everything.\"\n"
+" exit 1;\n"
+" }\n"
+" file attributes $tmp -permissions \"0400\"\n"
+" puts $fh $code\n"
+" close $fh\n"
+"\n"
+" #puts stderr [exec ls -l $tmp]\n"
+"\n"
+" wm withdraw .\n"
+" catch {wm withdraw $full_win}\n"
+" update\n"
+"\n"
+" exec $env(X11VNC_WISHCMD) $tmp &\n"
+" after 2000\n"
+" file delete -force $tmp\n"
+" \n"
+" destroy .\n"
+" exit\n"
+"}\n"
+"\n"
+"proc undo_tray_embed {} {\n"
+" global icon_win\n"
+" set wid [winfo id .] \n"
+" push_new_value \"remote-cmd\" \"remote-cmd\" \"trayunembed:$wid\" 0\n"
+"}\n"
+"\n"
"############################################################################\n"
"# main:\n"
"\n"
"global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;\n"
-"global x11vnc_client_file\n"
+"global x11vnc_client_file x11vnc_gui_geom x11vnc_started vnc_url\n"
"global x11vnc_auth_file x11vnc_connect_file beginner_mode simple_gui_created\n"
-"global helpall helptext helpremote helplabel hostname;\n"
+"global helpall helptext helpremote helplabel hostname osname\n"
"global all_settings reply_xdisplay always_update\n"
"global max_text_height max_text_width\n"
"global menu_var unset_str menus_disabled\n"
@@ -3713,15 +4708,21 @@
"global connected_to_x11vnc\n"
"global delay_sleep extra_sleep extra_sleep_split\n"
"global cache_all_query_vars\n"
-"global last_query_all_time query_all_freq\n"
-"global tray_mode tray_embed_id client_tail\n"
+"global last_query_all_time query_all_freq client_tail client_tail_read\n"
+"global icon_mode tray_embed tray_running icon_setpasswd icon_embed_id\n"
+"global icon_noadvanced icon_minimal\n"
+"global make_gui_count text_area_str\n"
+"global gui_argv0 gui_start_mode\n"
"\n"
"set unset_str \"(unset)\"\n"
+"set vnc_url $unset_str\n"
"set connected_to_x11vnc 0\n"
"set menus_disabled 0\n"
"set max_text_height 40\n"
"set max_text_width 90\n"
"set bfont \"-adobe-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*\"\n"
+"set sfont \"-adobe-helvetica-bold-r-*-*-*-100-*-*-*-*-*-*\"\n"
+"set snfont \"-adobe-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*\"\n"
"set ffont \"fixed\"\n"
"set help_indent 24;\n"
"set reply_xdisplay \"\"\n"
@@ -3731,12 +4732,23 @@
"set query_all_freq 120\n"
"set last_query_all_time [clock seconds]\n"
"set client_tail \"\"\n"
+"set client_tail_read 0\n"
+"set make_gui_count 0\n"
+"set text_area_str \"\"\n"
+"set gui_argv0 $argv0\n"
+"set gui_start_mode \"\"\n"
"\n"
"# these are no longer used under x11vnc -sync:\n"
"set delay_sleep 350\n"
"set extra_sleep 1000\n"
"set extra_sleep_split 4\n"
"\n"
+"if {$tk_version < 8.0} {\n"
+" puts stderr \"\"\n"
+" puts stderr \"*** tkx11vnc: tk version is old $tk_version, please use 8.0 or higher.\"\n"
+" puts stderr \"*** will try to continue with reduced functionality...\"\n"
+" puts stderr \"\"\n"
+"}\n"
"if {[regexp {^[34]} $tk_version] || $tk_version == \"8.0\"} {\n"
" set old_labels 1\n"
"} else {\n"
@@ -3765,7 +4777,34 @@
" exit 0\n"
"}\n"
"\n"
+"\n"
+"set_view_variable \"full\"\n"
+"\n"
+"#puts [exec env | grep X11VNC]\n"
+"\n"
"# Read environment for clues:\n"
+"\n"
+"set x11vnc_client_file \"\";\n"
+"if {[info exists env(X11VNC_CLIENT_FILE)]} {\n"
+" set x11vnc_client_file $env(X11VNC_CLIENT_FILE);\n"
+" set file $x11vnc_client_file\n"
+"\n"
+" set client_tail \"\"\n"
+" if {[file exists $file] && [file isfile $file]} {\n"
+" if {[file readable $file] && [file owned $file]} {\n"
+" set client_tail [open \"|tail -f $x11vnc_client_file\" \"r\"]\n"
+" }\n"
+" }\n"
+" if {$client_tail != \"\"} {\n"
+" gets $client_tail tmp\n"
+" if [eof $client_tail] {\n"
+" clean_client_tail\n"
+" set client_tail \"\"\n"
+" }\n"
+" }\n"
+" catch {file delete -force $x11vnc_client_file}\n"
+"}\n"
+"\n"
"if {[info exists env(X11VNC_PROG)]} {\n"
" set x11vnc_prog $env(X11VNC_PROG);\n"
"} else {\n"
@@ -3784,16 +4823,21 @@
" set x11vnc_connect 0;\n"
"}\n"
"\n"
+"if {[info exists env(X11VNC_GUI_GEOM)]} {\n"
+" set x11vnc_gui_geom $env(X11VNC_GUI_GEOM);\n"
+"} else {\n"
+" set x11vnc_gui_geom \"\"\n"
+"}\n"
+"\n"
"if {[info exists env(X11VNC_CONNECT_FILE)]} {\n"
" set x11vnc_connect_file $env(X11VNC_CONNECT_FILE);\n"
"} else {\n"
" set x11vnc_connect_file \"\";\n"
"}\n"
"\n"
-"if {[info exists env(X11VNC_CLIENT_FILE)]} {\n"
-" set x11vnc_client_file $env(X11VNC_CLIENT_FILE);\n"
-"} else {\n"
-" set x11vnc_client_file \"\";\n"
+"set x11vnc_started 0\n"
+"if {[info exists env(X11VNC_STARTED)]} {\n"
+" set x11vnc_started 1\n"
"}\n"
"\n"
"if {[info exists env(X11VNC_XDISPLAY)]} {\n"
@@ -3801,6 +4845,7 @@
" set x11vnc_connect 1\n"
"\n"
"} elseif {$argv != \"\" && [regexp {:[0-9]} $argv]} {\n"
+" set env(X11VNC_XDISPLAY) \"$argv\"\n"
" set x11vnc_xdisplay \"$argv\"\n"
" set x11vnc_connect 1\n"
"\n"
@@ -3823,21 +4868,55 @@
" set beginner_mode 0\n"
"}\n"
"\n"
-"set tray_mode 0\n"
-"if {[info exists env(X11VNC_TRAY_MODE)]} {\n"
-" set tray_mode 1\n"
+"set icon_mode 0\n"
+"set tray_embed 0\n"
+"set tray_running 0\n"
+"if {![info exists env(X11VNC_ICON_MODE)]} {\n"
+" set icon_mode 0\n"
+"} elseif {$env(X11VNC_ICON_MODE) == \"\" || $env(X11VNC_ICON_MODE) == \"0\"} {\n"
+" set icon_mode 0\n"
"} else {\n"
-" set tray_mode 0\n"
+" set icon_mode 1\n"
+" set_view_variable \"icon\"\n"
+" if [regexp -nocase {TRAY} $env(X11VNC_ICON_MODE)] {\n"
+" set tray_embed 1\n"
+" }\n"
+" if [regexp -nocase {RUNNING} $env(X11VNC_ICON_MODE)] {\n"
+" set tray_running 1\n"
+" }\n"
+"}\n"
+"set icon_setpasswd 0\n"
+"if {[info exists env(X11VNC_ICON_SETPASS)]} {\n"
+" if {$env(X11VNC_ICON_SETPASS) != \"\"} {\n"
+" set icon_setpasswd 1\n"
+" }\n"
"}\n"
-"set tray_mode 1\n"
"\n"
-"if {[info exists env(X11VNC_TRAY_EMBED_ID)]} {\n"
-" set tray_embed_id $env(X11VNC_TRAY_EMBED_ID)\n"
+"set icon_noadvanced 0\n"
+"if {[info exists env(X11VNC_ICON_NOADVANCED)]} {\n"
+" set icon_noadvanced 1\n"
+"}\n"
+"\n"
+"set icon_minimal 0\n"
+"if {[info exists env(X11VNC_ICON_MINIMAL)]} {\n"
+" set icon_minimal 1\n"
+"}\n"
+"\n"
+"if {[info exists env(X11VNC_ICON_EMBED_ID)]} {\n"
+" set icon_embed_id $env(X11VNC_ICON_EMBED_ID)\n"
"} else {\n"
-" set tray_embed_id \"\"\n"
+" set icon_embed_id \"\"\n"
"}\n"
"\n"
+"\n"
"set hostname [exec uname -n]\n"
+"set osname [exec uname]\n"
+"\n"
+"if {[regexp -nocase {IRIX} $osname]} {\n"
+" # IRIX \"fixed\" font is huge and doublespaced... \n"
+" set ffont $snfont\n"
+"}\n"
+"\n"
"#puts [exec env]\n"
"#puts \"x11vnc_xdisplay: $x11vnc_xdisplay\"\n"
"\n"
@@ -3860,18 +4939,28 @@
"set_template\n"
"\n"
"set_name \"tkx11vnc\"\n"
-"make_widgets;\n"
"\n"
-"menu_bindings;\n"
"key_bindings;\n"
"\n"
-"if {$x11vnc_connect} {\n"
-" try_connect_and_query_all\n"
-"}\n"
-"set_widgets\n"
-"\n"
-"if {$tray_mode && $client_tail != \"\"} {\n"
-" fileevent $client_tail readable read_client_info\n"
+"if {$icon_mode} {\n"
+" if {$tray_embed} {\n"
+" make_gui \"tray\"\n"
+" } else {\n"
+" make_gui \"icon\"\n"
+" }\n"
+" old_balloon\n"
+" if {$icon_setpasswd} {\n"
+" set m \"You must specify a Session\\n\" \n"
+" set m \"${m}Password before VNC clients can\\n\" \n"
+" set m \"${m}connect. Enter one in the Password\\n\" \n"
+" set m \"${m}field and then Press \\\"OK\\\". This\\n\" \n"
+" set m \"${m}password is not stored, it is only\\n\" \n"
+" set m \"${m}used for this x11vnc session.\\n\" \n"
+" do_props $m\n"
+" push_new_value \"unlock\" \"unlock\" 1 0\n"
+" }\n"
+"} else {\n"
+" make_gui \"full\"\n"
"}\n"
"\n"
"# main loop.\n"
diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1
index d5243da..ee330b1 100644
--- a/x11vnc/x11vnc.1
+++ b/x11vnc/x11vnc.1
@@ -2,7 +2,7 @@
.TH X11VNC "1" "July 2005" "x11vnc " "User Commands"
.SH NAME
x11vnc - allow VNC connections to real X11 displays
- version: 0.7.2, lastmod: 2005-07-01
+ version: 0.7.2, lastmod: 2005-07-06
.SH SYNOPSIS
.B x11vnc
[OPTION]...
@@ -1378,6 +1378,11 @@ Disable any use of the RECORD extension. This is
currently used by the \fB-scrollcopyrect\fR scheme and to
monitor X server grabs.
.PP
+\fB-debug_grabs\fR
+.IP
+Turn on debugging info printout with respect to
+XGrabServer() deadlock for \fB-scrollcopyrect__mode_.\fR
+.PP
\fB-pointer_mode\fR \fIn\fR
.IP
Various pointer motion update schemes. "\fB-pm\fR" is
@@ -1708,9 +1713,10 @@ to start up both the gui and x11vnc with the gui showing
up on the X display in the environment variable DISPLAY.
.IP
"gui-opts" can be a comma separated list of items.
-Currently there are these types of items: 1) a gui mode,
-a 2) gui "simplicity", 3) the X display the gui
-should display on, and 4) a "tray" (or icon) mode.
+Currently there are these types of items: 1) a gui
+mode, a 2) gui "simplicity", 3) the X display the
+gui should display on, 4) a "tray" or "icon" mode,
+and 5) a gui geometry.
.IP
1) The gui mode can be "start", "conn", or "wait"
"start" is the default mode above and is not required.
@@ -1743,22 +1749,44 @@ tries \fB-display\fR and then DISPLAY. For example, "x11vnc
x11vnc polling :0 and display the gui on otherhost:0
The "tray" mode below reverses this preference.
.IP
-4) When "tray" is specified, the gui presents itself
-as a small icon with behavior similar to a "system
-tray" or "dock" applet. The color of the icon
-indicates status (connected clients) and there is also a
-balloon status. Clicking on the icon gives a menu from
-which properties, etc, can be set and the full gui is
-available under "Advanced". To be fully functional,
-the gui mode should be "start" (the default). At some
-point it is hoped the icon can be automatically embedded
-in common destkop trays/docks. Currently one can only
-embed it in a window via, e.g., "tray=0x3600028".
-Otherwise the icon is just a normal standalone window.
-.IP
-Examples: "x11vnc \fB-gui",\fR "x11vnc \fB-gui\fR ez"
-"x11vnc \fB-gui\fR localhost:10", "x11vnc \fB-gui\fR conn,host:0"
-"x11vnc \fB-gui\fR tray,ez"
+4) When "tray" or "icon" is specified, the gui
+presents itself as a small icon with behavior typical
+of a "system tray" or "dock" applet. The color
+of the icon indicates status (connected clients) and
+there is also a balloon status. Clicking on the icon
+gives a menu from which properties, etc, can be set and
+the full gui is available under "Advanced". To be
+fully functional, the gui mode should be "start"
+(the default).
+.IP
+For "icon" the gui just a small standalone window.
+For "tray" it will attempt to embed itself in the
+"system tray". If "=setpass" is appended then
+at startup the X11 user will be prompted to set the
+VNC session password. If =<hexnumber> is appended
+that icon will attempt to embed itself in the window
+given by hexnumber. Use =noadvanced to disable the
+full gui. (To supply more than one, use "+" sign).
+E.g. \fB-gui\fR tray=setpass and \fB-gui\fR icon=0x3600028
+.IP
+5) When "geom=+X+Y" is specified, that geometry
+is passed to the gui toplevel. This is the icon in
+icon/tray mode, or the full gui otherwise. You can
+also specify width and height, i.e. WxH+X+Y, but it
+is not recommended. In "tray" mode the geometry is
+ignored unless the system tray manager does not seem
+to be running. One could imagine using something like
+"\fB-gui\fR \fItray,geom=+4000+4000\fR" with a display manager
+to keep the gui invisible until someone logs in...
+.IP
+More icon tricks, "icon=minimal" gives an icon just
+with the VNC display number. You can also set the font
+with "iconfont=...". The following could be useful:
+"\fB-gui\fR \fIicon=minimal,iconfont=5x8,geom=24x10+0-0\fR"
+.IP
+General examples of the \fB-gui\fR option: "x11vnc \fB-gui",\fR
+"x11vnc \fB-gui\fR ez" "x11vnc \fB-gui\fR localhost:10",
+"x11vnc \fB-gui\fR conn,host:0", "x11vnc \fB-gui\fR tray,ez"
.IP
If you do not intend to start x11vnc from the gui
(i.e. just remote control an existing one), then the
@@ -2206,6 +2234,10 @@ debug_tiles enable \fB-debug_tiles\fR
.IP
nodebug_tiles disable \fB-debug_tiles\fR
.IP
+debug_grabs enable \fB-debug_grabs\fR
+.IP
+nodebug_grabs disable \fB-debug_grabs\fR
+.IP
dbg enable \fB-dbg\fR crash shell
.IP
nodbg disable \fB-dbg\fR crash shell
@@ -2266,10 +2298,10 @@ 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
+scale_cursor viewonly noviewonly shared noshared forever
+noforever once timeout deny lock nodeny unlock connect
+allowonce allow localhost nolocalhost listen lookup
+nolookup accept popup gone shm noshm flipbyteorder
noflipbyteorder onetile noonetile solid_color solid
nosolid blackout xinerama noxinerama xtrap noxtrap
xrandr noxrandr xrandr_mode padgeom quiet q noquiet
@@ -2300,8 +2332,8 @@ nodontdisconnect desktop debug_xevents nodebug_xevents
debug_xevents debug_xdamage nodebug_xdamage
debug_xdamage debug_wireframe nodebug_wireframe
debug_wireframe debug_scroll nodebug_scroll debug_scroll
-debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg
-nodbg noremote
+debug_tiles dbt nodebug_tiles nodbt debug_tiles
+debug_grabs nodebug_grabs dbg nodbg noremote
.IP
aro= display vncdisplay desktopname guess_desktop
http_url auth users rootshift clipshift scale_str
diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c
index 04e02e8..0d30ef8 100644
--- a/x11vnc/x11vnc.c
+++ b/x11vnc/x11vnc.c
@@ -382,7 +382,7 @@ double xdamage_scheduled_mark = 0.0;
sraRegionPtr xdamage_scheduled_mark_region = NULL;
/* date +'lastmod: %Y-%m-%d' */
-char lastmod[] = "0.7.2 lastmod: 2005-07-01";
+char lastmod[] = "0.7.2 lastmod: 2005-07-06";
int hack_val = 0;
/* X display info */
@@ -593,6 +593,7 @@ int count_added_keycodes(void);
double dtime(double *);
double dtime0(double *);
double dnow(void);
+double dnowx(void);
void initialize_blackouts(char *);
void initialize_blackouts_and_xinerama(void);
@@ -615,6 +616,7 @@ void initialize_xinerama(void);
void initialize_xfixes(void);
void initialize_xdamage(void);
int valid_window(Window, XWindowAttributes *, int);
+Window parent_window(Window, char**);
int xtranslate(Window, Window, int, int, int*, int*, Window*, int);
void create_xdamage_if_needed(void);
void destroy_xdamage_if_needed(void);
@@ -749,6 +751,8 @@ void push_black_screen(int);
void push_sleep(int);
void refresh_screen(int);
+int tray_embed(Window, int);
+int tray_manager_running(Display *, Window *);
/* -- options.h -- */
/*
@@ -841,11 +845,22 @@ 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 */
-
-int tray_mode = 0; /* hack for -gui tray */
-char *tray_mode_file = NULL;
-char *tray_mode_params = NULL;
-FILE *tray_mode_fh = NULL;
+char *gui_geometry = NULL;
+
+int icon_mode = 0; /* hack for -gui tray */
+int icon_in_tray = 0;
+char *icon_mode_file = NULL;
+char *icon_mode_params = NULL;
+char *icon_mode_embed_id = NULL;
+char *icon_mode_font = NULL;
+FILE *icon_mode_fh = NULL;
+#define ICON_MODE_SOCKS 16
+int icon_mode_socks[ICON_MODE_SOCKS];
+
+int tray_manager_ok = 0;
+Window tray_request = None;
+Window tray_window = None;
+int tray_unembed = 0;
int use_modifier_tweak = 1; /* use the shift/altgr modifier tweak */
int use_iso_level3 = 0; /* ISO_Level3_Shift instead of Mode_switch */
@@ -864,6 +879,7 @@ int debug_xevents = 0; /* -R debug_xevents:1 */
int debug_xdamage = 0; /* -R debug_xdamage:1 or 2 ... */
int debug_wireframe = 0;
int debug_tiles = 0;
+int debug_grabs = 0;
int xtrap_input = 0; /* -xtrap for user input insertion */
int xinerama = 0; /* -xinerama */
@@ -2940,6 +2956,12 @@ void disable_grabserver(Display *in_dpy, int change) {
int ok = 0;
static int didmsg = 0;
+ if (debug_grabs) {
+ fprintf(stderr, "disable_grabserver/%d %.5f\n",
+ xserver_grabbed, dnowx());
+ didmsg = 0;
+ }
+
if (! xtrap_input) {
if (XTestGrabControl_wr(in_dpy, True)) {
if (change) {
@@ -3029,6 +3051,11 @@ void xrecord_grabserver(int start) {
XErrorHandler old_handler = NULL;
int rc;
+ if (debug_grabs) {
+ fprintf(stderr, "xrecord_grabserver%d/%d %.5f\n",
+ xserver_grabbed, start, dnowx());
+ }
+
if (! gdpy_ctrl || ! gdpy_data) {
return;
}
@@ -3075,6 +3102,9 @@ void xrecord_grabserver(int start) {
XSetErrorHandler(old_handler);
XFlush(gdpy_data);
#endif
+ if (debug_grabs) {
+ fprintf(stderr, "xrecord_grabserver-done: %.5f\n", dnowx());
+ }
}
void initialize_xrecord(void) {
@@ -3165,6 +3195,11 @@ void initialize_xrecord(void) {
void shutdown_xrecord(void) {
#if LIBVNCSERVER_HAVE_RECORD
+ if (debug_grabs) {
+ fprintf(stderr, "shutdown_xrecord%d %.5f\n",
+ xserver_grabbed, dnowx());
+ }
+
if (rr_CA) XFree(rr_CA);
if (rr_CW) XFree(rr_CW);
if (rr_GS) XFree(rr_GS);
@@ -3208,6 +3243,10 @@ void shutdown_xrecord(void) {
X_UNLOCK;
#endif
use_xrecord = 0;
+
+ if (debug_grabs) {
+ fprintf(stderr, "shutdown_xrecord-done: %.5f\n", dnowx());
+ }
}
int xrecord_skip_keysym(rfbKeySym keysym) {
@@ -4190,6 +4229,8 @@ void record_grab(XPointer ptr, XRecordInterceptData *rec_data) {
xReq *req;
int db = 0;
+ if (debug_grabs) db = 1;
+
/* should handle control msgs, start/stop/etc */
if (rec_data->category == XRecordStartOfData) {
;
@@ -4246,7 +4287,7 @@ void check_xrecord_grabserver(void) {
return;
}
-if (0) dtime0(&d);
+ dtime0(&d);
XFlush(gdpy_ctrl);
for (i=0; i<max; i++) {
last_val = xserver_grabbed;
@@ -4260,7 +4301,7 @@ if (0) dtime0(&d);
if (cnt) {
XFlush(gdpy_ctrl);
}
-if (0) {
+if (debug_grabs && cnt > 0) {
d = dtime(&d);
fprintf(stderr, "check_xrecord_grabserver: cnt=%d i=%d %.4f\n", cnt, i, d);
}
@@ -4469,7 +4510,7 @@ if (0) db = 1;
check_xrecord_grabserver();
X_UNLOCK;
if (xserver_grabbed) {
-if (db) fprintf(stderr, "xrecord_watch: %d/%d out xserver_grabbed\n", start, setby);
+if (db || debug_grabs) fprintf(stderr, "xrecord_watch: %d/%d out xserver_grabbed\n", start, setby);
return;
}
}
@@ -4477,7 +4518,7 @@ if (db) fprintf(stderr, "xrecord_watch: %d/%d out xserver_grabbed\n", start, se
#if LIBVNCSERVER_HAVE_RECORD
if (! start) {
int shut_reopen = 2, shut_time = 25;
-if (db) fprintf(stderr, "XRECORD OFF: %d/%d %.4f\n", xrecording, setby, now - x11vnc_start);
+if (db || debug_grabs) fprintf(stderr, "XRECORD OFF: %d/%d %.4f\n", xrecording, setby, now - x11vnc_start);
xrecording = 0;
if (! rc_scroll) {
xrecord_focus_window = None;
@@ -4592,7 +4633,7 @@ if (db > 1) fprintf(stderr, "=== disab-scroll 0x%lx 0x%lx\n", rc_scroll, rcs_scr
rcs_scroll = 0;
return;
}
-if (db) fprintf(stderr, "XRECORD ON: %d/%d %.4f\n", xrecording, setby, now - x11vnc_start);
+if (db || debug_grabs) fprintf(stderr, "XRECORD ON: %d/%d %.4f\n", xrecording, setby, now - x11vnc_start);
if (xrecording) {
return;
@@ -4893,15 +4934,15 @@ void clean_shm(int quick) {
}
}
-void clean_tray_mode(void) {
- if (tray_mode && tray_mode_fh) {
- fprintf(tray_mode_fh, "quit\n");
- fflush(tray_mode_fh);
- fclose(tray_mode_fh);
- tray_mode_fh = NULL;
- if (tray_mode_file) {
- unlink(tray_mode_file);
- tray_mode_file = NULL;
+void clean_icon_mode(void) {
+ if (icon_mode && icon_mode_fh) {
+ fprintf(icon_mode_fh, "quit\n");
+ fflush(icon_mode_fh);
+ fclose(icon_mode_fh);
+ icon_mode_fh = NULL;
+ if (icon_mode_file) {
+ unlink(icon_mode_file);
+ icon_mode_file = NULL;
}
}
}
@@ -4912,8 +4953,8 @@ void clean_tray_mode(void) {
void clean_up_exit (int ret) {
exit_flag = 1;
- if (tray_mode) {
- clean_tray_mode();
+ if (icon_mode) {
+ clean_icon_mode();
}
/* remove the shm areas: */
@@ -5172,8 +5213,8 @@ void interrupted (int sig) {
X_UNLOCK;
- if (tray_mode) {
- clean_tray_mode();
+ if (icon_mode) {
+ clean_icon_mode();
}
/* remove the shm areas with quick=1: */
clean_shm(1);
@@ -5207,6 +5248,27 @@ void interrupted (int sig) {
}
}
+Window parent_window(Window win, char **name) {
+ Window r, parent;
+ Window *list;
+ unsigned int nchild;
+
+ if (name != NULL) {
+ *name = NULL;
+ }
+
+ if (! XQueryTree(dpy, win, &r, &parent, &list, &nchild)) {
+ return None;
+ }
+ if (list) {
+ XFree(list);
+ }
+ if (parent && name) {
+ XFetchName(dpy, parent, name);
+ }
+ return parent;
+}
+
/* trapping utility to check for a valid window: */
int valid_window(Window win, XWindowAttributes *attr_ret, int bequiet) {
XErrorHandler old_handler;
@@ -5219,6 +5281,10 @@ int valid_window(Window win, XWindowAttributes *attr_ret, int bequiet) {
pattr = attr_ret;
}
+ if (win == None) {
+ return 0;
+ }
+
trapped_xerror = 0;
old_handler = XSetErrorHandler(trap_xerror);
if (XGetWindowAttributes(dpy, win, pattr)) {
@@ -6668,6 +6734,10 @@ void read_vnc_connect_prop(void) {
vnc_connect_str[VNC_CONNECT_MAX] = '\0';
if (! db) {
;
+ } else if (strstr(vnc_connect_str, "ans=stop:N/A,ans=quit:N/A,ans=")) {
+ ;
+ } else if (strstr(vnc_connect_str, "qry=stop,quit,exit")) {
+ ;
} else if (strstr(vnc_connect_str, "cmd=") &&
strstr(vnc_connect_str, "passwd")) {
rfbLog("read VNC_CONNECT\n");
@@ -6816,10 +6886,136 @@ enum rfbNewClientAction new_client(rfbClientPtr client) {
return(RFB_CLIENT_ACCEPT);
}
+void start_client_info_sock(char *host_port_cookie) {
+ char *host = NULL, *cookie = NULL, *p;
+ char *str = strdup(host_port_cookie);
+ int i, port, sock, next = -1;
+ static time_t start_time[ICON_MODE_SOCKS];
+ time_t oldest = 0;
+ int db = 0;
+
+ for (i = 0; i < ICON_MODE_SOCKS; i++) {
+ if (icon_mode_socks[i] < 0) {
+ next = i;
+ break;
+ }
+ if (oldest == 0 || start_time[i] < oldest) {
+ next = i;
+ oldest = start_time[i];
+ }
+ }
+
+ p = strtok(str, ":");
+ i = 0;
+ while (p) {
+ if (i == 0) {
+ host = strdup(p);
+ } else if (i == 1) {
+ port = atoi(p);
+ } else if (i == 2) {
+ cookie = strdup(p);
+ }
+ i++;
+ p = strtok(NULL, ":");
+ }
+ free(str);
+
+ if (db) fprintf(stderr, "%s/%d/%s next=%d\n", host, port, cookie, next);
+
+ if (host && port && cookie) {
+ if (*host == '\0') {
+ free(host);
+ host = strdup("localhost");
+ }
+ sock = rfbConnectToTcpAddr(host, port);
+ if (sock < 0) {
+ usleep(200 * 1000);
+ sock = rfbConnectToTcpAddr(host, port);
+ }
+ if (sock >= 0) {
+ char *lst = list_clients();
+ icon_mode_socks[next] = sock;
+ start_time[next] = time(0);
+ write(sock, "COOKIE:", strlen("COOKIE:"));
+ write(sock, cookie, strlen(cookie));
+ write(sock, "\n", strlen("\n"));
+ write(sock, "none\n", strlen("none\n"));
+ write(sock, "none\n", strlen("none\n"));
+ write(sock, lst, strlen(lst));
+ write(sock, "\n", strlen("\n"));
+ if (db) {
+ fprintf(stderr, "list: %s\n", lst);
+ }
+ free(lst);
+ rfbLog("client_info_sock to: %s:%d\n", host, port);
+ } else {
+ rfbLog("failed client_info_sock: %s:%d\n", host, port);
+ }
+ } else {
+ rfbLog("malformed client_info_sock: %s\n", host_port_cookie);
+ }
+
+ if (host) free(host);
+ if (cookie) free(cookie);
+}
+
+void send_client_info(char *str) {
+ int i;
+ static char *pstr = NULL;
+ static int len = 128;
+
+ if (!str || strlen(str) == 0) {
+ return;
+ }
+
+ if (!pstr) {
+ pstr = (char *)malloc(len);
+ }
+ if (strlen(str) + 2 > (size_t) len) {
+ free(pstr);
+ len *= 2;
+ pstr = (char *)malloc(len);
+ }
+ strcpy(pstr, str);
+ strcat(pstr, "\n");
+
+ if (icon_mode_fh) {
+ fprintf(icon_mode_fh, "%s", pstr);
+ fflush(icon_mode_fh);
+ }
+
+ for (i=0; i<ICON_MODE_SOCKS; i++) {
+ int len, n, sock = icon_mode_socks[i];
+ char *buf = pstr;
+
+ if (sock < 0) {
+ continue;
+ }
+
+ len = strlen(pstr);
+ while (len > 0) {
+ n = write(sock, buf, len);
+ if (n > 0) {
+ buf += n;
+ len -= n;
+ continue;
+ }
+
+ if (n < 0 && errno == EINTR) {
+ continue;
+ }
+ close(sock);
+ icon_mode_socks[i] = -1;
+ break;
+ }
+ }
+}
+
void check_new_clients(void) {
static int last_count = 0;
rfbClientIteratorPtr iter;
rfbClientPtr cl;
+ int i, send_info = 0;
if (client_count == last_count) {
return;
@@ -6835,10 +7031,7 @@ void check_new_clients(void) {
return;
}
if (! client_count) {
- if (tray_mode_fh) {
- fprintf(tray_mode_fh, "none\n");
- fflush(tray_mode_fh);
- }
+ send_client_info("none");
return;
}
@@ -6868,10 +7061,18 @@ void check_new_clients(void) {
}
rfbReleaseClientIterator(iter);
- if (tray_mode_fh) {
+ if (icon_mode_fh) {
+ send_info++;
+ }
+ for (i = 0; i < ICON_MODE_SOCKS; i++) {
+ if (send_info || icon_mode_socks[i] >= 0) {
+ send_info++;
+ break;
+ }
+ }
+ if (send_info) {
char *str = list_clients();
- fprintf(tray_mode_fh, "%s\n", str);
- fflush(tray_mode_fh);
+ send_client_info(str);
free(str);
}
}
@@ -11777,6 +11978,16 @@ void check_xevents(void) {
last_bell = now;
check_bell_event();
}
+ if (tray_request != None) {
+ static time_t last_tray_request = 0;
+ if (now > last_tray_request + 2) {
+ last_tray_request = now;
+ if (tray_embed(tray_request, tray_unembed)) {
+ tray_window = tray_request;
+ tray_request = None;
+ }
+ }
+ }
#ifndef DEBUG_XEVENTS
#define DEBUG_XEVENTS 1
@@ -13229,9 +13440,9 @@ char *process_remote_cmd(char *cmd, int stringonly) {
}
p += strlen("accept:");
if (safe_remote_only) {
- if (tray_mode && !strcmp(p, "")) {
+ if (icon_mode && !strcmp(p, "")) {
;
- } else if (tray_mode && !strcmp(p, "popup")) {
+ } else if (icon_mode && !strcmp(p, "popup")) {
;
} else {
rfbLog("unsafe: %s\n", p);
@@ -15214,6 +15425,21 @@ char *process_remote_cmd(char *cmd, int stringonly) {
debug_tiles = atoi(p);
rfbLog("set debug_tiles to: %d\n", debug_tiles);
+ } else if (!strcmp(p, "debug_grabs")) {
+ if (query) {
+ snprintf(buf, bufn, "ans=%s:%d", p, debug_grabs);
+ goto qry;
+ }
+ debug_grabs = 1;
+ rfbLog("set debug_grabs to: %d\n", debug_grabs);
+ } else if (!strcmp(p, "nodebug_grabs")) {
+ if (query) {
+ snprintf(buf, bufn, "ans=%s:%d", p, !debug_grabs);
+ goto qry;
+ }
+ debug_grabs = 0;
+ rfbLog("set debug_grabs to: %d\n", debug_grabs);
+
} else if (!strcmp(p, "dbg")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, crash_debug);
@@ -15248,7 +15474,18 @@ char *process_remote_cmd(char *cmd, int stringonly) {
rfbLog("remote_cmd: disabling remote commands.\n");
accept_remote_cmds = 0; /* cannot be turned back on. */
- } else if (tray_mode && !query && strstr(p, "passwd") == p) { /* skip-cmd-list */
+ } else if (strstr(p, "client_info_sock") == p) { /* skip-cmd-list */
+ NOTAPP
+ p += strlen("client_info_sock:");
+ if (*p != '\0') {
+ start_client_info_sock(p);
+ }
+
+ } else if (strstr(p, "noop") == p) {
+ NOTAPP
+ rfbLog("remote_cmd: noop\n");
+
+ } else if (icon_mode && !query && strstr(p, "passwd") == p) { /* skip-cmd-list */
char **passwds_new = (char **) malloc(3*sizeof(char *));
char **passwds_old = (char **) screen->authPasswdData;
@@ -15272,7 +15509,7 @@ char *process_remote_cmd(char *cmd, int stringonly) {
}
rfbLog("remote_cmd: changed full access passwd.\n");
- } else if (tray_mode && !query && strstr(p, "viewpasswd") == p) { /* skip-cmd-list */
+ } else if (icon_mode && !query && strstr(p, "viewpasswd") == p) { /* skip-cmd-list */
char **passwds_new = (char **) malloc(3*sizeof(char *));
char **passwds_old = (char **) screen->authPasswdData;
@@ -15299,6 +15536,32 @@ char *process_remote_cmd(char *cmd, int stringonly) {
screen->authPasswdData = (void*) passwds_new;
rfbLog("remote_cmd: changed view only passwd.\n");
+ } else if (strstr(p, "trayembed") == p) { /* skip-cmd-list */
+ unsigned long id;
+ NOTAPP
+
+ COLON_CHECK("trayembed:")
+ p += strlen("trayembed:");
+ if (scan_hexdec(p, &id)) {
+ tray_request = (Window) id;
+ tray_unembed = 0;
+ rfbLog("remote_cmd: will try to embed 0x%x in"
+ " the system tray.\n", id);
+ }
+ } else if (strstr(p, "trayunembed") == p) { /* skip-cmd-list */
+ unsigned long id;
+ NOTAPP
+
+ COLON_CHECK("trayunembed:")
+ p += strlen("trayunembed:");
+ if (scan_hexdec(p, &id)) {
+ tray_request = (Window) id;
+ tray_unembed = 1;
+ rfbLog("remote_cmd: will try to unembed 0x%x out"
+ " of the system tray.\n", id);
+ }
+
+
} else if (query) {
/* read-only variables that can only be queried: */
@@ -23098,6 +23361,150 @@ int scan_for_updates(int count_only) {
return tile_diffs;
}
+Window tweak_tk_window_id(Window win) {
+ char *name = NULL;
+ Window parent, new;
+
+ /* hack for tk, does not report outermost window */
+ new = win;
+ parent = parent_window(win, &name);
+ if (parent && name != NULL) {
+ lowercase(name);
+ if (strstr(name, "wish") || strstr(name, "x11vnc")) {
+ new = parent;
+ rfbLog("tray_embed: using parent: %s\n", name);
+ }
+ }
+ if (name != NULL) {
+ XFree(name);
+ }
+ return new;
+}
+
+#define SYSTEM_TRAY_REQUEST_DOCK 0
+#define SYSTEM_TRAY_BEGIN_MESSAGE 1
+#define SYSTEM_TRAY_CANCEL_MESSAGE 2
+#define XEMBED_VERSION 0
+#define XEMBED_MAPPED (1 << 0)
+
+int tray_embed(Window iconwin, int remove) {
+ XEvent ev;
+ XErrorHandler old_handler;
+ Window manager;
+ Atom xembed_info;
+ Atom tatom;
+ XWindowAttributes attr;
+ long info[2] = {XEMBED_VERSION, XEMBED_MAPPED};
+ long data = 0;
+
+ if (remove) {
+ if (!valid_window(iconwin, &attr, 1)) {
+ return 0;
+ }
+ iconwin = tweak_tk_window_id(iconwin);
+ trapped_xerror = 0;
+ old_handler = XSetErrorHandler(trap_xerror);
+
+ /*
+ * unfortunately no desktops seem to obey this
+ * part of the XEMBED spec yet...
+ */
+ XReparentWindow(dpy, iconwin, rootwin, 0, 0);
+
+ XSetErrorHandler(old_handler);
+ if (trapped_xerror) {
+ trapped_xerror = 0;
+ return 0;
+ }
+ trapped_xerror = 0;
+ return 1;
+ }
+
+ xembed_info = XInternAtom(dpy, "_XEMBED_INFO", False);
+ if (xembed_info == None) {
+ return 0;
+ }
+
+ if (!tray_manager_running(dpy, &manager)) {
+ return 0;
+ }
+
+ memset(&ev, 0, sizeof(ev));
+ ev.xclient.type = ClientMessage;
+ ev.xclient.window = manager;
+ ev.xclient.message_type = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE",
+ False);
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = CurrentTime;
+ ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
+ ev.xclient.data.l[2] = iconwin;
+ ev.xclient.data.l[3] = 0;
+ ev.xclient.data.l[4] = 0;
+
+ if (!valid_window(iconwin, &attr, 1)) {
+ return 0;
+ }
+
+ iconwin = tweak_tk_window_id(iconwin);
+ ev.xclient.data.l[2] = iconwin;
+
+ XUnmapWindow(dpy, iconwin);
+
+ trapped_xerror = 0;
+ old_handler = XSetErrorHandler(trap_xerror);
+
+ XSendEvent(dpy, manager, False, NoEventMask, &ev);
+ XSync(dpy, False);
+
+ if (trapped_xerror) {
+ XSetErrorHandler(old_handler);
+ trapped_xerror = 0;
+ return 0;
+ }
+
+ XChangeProperty(dpy, iconwin, xembed_info, xembed_info, 32,
+ PropModeReplace, (unsigned char *)&info, 2);
+
+ /* kludge for KDE evidently needed... */
+ tatom = XInternAtom(dpy, "KWM_DOCKWINDOW", False);
+ XChangeProperty(dpy, iconwin, tatom, tatom, 32, PropModeReplace,
+ (unsigned char *)&data, 1);
+ tatom = XInternAtom(dpy, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False);
+ XChangeProperty(dpy, iconwin, tatom, XA_WINDOW, 32, PropModeReplace,
+ (unsigned char *)&data, 1);
+
+ XSetErrorHandler(old_handler);
+ trapped_xerror = 0;
+ return 1;
+}
+
+int tray_manager_running(Display *d, Window *manager) {
+ char tray_string[100];
+ Atom tray_manager;
+ Window tray_win;
+
+ if (manager) {
+ *manager = None;
+ }
+ sprintf(tray_string, "_NET_SYSTEM_TRAY_S%d", scr);
+
+ tray_manager = XInternAtom(d, tray_string, True);
+ if (tray_manager == None) {
+ return 0;
+ }
+
+ tray_win = XGetSelectionOwner(d, tray_manager);
+ if (manager) {
+ *manager = tray_win;
+ }
+
+ if (tray_win == None) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
/* -- gui.c -- */
#ifdef NOGUI
char gui_code[] = "";
@@ -23157,7 +23564,7 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
rootwin = RootWindow(dpy, scr);
initialize_vnc_connect_prop();
}
- usleep(1000*1000);
+ usleep(2200*1000);
fprintf(stderr, "\n");
for (i=0; i<try_max; i++) {
usleep(sleep*1000);
@@ -23246,16 +23653,50 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
set_env("DISPLAY", gui_xdisplay);
set_env("X11VNC_PROG", program_name);
set_env("X11VNC_CMDLINE", program_cmdline);
+ set_env("X11VNC_WISHCMD", wish);
if (simple_gui) {
set_env("X11VNC_SIMPLE_GUI", "1");
}
- if (tray_mode && tray_mode_file) {
- set_env("X11VNC_TRAY_MODE", "1");
- set_env("X11VNC_CLIENT_FILE", tray_mode_file);
- if (tray_mode_params) {
- set_env("X11VNC_TRAY_EMBED_ID", tray_mode_params);
+ if (gui_geometry) {
+ set_env("X11VNC_GUI_GEOM", gui_geometry);
+ }
+ if (connect_to_x11vnc) {
+ set_env("X11VNC_STARTED", "1");
+ }
+ if (icon_mode && icon_mode_file) {
+ set_env("X11VNC_ICON_MODE", "1");
+ set_env("X11VNC_CLIENT_FILE", icon_mode_file);
+ if (icon_in_tray) {
+ if (tray_manager_ok) {
+ set_env("X11VNC_ICON_MODE", "TRAY:RUNNING");
+ } else {
+ set_env("X11VNC_ICON_MODE", "TRAY");
+ }
+ } else {
+ set_env("X11VNC_ICON_MODE", "ICON");
+ }
+ if (icon_mode_params) {
+ char *p, *str = strdup(icon_mode_params);
+ p = strtok(str, ":-/,.+");
+ while (p) {
+ if(strstr(p, "setp") == p) {
+ set_env("X11VNC_ICON_SETPASS", "1");
+ } else if(strstr(p, "noadvanced") == p) {
+ set_env("X11VNC_ICON_NOADVANCED", "1");
+ } else if(strstr(p, "minimal") == p) {
+ set_env("X11VNC_ICON_MINIMAL", "1");
+ } else if (strstr(p, "0x") == p) {
+ set_env("X11VNC_ICON_EMBED_ID", p);
+ icon_mode_embed_id = strdup(p);
+ }
+ p = strtok(NULL, ":-/,.+");
+ }
+ free(str);
}
}
+ if (icon_mode_font) {
+ set_env("X11VNC_ICON_FONT", icon_mode_font);
+ }
if (no_external_cmds) {
fprintf(stderr, "cannot run external commands in -nocmds "
@@ -23269,10 +23710,10 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
tmpf = tmpfile();
if (tmpf == NULL) {
/* if no tmpfile, use a pipe */
- if (tray_mode_params) {
- if (strlen(tray_mode_params) < 20) {
+ if (icon_mode_embed_id) {
+ if (strlen(icon_mode_embed_id) < 20) {
strcat(cmd, " -use ");
- strcat(cmd, tray_mode_params);
+ strcat(cmd, icon_mode_embed_id);
}
}
pipe = popen(cmd, "w");
@@ -23294,8 +23735,8 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
rewind(tmpf);
dup2(n, 0);
close(n);
- if (tray_mode_params) {
- execlp(wish, wish, "-", "-use", tray_mode_params,
+ if (icon_mode_embed_id) {
+ execlp(wish, wish, "-", "-use", icon_mode_embed_id,
(char *) NULL);
} else {
execlp(wish, wish, "-", (char *) NULL);
@@ -23352,11 +23793,27 @@ void do_gui(char *opts) {
connect_to_x11vnc = 1;
} else if (!strcmp(p, "ez") || !strcmp(p, "simple")) {
simple_gui = 1;
- } else if (strstr(p, "tray") || strstr(p, "icon")) {
+ } else if (strstr(p, "iconfont") == p) {
char *q;
- tray_mode = 1;
if ((q = strchr(p, '=')) != NULL) {
- tray_mode_params = strdup(q+1);
+ icon_mode_font = strdup(q+1);
+ }
+ } else if (strstr(p, "tray") == p || strstr(p, "icon") == p) {
+ char *q;
+ icon_mode = 1;
+ if ((q = strchr(p, '=')) != NULL) {
+ icon_mode_params = strdup(q+1);
+ if (strstr(icon_mode_params, "setp")) {
+ deny_all = 1;
+ }
+ }
+ if (strstr(p, "tray") == p) {
+ icon_in_tray = 1;
+ }
+ } else if (strstr(p, "geom") == p) {
+ char *q;
+ if ((q = strchr(p, '=')) != NULL) {
+ gui_geometry = strdup(q+1);
}
} else {
fprintf(stderr, "unrecognized gui opt: %s\n", p);
@@ -23369,7 +23826,7 @@ void do_gui(char *opts) {
connect_to_x11vnc = 1;
}
- if (tray_mode && !got_gui_xdisplay) {
+ if (icon_mode && !got_gui_xdisplay) {
/* for tray mode, prefer the polled DISPLAY */
if (use_dpy) {
if (gui_xdisplay) {
@@ -23404,6 +23861,13 @@ void do_gui(char *opts) {
gui_xdisplay);
exit(1);
}
+ if (icon_mode && icon_in_tray) {
+ if (tray_manager_running(test_dpy, NULL)) {
+ tray_manager_ok = 1;
+ } else {
+ tray_manager_ok = 0;
+ }
+ }
XCloseDisplay(test_dpy);
if (start_x11vnc) {
@@ -23413,23 +23877,28 @@ void do_gui(char *opts) {
int p;
pid_t parent = getpid();
- if (tray_mode) {
+ if (icon_mode) {
char tf[100];
+ double dn = dnow();
struct stat sbuf;
/* FIXME */
- sprintf(tf, "/tmp/x11vnc.tray.%d", (int) getpid());
+ dn = dn - ((int) dn);
+ sprintf(tf, "/tmp/x11vnc.tray%d%d", (int) (1000000*dn),
+ (int) getpid());
unlink(tf);
+ /* race begins.. */
if (stat(tf, &sbuf) == 0) {
- tray_mode = 0;
+ icon_mode = 0;
} else {
- tray_mode_fh = fopen(tf, "w");
- if (! tray_mode_fh) {
- tray_mode = 0;
+ icon_mode_fh = fopen(tf, "w");
+ if (! icon_mode_fh) {
+ icon_mode = 0;
} else {
- chmod(tf, 0600);
- tray_mode_file = strdup(tf);
- fprintf(tray_mode_fh, "none\n");
- fflush(tray_mode_fh);
+ chmod(tf, 0400);
+ icon_mode_file = strdup(tf);
+ fprintf(icon_mode_fh, "none\n");
+ fprintf(icon_mode_fh, "none\n");
+ fflush(icon_mode_fh);
if (! got_connect_once) {
/* want -forever for tray */
connect_once = 0;
@@ -27747,6 +28216,10 @@ double dnow(void) {
return dtime0(&t);
}
+double dnowx(void) {
+ return dnow() - x11vnc_start;
+}
+
void measure_display_hook(rfbClientPtr cl) {
ClientData *cd = (ClientData *) cl->clientData;
dtime0(&cd->timer);
@@ -29785,6 +30258,9 @@ static void print_help(int mode) {
" currently used by the -scrollcopyrect scheme and to\n"
" monitor X server grabs.\n"
"\n"
+"-debug_grabs Turn on debugging info printout with respect to\n"
+" XGrabServer() deadlock for -scrollcopyrect mode.\n"
+"\n"
"-pointer_mode n Various pointer motion update schemes. \"-pm\" is\n"
" an alias. The problem is pointer motion can cause\n"
" rapid changes on the screen: consider the rapid changes\n"
@@ -30032,9 +30508,10 @@ static void print_help(int mode) {
" up on the X display in the environment variable DISPLAY.\n"
"\n"
" \"gui-opts\" can be a comma separated list of items.\n"
-" Currently there are these types of items: 1) a gui mode,\n"
-" a 2) gui \"simplicity\", 3) the X display the gui\n"
-" should display on, and 4) a \"tray\" (or icon) mode.\n"
+" Currently there are these types of items: 1) a gui\n"
+" mode, a 2) gui \"simplicity\", 3) the X display the\n"
+" gui should display on, 4) a \"tray\" or \"icon\" mode,\n"
+" and 5) a gui geometry.\n"
"\n"
" 1) The gui mode can be \"start\", \"conn\", or \"wait\"\n"
" \"start\" is the default mode above and is not required.\n"
@@ -30067,22 +30544,44 @@ static void print_help(int mode) {
" x11vnc polling :0 and display the gui on otherhost:0\n"
" The \"tray\" mode below reverses this preference.\n"
"\n"
-" 4) When \"tray\" is specified, the gui presents itself\n"
-" as a small icon with behavior similar to a \"system\n"
-" tray\" or \"dock\" applet. The color of the icon\n"
-" indicates status (connected clients) and there is also a\n"
-" balloon status. Clicking on the icon gives a menu from\n"
-" which properties, etc, can be set and the full gui is\n"
-" available under \"Advanced\". To be fully functional,\n"
-" the gui mode should be \"start\" (the default). At some\n"
-" point it is hoped the icon can be automatically embedded\n"
-" in common destkop trays/docks. Currently one can only\n"
-" embed it in a window via, e.g., \"tray=0x3600028\".\n"
-" Otherwise the icon is just a normal standalone window.\n"
+" 4) When \"tray\" or \"icon\" is specified, the gui\n"
+" presents itself as a small icon with behavior typical\n"
+" of a \"system tray\" or \"dock\" applet. The color\n"
+" of the icon indicates status (connected clients) and\n"
+" there is also a balloon status. Clicking on the icon\n"
+" gives a menu from which properties, etc, can be set and\n"
+" the full gui is available under \"Advanced\". To be\n"
+" fully functional, the gui mode should be \"start\"\n"
+" (the default).\n"
+"\n"
+" For \"icon\" the gui just a small standalone window.\n"
+" For \"tray\" it will attempt to embed itself in the\n"
+" \"system tray\". If \"=setpass\" is appended then\n"
+" at startup the X11 user will be prompted to set the\n"
+" VNC session password. If =<hexnumber> is appended\n"
+" that icon will attempt to embed itself in the window\n"
+" given by hexnumber. Use =noadvanced to disable the\n"
+" full gui. (To supply more than one, use \"+\" sign).\n"
+" E.g. -gui tray=setpass and -gui icon=0x3600028\n"
"\n"
-" Examples: \"x11vnc -gui\", \"x11vnc -gui ez\"\n"
-" \"x11vnc -gui localhost:10\", \"x11vnc -gui conn,host:0\"\n"
-" \"x11vnc -gui tray,ez\"\n"
+" 5) When \"geom=+X+Y\" is specified, that geometry\n"
+" is passed to the gui toplevel. This is the icon in\n"
+" icon/tray mode, or the full gui otherwise. You can\n"
+" also specify width and height, i.e. WxH+X+Y, but it\n"
+" is not recommended. In \"tray\" mode the geometry is\n"
+" ignored unless the system tray manager does not seem\n"
+" to be running. One could imagine using something like\n"
+" \"-gui tray,geom=+4000+4000\" with a display manager\n"
+" to keep the gui invisible until someone logs in...\n"
+"\n"
+" More icon tricks, \"icon=minimal\" gives an icon just\n"
+" with the VNC display number. You can also set the font\n"
+" with \"iconfont=...\". The following could be useful:\n"
+" \"-gui icon=minimal,iconfont=5x8,geom=24x10+0-0\"\n"
+"\n"
+" General examples of the -gui option: \"x11vnc -gui\",\n"
+" \"x11vnc -gui ez\" \"x11vnc -gui localhost:10\",\n"
+" \"x11vnc -gui conn,host:0\", \"x11vnc -gui tray,ez\"\n"
"\n"
" If you do not intend to start x11vnc from the gui\n"
" (i.e. just remote control an existing one), then the\n"
@@ -30354,6 +30853,8 @@ static void print_help(int mode) {
" nodebug_scroll disable debugging scrollcopy mechanism.\n"
" debug_tiles enable -debug_tiles\n"
" nodebug_tiles disable -debug_tiles\n"
+" debug_grabs enable -debug_grabs\n"
+" nodebug_grabs disable -debug_grabs\n"
" dbg enable -dbg crash shell\n"
" nodbg disable -dbg crash shell\n"
"\n"
@@ -30394,10 +30895,10 @@ static void print_help(int mode) {
" 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"
+" scale_cursor viewonly noviewonly shared noshared forever\n"
+" noforever once timeout deny lock nodeny unlock connect\n"
+" allowonce allow localhost nolocalhost listen lookup\n"
+" nolookup accept popup gone shm noshm flipbyteorder\n"
" noflipbyteorder onetile noonetile solid_color solid\n"
" nosolid blackout xinerama noxinerama xtrap noxtrap\n"
" xrandr noxrandr xrandr_mode padgeom quiet q noquiet\n"
@@ -30428,8 +30929,8 @@ static void print_help(int mode) {
" debug_xevents debug_xdamage nodebug_xdamage\n"
" debug_xdamage debug_wireframe nodebug_wireframe\n"
" debug_wireframe debug_scroll nodebug_scroll debug_scroll\n"
-" debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg\n"
-" nodbg noremote\n"
+" debug_tiles dbt nodebug_tiles nodbt debug_tiles\n"
+" debug_grabs nodebug_grabs dbg nodbg noremote\n"
"\n"
" aro= display vncdisplay desktopname guess_desktop\n"
" http_url auth users rootshift clipshift scale_str\n"
@@ -30741,6 +31242,11 @@ static void check_rcfile(int argc, char **argv) {
FILE *rc;
for (i=1; i < argc; i++) {
+ if (!strcmp(argv[i], "-printgui")) {
+ fprintf(stdout, "%s", gui_code);
+ fflush(stdout);
+ exit(0);
+ }
if (!strcmp(argv[i], "-norc")) {
norc = 1;
}
@@ -31062,6 +31568,10 @@ int main(int argc, char* argv[]) {
}
}
+ for (i=0; i<ICON_MODE_SOCKS; i++) {
+ icon_mode_socks[i] = -1;
+ }
+
check_rcfile(argc, argv);
/* kludge for the new array argv2 set in check_rcfile() */
# define argc argc2
@@ -31550,6 +32060,8 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-debug_tiles")
|| !strcmp(arg, "-dbt")) {
debug_tiles++;
+ } else if (!strcmp(arg, "-debug_grabs")) {
+ debug_grabs++;
} else if (!strcmp(arg, "-snapfb")) {
use_snapfb = 1;
} else if (!strcmp(arg, "-rawfb")) {
@@ -31606,6 +32118,8 @@ int main(int argc, char* argv[]) {
xkbcompat = 0;
} else if (!strcmp(arg, "-sync")) {
remote_sync = 1;
+ } else if (!strcmp(arg, "-nosync")) {
+ remote_sync = 0;
} else if (!strcmp(arg, "-noremote")) {
accept_remote_cmds = 0;
} else if (!strcmp(arg, "-yesremote")) {