summaryrefslogtreecommitdiffstats
path: root/x11vnc/tkx11vnc.h
diff options
context:
space:
mode:
authorrunge <runge>2005-07-18 02:21:14 +0000
committerrunge <runge>2005-07-18 02:21:14 +0000
commit37f23b2c074e6cde6d5fa0387cdef1517bdedb0c (patch)
tree6a637d1427d9409bb55c224ed51feef5ffabfaa1 /x11vnc/tkx11vnc.h
parent57d2ea65910a122d6011e205e20388518b9d68e5 (diff)
downloadlibtdevnc-37f23b2c074e6cde6d5fa0387cdef1517bdedb0c.tar.gz
libtdevnc-37f23b2c074e6cde6d5fa0387cdef1517bdedb0c.zip
x11vnc: more gui fixes, gui requests via client_sock, PASSWD_REQUIRED build opt.
Diffstat (limited to 'x11vnc/tkx11vnc.h')
-rw-r--r--x11vnc/tkx11vnc.h454
1 files changed, 386 insertions, 68 deletions
diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h
index 97d3ae5..9aaf5fa 100644
--- a/x11vnc/tkx11vnc.h
+++ b/x11vnc/tkx11vnc.h
@@ -28,7 +28,7 @@
"# USA.\n"
"\n"
"#\n"
-"# tkx11vnc v0.1\n"
+"# tkx11vnc v0.2\n"
"# This is a simple frontend to x11vnc. It uses the remote control\n"
"# and query features (-remote/-query aka -R/-Q) to interact with it. \n"
"# It is just a quick-n-dirty hack (it parses -help output, etc), but\n"
@@ -565,7 +565,9 @@
" 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"
+" Disconnect - Shows a popup menu of connected clients. Click on\n"
+" one to disconnect it, or click on \\\"All Clients\\\"\n"
+" disconnect all clients.\n"
"\n"
" Window View - Switch between the \\\"full\\\" gui (also known as\n"
" \\\"Advanced\\\"), \\\"icon\\\" mode (small icon window with\n"
@@ -577,11 +579,29 @@
" and then exit. The tray/icon GUI then exits as well.\n"
"\n"
"\n"
+"Termination:\n"
+"\n"
"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. (This will disconnect any\n"
-"VNC viewer you are currently using to access the display).\n"
+"VNC viewer you are currently using to access the display since the\n"
+"x11vnc server is terminated).\n"
+"\n"
+"To terminate the tray/icon gui window but not the x11vnc server press\n"
+"Control-C on the tray/icon window. You can also do this (and much\n"
+"more) via Properties -> Advanced -> Actions -> Quit\n"
+"\"\n"
+"\n"
+" set helptext(NewClient) \"\n"
+" New Client - Presents an entry box where you type in the name\n"
+" 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"
"\"\n"
"\n"
" set helptext(Properties) \"\n"
@@ -628,7 +648,39 @@
" \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"
+"\n"
+"--------------------------------------------------------------------\n"
+"Don't Lock Yourself Out:\n"
+"\n"
+" If you are sitting at the physical X display you cannot get into too\n"
+" much trouble setting the Properties dialog values.\n"
+"\n"
+" However IF you are using a VNC Viewer to REMOTELY access the X display\n"
+" some items in the Properties dialog can lock you out of further access:\n"
+"\n"
+" \\\"Accept Connections\\\" if you disable this remotely, and\n"
+" accidentally disconnect your VNC viewer then you will not be\n"
+" able to reconnect.\n"
+" \n"
+" \\\"Ask for Confirmation\\\" if you enable this only someone\n"
+" sitting at the X display can confirm any new VNC connections.\n"
+" Furthermore, any current VNC viewers will be blocked while\n"
+" waiting for the confirmation (times out in 120 sec by default). \n"
+" \n"
+" \\\"All Clients ViewOnly\\\" if you enable this remotely, well\n"
+" you can no longer provide input to disable it.\n"
+" \n"
+" If you do lock yourself out you could log in remotely and start up\n"
+" a second x11vnc and connect to that one to try to fix things in the\n"
+" first one.\n"
+"\n"
+" Note that if there are two or more x11vnc's on the same display the\n"
+" use of the GUI may be ill-behaved. Terminate the second x11vnc as\n"
+" soon as you have fixed the setting in the first one. Use of a remote\n"
+" control command, e.g. \\\"x11vnc -R noviewonly\\\" or \\\"x11vnc -R unlock\\\"\n"
+" is a good way to avoid this problem.\n"
+"\"\n"
"\n"
" set helptext(all) $helpall\n"
"\n"
@@ -1105,10 +1157,11 @@
" if {![info exists full_win]} {\n"
" return\n"
" }\n"
+" set w \".\"\n"
" if {$icon_mode} {\n"
+" wm title $w \"$name\"\n"
+" wm iconname $w \"$name\"\n"
" set w $full_win\n"
-" } else {\n"
-" set w \".\"\n"
" }\n"
" wm title $w \"$name\"\n"
" wm iconname $w \"$name\"\n"
@@ -2641,14 +2694,32 @@
"\n"
"proc show_all_settings {} {\n"
" global all_settings\n"
-" set txt \"\\nRead-Write setting:\\n\\n\"\n"
+" global client_sock client_tail\n"
+" global x11vnc_client_file\n"
+"\n"
+" set txt \"\\nRead-Write settings:\\n\\n\"\n"
" foreach item [split_query $all_settings] {\n"
" regsub {:} $item {: } item\n"
" append txt \" $item\\n\"\n"
" if {[regexp {noremote} $item]} {\n"
-" append txt \"\\nRead-Only setting:\\n\\n\"\n"
+" append txt \"\\nRead-Only settings:\\n\\n\"\n"
" }\n"
" }\n"
+" append txt \"\\nInternal settings:\\n\\n\"\n"
+" append txt \"x11vnc_client_file: $x11vnc_client_file\\n\"\n"
+" if {[info exists client_tail]} {\n"
+" append txt \"client_tail: $client_tail\\n\"\n"
+" } else {\n"
+" append txt \"client_tail: unset\\n\"\n"
+" }\n"
+" if {[info exists client_sock]} {\n"
+" append txt \"client_sock: $client_sock\\n\"\n"
+" } else {\n"
+" append txt \"client_sock: unset\\n\"\n"
+" }\n"
+" set estr \"\"\n"
+" catch {set estr [exec env | grep -i X11VNC]}\n"
+" append txt \"$estr\\n\"\n"
" textwin \"Settings\" \"All Current Settings\" $txt\n"
"}\n"
"\n"
@@ -3579,16 +3650,15 @@
" }\n"
"}\n"
"\n"
-"proc menu_posted {} {\n"
+"proc check_update_vars {} {\n"
" global last_query_all_time query_all_freq icon_mode\n"
-" global connected_to_x11vnc client_tail\n"
+" global connected_to_x11vnc client_tail client_sock\n"
"\n"
" set now [clock seconds]\n"
"\n"
-" if {$icon_mode && $client_tail != \"\"} {\n"
+" set delay $query_all_freq\n"
+" if {$client_tail != \"\" && $client_sock == \"\"} {\n"
" set delay [expr 2 * $query_all_freq]\n"
-" } else {\n"
-" set delay $query_all_freq\n"
" }\n"
"\n"
" if {$connected_to_x11vnc} {\n"
@@ -3608,6 +3678,10 @@
" }\n"
"}\n"
"\n"
+"proc menu_posted {} {\n"
+" check_update_vars\n"
+"}\n"
+"\n"
"proc props_widgets {state} {\n"
" global props_buttons\n"
" foreach w $props_buttons {\n"
@@ -3622,20 +3696,30 @@
" global prop0_accept prop0_confirm prop0_viewonly prop0_shared\n"
" global prop0_passwd prop0_viewpasswd\n"
" global menu_var\n"
+" global client_sock\n"
"\n"
" props_widgets disabled\n"
"\n"
+" set aft 500\n"
+" if {[info exists client_sock]} {\n"
+" if {$client_sock != \"\"} {\n"
+" set aft 150\n"
+" }\n"
+" }\n"
+" set did 0\n"
+"\n"
" if {$props_accept != $prop0_accept} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" if {$props_accept} {\n"
" push_new_value \"unlock\" \"unlock\" 1 0\n"
" } else {\n"
" push_new_value \"lock\" \"lock\" 1 0\n"
" }\n"
" set prop0_accept $props_accept\n"
-" after 500\n"
" }\n"
"\n"
" if {$props_confirm != $prop0_confirm} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" if {$props_confirm} {\n"
" push_new_value \"accept\" \"accept\" \"popup\" 1\n"
" } else {\n"
@@ -3647,10 +3731,10 @@
" set props_confirm 0\n"
" }\n"
" set prop0_confirm $props_confirm\n"
-" after 500\n"
" }\n"
"\n"
" if {$props_viewonly != $prop0_viewonly} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" if {$props_viewonly} {\n"
" push_new_value \"viewonly\" \"viewonly\" 1 1\n"
" } else {\n"
@@ -3662,10 +3746,10 @@
" set props_viewonly 0\n"
" }\n"
" set prop0_viewonly $props_viewonly\n"
-" after 500\n"
" }\n"
"\n"
" if {$props_shared != $prop0_shared} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" if {$props_shared} {\n"
" push_new_value \"shared\" \"shared\" 1 1\n"
" } else {\n"
@@ -3677,7 +3761,6 @@
" set props_shared 0\n"
" }\n"
" set prop0_shared $props_shared\n"
-" after 500\n"
" }\n"
"\n"
" set fpw 0\n"
@@ -3742,14 +3825,14 @@
"\n"
" foreach case $pw_ord {\n"
" if {$case == \"fpw\"} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" push_new_value \"passwd\" \"passwd\" \"$props_passwd\" 1\n"
" set prop0_passwd $props_passwd\n"
-" after 500\n"
" }\n"
" if {$case == \"vpw\"} {\n"
+" if {$did > 0} {after $aft}; incr did\n"
" push_new_value \"viewpasswd\" \"viewpasswd\" \"$props_viewpasswd\" 1\n"
" set prop0_viewpasswd $props_viewpasswd\n"
-" after 500\n"
" }\n"
" }\n"
"\n"
@@ -3785,6 +3868,8 @@
" global have_labelframes ffont bfont\n"
" global props_buttons icon_noadvanced\n"
"\n"
+" check_update_vars\n"
+"\n"
" if [info exists menu_var(deny)] {\n"
" if {$menu_var(deny) == $unset_str || $menu_var(deny) == 0} {\n"
" set props_accept 1\n"
@@ -3862,6 +3947,8 @@
" button $b1.cancel -text Cancel -command \"destroy $w\" -font $bfont\n"
" button $b1.apply -text Apply -command \"props_apply\" -font $bfont\n"
"\n"
+" bind $w <KeyPress-Escape> \"destroy $w\"\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"
@@ -3971,11 +4058,12 @@
" set newclient \"\"\n"
" entry $w.e -width 16 -textvariable newclient -font $bfont \n"
" button $w.b -text OK -command \"destroy $w\" -font $bfont\n"
+" button $w.h -text Help -command \"menu_help NewClient\" -font $bfont\n"
" bind $w.e <Return> \"update; after 100; destroy $w\"\n"
"\n"
" wm title $w \"New Client\"\n"
"\n"
-" pack $w.l $w.e $w.b -side left -pady 1m -padx 1m\n"
+" pack $w.l $w.e $w.h $w.b -side left -pady 1m -padx 0.5m\n"
" focus $w.e\n"
" center_win $w\n"
" update \n"
@@ -3993,6 +4081,43 @@
" push_new_value \"disconnect\" \"disconnect\" \"all\" 1\n"
"}\n"
"\n"
+"proc do_disconnect_client {id} {\n"
+" push_new_value \"disconnect\" \"disconnect\" \"$id\" 1\n"
+"}\n"
+"\n"
+"proc popup_post {m} {\n"
+" global popup_cascade_posted client_balloon\n"
+" global client_id_list\n"
+"\n"
+" set popup_cascade_posted 0\n"
+" \n"
+" set wd \"$m.disconnect\"\n"
+"\n"
+" if {![winfo exists $wd]} {\n"
+" return\n"
+" }\n"
+"\n"
+" catch {$wd delete 0 end}\n"
+"\n"
+" $wd add command -label \"Disconnect client:\"\n"
+" $wd add separator\n"
+" $wd add command -label \"All Clients\" -command do_disconnect_all\n"
+"\n"
+" if {![info exists client_id_list]} {\n"
+" return\n"
+" }\n"
+"\n"
+" foreach client $client_id_list {\n"
+" if {$client == \"\"} {\n"
+" continue\n"
+" }\n"
+" if {[regexp {^([^:]*):(.*)$} $client mat id lab]} {\n"
+" $wd add command -label \"$lab\" \\\n"
+" -command \"do_disconnect_client $id\"\n"
+" }\n"
+" }\n"
+"}\n"
+"\n"
"proc pmenu {m x y} {\n"
" if {![winfo exists $m]} {\n"
" return\n"
@@ -4004,6 +4129,9 @@
"\n"
"proc set_client_balloon {str} {\n"
" global client_balloon vnc_display\n"
+" global client_id_list\n"
+"\n"
+" set client_id_list [list]\n"
" \n"
" set client_balloon \"$vnc_display\"\n"
" set count 0\n"
@@ -4029,8 +4157,10 @@
" set client_balloon \"${client_balloon}\\n$user\\@$host\"\n"
" if {$vo == \"1\"} {\n"
" set client_balloon \"${client_balloon} - view\"\n"
+" lappend client_id_list \"$id:$user\\@$host - view\"\n"
" } else {\n"
" set client_balloon \"${client_balloon} - full\"\n"
+" lappend client_id_list \"$id:$user\\@$host - full\"\n"
" }\n"
" } else {\n"
" set i [expr $count+1]\n"
@@ -4044,26 +4174,37 @@
" icon_win_cfg $count\n"
"}\n"
"\n"
-"proc read_client_info {} {\n"
-" global x11vnc_client_file client_tail client_str\n"
-" global client_tail_read\n"
+"proc read_client_info {channel} {\n"
+" global x11vnc_client_file client_str client_info_read\n"
+" global read_client_info_lock\n"
" set db 0\n"
"\n"
-" if {$client_tail != \"\"} {\n"
+" if {![info exists read_client_info_lock]} {\n"
+" set read_client_info_lock 0\n"
+" }\n"
+"\n"
+" if {$channel != \"\"} {\n"
+"\n"
+" if {$read_client_info_lock} {\n"
+" return\n"
+" }\n"
+" set read_client_info_lock 1\n"
" after 100\n"
" set str \"\"\n"
-" set count [gets $client_tail str]\n"
-" if {$db} {puts stderr \"read_client_info: $str\"}\n"
+" set count [gets $channel str]\n"
+" if {$db} {puts stderr \"read_client_info-$channel: $str\"}\n"
"\n"
-" if {$count == -1 || [eof $client_tail]} {\n"
-" close $client_tail\n"
+" if {$count == -1 || [eof $channel]} {\n"
+" close $channel\n"
" catch {file delete $x11vnc_client_file}\n"
+" set read_client_info_lock 0\n"
" clean_icon_exit\n"
" }\n"
" if {$count > 0 && ![regexp {^[ ]*$} $str]} {\n"
-" set client_tail_read 1\n"
+" set client_info_read 1\n"
" if {$str == \"quit\"} {\n"
" catch {file delete $x11vnc_client_file}\n"
+" set read_client_info_lock 0\n"
" clean_icon_exit\n"
" } elseif {$str != \"skip\"} {\n"
" if {$str == \"none\"} {\n"
@@ -4074,6 +4215,23 @@
" set_client_balloon $str\n"
" }\n"
" }\n"
+" set read_client_info_lock 0\n"
+" }\n"
+"}\n"
+"\n"
+"proc read_client_tail {} {\n"
+" global client_tail\n"
+"\n"
+" if {$client_tail != \"\"} {\n"
+" read_client_info $client_tail\n"
+" }\n"
+"}\n"
+"\n"
+"proc read_client_sock {} {\n"
+" global client_sock\n"
+"\n"
+" if {$client_sock != \"\"} {\n"
+" read_client_info $client_sock\n"
" }\n"
"}\n"
"\n"
@@ -4135,20 +4293,30 @@
"}\n"
"\n"
"proc icon_win_cfg {clients} {\n"
-" global icon_win client_tail client_tail_read\n"
+" global icon_win client_tail client_sock client_info_read\n"
+"\n"
+" if {![info exists icon_win]} {\n"
+" return\n"
+" }\n"
+" if {$icon_win == \"\"} {\n"
+" return\n"
+" }\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"
+" if {$client_tail == \"\" || !$client_info_read} {\n"
+" if {$client_sock == \"\"} {\n"
+" $icon_win configure -fg red\n"
+" }\n"
" }\n"
"}\n"
"\n"
"proc server_accept {sock addr port} {\n"
" global socket_cookie server socket_got_callback\n"
-" global client_tail\n"
+" global client_tail client_sock\n"
" set db 0\n"
"\n"
" if {$db} {puts stderr \"sock=$sock addr=$addr port=$port\"}\n"
@@ -4162,8 +4330,8 @@
" 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"
+" set client_sock $sock\n"
+" if {$db} {puts stderr \"cookie matched. $client_sock\"}\n"
" } else {\n"
" if {$db} {puts stderr \"cookie NO matched.\"}\n"
" }\n"
@@ -4175,17 +4343,39 @@
"\n"
"proc try_client_info_sock {} {\n"
" global socket_cookie server socket_got_callback\n"
-" global x11vnc_started hostname\n"
+" global x11vnc_started x11vnc_xdisplay hostname client_sock\n"
+" global x11vnc_xdisplay0 menu_var\n"
+"\n"
+" set db 0\n"
" set start 13037\n"
" set tries 100\n"
" set socket_got_callback 0\n"
"\n"
+" set xd $x11vnc_xdisplay\n"
+" if {$xd == \"\" && $x11vnc_xdisplay0 != \"\"} {\n"
+" set xd $x11vnc_xdisplay0\n"
+" }\n"
+" if {$xd == \"\" && [info exists menu_var(display)]} {\n"
+" set xd $menu_var(display)\n"
+" }\n"
+"\n"
+" set myaddr \"\"\n"
+" regsub {\\..*$} $hostname \"\" shost\n"
" if {$x11vnc_started} {\n"
" set myaddr \"127.0.0.1\"\n"
+" } elseif {$xd != \"\"} {\n"
+" if {[regexp {^:} $xd]} {\n"
+" set myaddr \"127.0.0.1\"\n"
+" } elseif {[regexp -nocase \"^$shost\" $xd]} {\n"
+" set myaddr \"127.0.0.1\"\n"
+" } elseif {[regexp -nocase \"^localhost\" $xd]} {\n"
+" set myaddr \"127.0.0.1\"\n"
+" } else {\n"
+" set myaddr $hostname\n"
+" }\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"
@@ -4209,8 +4399,25 @@
" }\n"
" run_remote_cmd [list \"-nosync\" \"-R\" \"noop\"]\n"
" after 500\n"
+"\n"
+" # set the cookie to some obscured randomness\n"
+" set socket_cookie [clock clicks]\n"
+" set r [expr rand()]\n"
+" if {$r != \"\"} {\n"
+" append socket_cookie $r\n"
+" }\n"
+" set r \"\"\n"
+" catch {set r [winfo id .]}\n"
+" if {$r != \"\"} {\n"
+" append socket_cookie $r\n"
+" }\n"
+" if {[regexp {([0-9])([0-9])$} [clock clicks] m m1 m2]} {\n"
+" regsub -all {\\.} $socket_cookie $m1 socket_cookie\n"
+" regsub -all {x} $socket_cookie $m2 socket_cookie\n"
+" }\n"
" run_remote_cmd [list \"-nosync\" \"-R\" \\\n"
" \"client_info_sock:$myaddr:$port:$socket_cookie\"]\n"
+" if {$db} {puts \"client_info_sock:$myaddr:$port:$socket_cookie\"}\n"
" after 500\n"
"\n"
" set aftid \"\"\n"
@@ -4227,7 +4434,7 @@
" puts stderr \"try_client_info_sock failed: no callback\\n\"\n"
" catch {close $server}\n"
" } else {\n"
-" setup_client_tail\n"
+" setup_client_sock 1\n"
" }\n"
"}\n"
"\n"
@@ -4258,11 +4465,11 @@
"}\n"
"\n"
"proc lmenu {menu} {\n"
-" global window_view_posted\n"
+" global popup_cascade_posted\n"
" after 100\n"
-" if {!$window_view_posted} {\n"
+" if {!$popup_cascade_posted} {\n"
" after 100\n"
-" if {!$window_view_posted} {\n"
+" if {!$popup_cascade_posted} {\n"
" $menu unpost\n"
" return\n"
" }\n"
@@ -4292,11 +4499,11 @@
"proc make_icon {} {\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 x11vnc_client_file client_tail client_sock client_str saved_clients_str\n"
" global client_balloon_id\n"
" global bfont sfont snfont ffont\n"
" global icon_minimal gui_start_mode\n"
-" global window_view_posted menu_var x11vnc_gui_geom\n"
+" global popup_cascade_posted menu_var x11vnc_gui_geom\n"
" set min_x 24\n"
" set min_y 24\n"
" \n"
@@ -4337,28 +4544,37 @@
" icon_win_cfg 0\n"
"\n"
"\n"
-" set window_view_posted 0\n"
+" set popup_cascade_posted 0\n"
" pack $l -fill both -expand 1\n"
" set menu \"$l.menu\"\n"
-" menu $menu -tearoff 0 -postcommand {set window_view_posted 0}\n"
+" menu $menu -tearoff 0 -postcommand \"popup_post $menu\"\n"
" $menu add command -font $mfont -label \"Properties\" -command do_props\n"
" $menu add command -font $mfont -label \"Help\" -command \"menu_help Tray\"\n"
" $menu add separator\n"
" $menu add command -font $mfont -label \"New Client\" -command do_new_client\n"
-" $menu add command -font $mfont -label \"Disconnect All\" -command do_disconnect_all\n"
+"\n"
+" set wd \"$menu.disconnect\"\n"
+" catch {destroy $wd}\n"
+" menu $wd -tearoff 0 -font $ffont \\\n"
+" -postcommand {set popup_cascade_posted 1}\n"
+" $wd add command -label \"Disconnect client:\"\n"
+" $wd add separator\n"
+" $wd add command -label \"All Clients\" -command do_disconnect_all\n"
+" $menu add cascade -font $mfont -label \"Disconnect:\" -menu $wd\n"
+"\n"
" $menu add separator\n"
"\n"
-" set wv \"$menu.casc1\"\n"
+" set wv \"$menu.windowview\"\n"
" catch {destroy $wv}\n"
" menu $wv -tearoff 0 -font $ffont \\\n"
-" -postcommand {set window_view_posted 1}\n"
+" -postcommand {set popup_cascade_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 $mfont -label \"Window View\" -menu $wv\n"
+" $menu add cascade -font $mfont -label \"Window View:\" -menu $wv\n"
"\n"
" $menu add command -font $mfont -label \"Stop x11vnc\" -command clean_icon_exit\n"
"\n"
@@ -4369,7 +4585,9 @@
" 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"
+"## bind $menu <KeyPress-Escape> \"$menu unpost\"\n"
+"\n"
+" bind . <Control-KeyPress-c> {destroy .; exit 0}\n"
"\n"
" if {!$tray_embed || !$tray_running} {\n"
" global x11vnc_gui_geom\n"
@@ -4385,18 +4603,27 @@
" }\n"
" }\n"
" }\n"
+" wm iconname . \"tkx11vnc\"\n"
+" wm title . \"tkx11vnc\"\n"
" wm deiconify .\n"
"\n"
-" if {$client_tail == \"\" } {\n"
+" old_balloon\n"
+"}\n"
+"\n"
+"proc setup_client_channel {} {\n"
+" global client_sock client_tail\n"
+"\n"
+"# XXX/setup_client_channel\n"
+" if {$client_sock == \"\" } {\n"
" stop_watch on\n"
" try_client_info_sock\n"
-" if {$client_tail == \"\" } {\n"
+" if {$client_sock == \"\" } {\n"
" after 500\n"
" try_client_info_sock\n"
" }\n"
" stop_watch off\n"
" }\n"
-" if {$client_tail == \"\" } {\n"
+" if {$client_tail == \"\" && $client_sock == \"\"} {\n"
" set m \"\\n\"\n"
" set m \"${m}tkx11vnc:\\n\"\n"
" set m \"${m}\\n\"\n"
@@ -4411,12 +4638,10 @@
" textwin \"Warning\" \"Warning\" $m\n"
" update\n"
" }\n"
-"\n"
-" old_balloon\n"
"}\n"
"\n"
"proc clean_client_tail {} {\n"
-" global client_tail client_tail_read\n"
+" global client_tail client_info_read\n"
" if [info exists client_tail] {\n"
" if {$client_tail != \"\"} {\n"
" set p \"\"\n"
@@ -4428,7 +4653,7 @@
" set client_tail \"\"\n"
" }\n"
" }\n"
-" set client_tail_read 0\n"
+" set client_info_read 0\n"
"}\n"
"\n"
"proc clean_icon_exit {} {\n"
@@ -4527,6 +4752,7 @@
" center_win .\n"
" }\n"
"\n"
+"\n"
" if {$make_gui_count == 1} {\n"
" copy_default_vars\n"
" if {$x11vnc_connect} {\n"
@@ -4537,13 +4763,13 @@
" } else {\n"
" set_name \"RESTORE\"\n"
" }\n"
+"\n"
+" setup_client_tail\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"
+" if {$mode == \"tray\"} {\n"
+" setup_tray_embed\n"
" }\n"
"}\n"
"\n"
@@ -4782,7 +5008,7 @@
" global env menus_disabled\n"
" if {[info exists env(USER)] && $env(USER) == \"runge\"} {\n"
" # quick restart\n"
-" bind . <Control-KeyPress-c> {exec $argv0 $argv &; destroy .}\n"
+" bind . <Control-KeyPress-k> {exec $argv0 $argv &; destroy .}\n"
" }\n"
" bind . <Control-KeyPress-p> { \\\n"
" global menus_disabled; \\\n"
@@ -5178,9 +5404,67 @@
" }\n"
"}\n"
"\n"
+"proc run_remote_cmd_via_sock {opts} {\n"
+" global client_sock\n"
+"\n"
+" set db 0\n"
+" if {[eof $client_sock]} {\n"
+" close $client_sock\n"
+" set client_sock \"\"\n"
+" return \"fail\"\n"
+" }\n"
+" set result \"\"\n"
+" \n"
+" setup_client_sock 0\n"
+"\n"
+" set docmd \"\"\n"
+" foreach opt $opts {\n"
+" if {$opt == \"-R\"} {\n"
+" set docmd \"-R\"\n"
+" continue\n"
+" } elseif {$opt == \"-Q\"} {\n"
+" set docmd \"-Q\"\n"
+" continue\n"
+" }\n"
+"\n"
+" if {$docmd == \"\"} {\n"
+" continue\n"
+" } elseif {$docmd == \"-R\"} {\n"
+" set str \"cmd=$opt\"\n"
+" } elseif {$docmd == \"-Q\"} {\n"
+" set str \"qry=$opt\"\n"
+" } else {\n"
+" set docmd \"\"\n"
+" continue\n"
+" }\n"
+"\n"
+" if {$db} {puts stderr \"run_remote_cmd_via_sock: $docmd \\\"$str\\\"\"}\n"
+" puts $client_sock $str\n"
+" if {$db} {puts stderr \"run_remote_cmd_via_sock: flush\"}\n"
+" flush $client_sock\n"
+" if {$db} {puts stderr \"run_remote_cmd_via_sock: gets\"}\n"
+" gets $client_sock res\n"
+" if {$db} {puts stderr \"run_remote_cmd_via_sock: \\\"$res\\\"\"}\n"
+" set res [string trim $res]\n"
+"\n"
+" set docmd \"\"\n"
+"\n"
+" if {$res != \"\"} {\n"
+" append result \"$res\\n\"\n"
+" }\n"
+" }\n"
+" \n"
+" setup_client_sock 1\n"
+"\n"
+" set result [string trim $result]\n"
+"\n"
+" return $result\n"
+"}\n"
+"\n"
"proc run_remote_cmd {opts} {\n"
" global menu_var x11vnc_prog x11vnc_cmdline x11vnc_xdisplay\n"
" global x11vnc_auth_file x11vnc_connect_file\n"
+" global client_sock\n"
"\n"
" set debug [in_debug_mode]\n"
"\n"
@@ -5195,6 +5479,17 @@
" }\n"
" }\n"
"\n"
+" if {$client_sock != \"\"} {\n"
+" menus_disable\n"
+" stop_watch on\n"
+" set result [run_remote_cmd_via_sock $opts]\n"
+" stop_watch off\n"
+" menus_enable\n"
+" if {$result != \"fail\"} {\n"
+" return $result\n"
+" }\n"
+" }\n"
+"\n"
" set cmd \"\"\n"
"\n"
" lappend cmd $x11vnc_prog;\n"
@@ -5218,7 +5513,6 @@
" }\n"
" lappend cmd \"2>\"\n"
" lappend cmd \"/dev/null\"\n"
-"# lappend cmd \"/tmp/nono\"\n"
"\n"
" if {0 || $debug} {\n"
" set str [join $cmd]\n"
@@ -5234,7 +5528,6 @@
" 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"
@@ -5265,6 +5558,8 @@
" global x11vnc_xdisplay connected_to_x11vnc reply_xdisplay\n"
" global menu_var unset_str\n"
"\n"
+" set db 0\n"
+"\n"
" if {! $connected_to_x11vnc} {\n"
" if {[info exists menu_var(display)]} {\n"
" set d $menu_var(display)\n"
@@ -5279,12 +5574,19 @@
" set rargs [list \"-Q\" \"ping\"]\n"
" set result [run_remote_cmd $rargs]\n"
"\n"
+" if {$db} {puts \"try_connect: \\\"$result\\\"\"}\n"
+"\n"
" if {[regexp {^ans=ping:} $result]} {\n"
" regsub {^ans=ping:} $result {} reply_xdisplay\n"
" set msg \"Connected to $reply_xdisplay\"\n"
" set_info $msg\n"
" append_text \"$msg\\n\"\n"
" set_connected yes\n"
+"\n"
+" setup_client_channel\n"
+" setup_client_sock 1\n"
+" setup_client_tail\n"
+"\n"
" fetch_displays\n"
" return 1\n"
" } else {\n"
@@ -5350,7 +5652,18 @@
"proc setup_client_tail {} {\n"
" global client_tail\n"
" if {$client_tail != \"\"} {\n"
-" fileevent $client_tail readable read_client_info\n"
+" fileevent $client_tail readable read_client_tail\n"
+" }\n"
+"}\n"
+"\n"
+"proc setup_client_sock {{enable 1}} {\n"
+" global client_sock\n"
+" if {$client_sock != \"\"} {\n"
+" if {$enable} {\n"
+" fileevent $client_sock readable read_client_sock\n"
+" } else {\n"
+" fileevent $client_sock readable \"\"\n"
+" }\n"
" }\n"
"}\n"
"\n"
@@ -5444,6 +5757,7 @@
"# main:\n"
"\n"
"global env x11vnc_prog x11vnc_cmdline x11vnc_xdisplay x11vnc_connect;\n"
+"global x11vnc_xdisplay0\n"
"global x11vnc_client_file x11vnc_gui_geom x11vnc_started vnc_url\n"
"global x11vnc_gui_params\n"
"global x11vnc_auth_file x11vnc_connect_file beginner_mode simple_gui_created\n"
@@ -5455,7 +5769,7 @@
"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 client_tail client_tail_read\n"
+"global last_query_all_time query_all_freq client_tail client_sock client_info_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"
@@ -5479,7 +5793,8 @@
"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 client_sock \"\"\n"
+"set client_info_read 0\n"
"set make_gui_count 0\n"
"set text_area_str \"\"\n"
"set gui_argv0 $argv0\n"
@@ -5545,6 +5860,7 @@
" if {$client_tail != \"\"} {\n"
" gets $client_tail tmp\n"
" if [eof $client_tail] {\n"
+"puts \"eof $client_tail\"\n"
" clean_client_tail\n"
" set client_tail \"\"\n"
" }\n"
@@ -5592,6 +5908,7 @@
" set x11vnc_started 1\n"
"}\n"
"\n"
+"set x11vnc_xdisplay \"\"\n"
"if {[info exists env(X11VNC_XDISPLAY)]} {\n"
" set x11vnc_xdisplay $env(X11VNC_XDISPLAY);\n"
" set x11vnc_connect 1\n"
@@ -5606,6 +5923,7 @@
"} else {\n"
" set x11vnc_xdisplay \":0\";\n"
"}\n"
+"set x11vnc_xdisplay0 $x11vnc_xdisplay\n"
"\n"
"if {[info exists env(X11VNC_AUTH_FILE)]} {\n"
" set x11vnc_auth_file $env(X11VNC_AUTH_FILE)\n"