summaryrefslogtreecommitdiffstats
path: root/x11vnc/tkx11vnc.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/tkx11vnc.h')
-rw-r--r--x11vnc/tkx11vnc.h262
1 files changed, 244 insertions, 18 deletions
diff --git a/x11vnc/tkx11vnc.h b/x11vnc/tkx11vnc.h
index 83891fe..63db7dd 100644
--- a/x11vnc/tkx11vnc.h
+++ b/x11vnc/tkx11vnc.h
@@ -53,6 +53,7 @@
"# Q means it is an action worth querying after running.\n"
"# D means it is a good idea to delay a little before querying \n"
"# (i.e. perhaps it causes x11vnc to do a lot of work, new fb)\n"
+"# No longer used, -sync is used instead.\n"
"# P means the string can be +/- appended/deleted (string may not\n"
"# be the same after the remote command)\n"
"# G means gui internal item\n"
@@ -845,7 +846,8 @@
"\n"
"# Utilities for remote control and updating vars.\n"
"\n"
-"proc push_new_value {item name new {query 1}} {\n"
+"proc push_new_value0 {item name new {query 1}} {\n"
+" # old way w/o -sync\n"
" global menu_var always_update remote_output query_output\n"
" global delay_sleep extra_sleep extra_sleep_split\n"
"\n"
@@ -959,6 +961,125 @@
" }\n"
"}\n"
"\n"
+"proc push_new_value {item name new {query 1}} {\n"
+" global menu_var always_update remote_output query_output\n"
+" global delay_sleep extra_sleep extra_sleep_split\n"
+" global query_result_list\n"
+"\n"
+" set debug [in_debug_mode]\n"
+"\n"
+" set getout 0\n"
+" set print_getout 0;\n"
+"\n"
+" set do_query_all 0\n"
+"\n"
+" set newnew \"\"\n"
+" if {$item == \"disconnect\"} {\n"
+" set newnew \"N/A\"\n"
+" set do_query_all 1\n"
+" } elseif {$always_update} {\n"
+" set do_query_all 1\n"
+" }\n"
+"\n"
+" if {$item == \"remote-cmd\"} {\n"
+" # kludge for arbitrary remote command:\n"
+" if {[regexp {^Q:} $new]} {\n"
+" # extra kludge for Q:var to mean -Q var\n"
+" regsub {^Q:} $new \"\" new\n"
+" set qonly 1\n"
+" } else {\n"
+" set qonly 0\n"
+" }\n"
+" # need to extract item from new:\n"
+" set qtmp $new\n"
+" regsub {:.*$} $qtmp \"\" qtmp\n"
+" if {$qonly} {\n"
+" set rargs [list \"-Q\" \"$qtmp\"]\n"
+" set print_getout 1\n"
+" set qargs \"\"\n"
+" } else {\n"
+" set rargs [list \"-R\" \"$new\"]\n"
+" set qargs \"\"\n"
+" }\n"
+" set getout 1\n"
+"\n"
+" } elseif {[value_is_string $item]} {\n"
+" # string var:\n"
+" set rargs [list \"-R\" \"$name:$new\"]\n"
+" set qargs [list \"-Q\" \"$name\"]\n"
+" } else {\n"
+" # boolean var:\n"
+" set rargs [list \"-R\" \"$name\"]\n"
+" set qargs [list \"-Q\" \"$name\"]\n"
+" }\n"
+"\n"
+" if {! $query && ! $always_update} {\n"
+" set getout 1\n"
+" } elseif {$item == \"noremote\"} {\n"
+" set getout 1\n"
+" } elseif {[is_action $item] && ![opt_match Q $item] && $rargs != \"\"} {\n"
+" set getout 1\n"
+" } elseif {[regexp {^(sid|id)$} $item] && ![regexp {^0x} $new]} {\n"
+" set getout 1\n"
+" }\n"
+"\n"
+" set remote_output \"\"\n"
+" set query_output \"\"\n"
+"\n"
+" if {!$debug} {\n"
+" append_text \"x11vnc $rargs ...\"\n"
+" }\n"
+"\n"
+" if {$getout} {\n"
+" set remote_output [run_remote_cmd $rargs]\n"
+" if {$print_getout} {\n"
+" append_text \"\\t$remote_output\"\n"
+" }\n"
+" append_text \"\\n\"\n"
+" return\n"
+" }\n"
+"\n"
+" if {$do_query_all} {\n"
+" set all [all_query_vars]\n"
+" set qargs [list \"-Q\" $all]\n"
+" }\n"
+"\n"
+" set rqargs [concat $rargs $qargs]\n"
+"\n"
+" set query [run_remote_cmd $rqargs]\n"
+" set query_output $query\n"
+"\n"
+" set query_result_list \"\"\n"
+"\n"
+" if {$newnew != \"\"} {\n"
+" set new $newnew\n"
+" }\n"
+"\n"
+" if {![see_if_ok $query $item \"$name:$new\"]} {\n"
+" # failed\n"
+" if {[regexp {^a..=} $query]} {\n"
+" # but some result came back\n"
+" # synchronize everything with a 2nd call.\n"
+" set query_output [query_all 1]\n"
+" } else {\n"
+" # server may be dead\n"
+" if {$item != \"ping\" && $item != \"attach\"} {\n"
+" try_connect\n"
+" }\n"
+" }\n"
+" } else {\n"
+" # succeeded\n"
+" # synchronize this variable (or variables)\n"
+" # for a speedup used the list parsed by see_if_ok.\n"
+" update_menu_vars \"USE_LIST\"\n"
+"\n"
+" if {$do_query_all} {\n"
+" global all_settings\n"
+" set all_settings $query\n"
+" }\n"
+" }\n"
+"}\n"
+"\n"
"# For updating a string variable. Also used for simple OK/Skip dialogs\n"
"# with entry = 0.\n"
"proc entry_dialog {item {entry 1}} {\n"
@@ -1048,14 +1169,25 @@
"}\n"
"\n"
"proc see_if_ok {query item expected} {\n"
+" global query_result_list\n"
+"\n"
" set ok 0\n"
" set found \"\"\n"
-" foreach q [split_query $query] {\n"
-" if {[regexp \"^$item:\" $q]} {\n"
+"\n"
+" set query_result_list [split_query $query]\n"
+"\n"
+" foreach q $query_result_list {\n"
+"# if {[regexp \"^$item:\" $q]} {\n"
+"# set found $q\n"
+"# }\n"
+" if {[string first \"$item:\" $q] == 0} {\n"
" set found $q\n"
" }\n"
" if {$q == $expected} {\n"
" set ok 1\n"
+" if {$found != \"\"} {\n"
+" break;\n"
+" }\n"
" }\n"
" }\n"
" if {$found == \"\"} {\n"
@@ -1082,23 +1214,26 @@
"}\n"
"\n"
"proc update_menu_vars {{query \"\"}} {\n"
-" global all_settings menu_var\n"
+" global all_settings menu_var query_result_list\n"
"\n"
" set debug [in_debug_mode]\n"
"\n"
-" if {$query == \"\"} {\n"
-" set qstr $all_settings\n"
+" if {$query == \"USE_LIST\"} {\n"
+" ;\n"
+" } elseif {$query == \"\"} {\n"
+" set query_result_list [split_query $all_settings]\n"
" } else {\n"
-" set qstr $query\n"
+" set query_result_list [split_query $query]\n"
" }\n"
-" foreach piece [split_query $qstr] {\n"
+"\n"
+" foreach piece $query_result_list {\n"
" if {[regexp {^([^:][^:]*):(.*)$} $piece m0 item val]} {\n"
" if {[info exists menu_var($item)]} {\n"
" set old $menu_var($item)\n"
" if {$val == \"N/A\"} {\n"
" continue\n"
" }\n"
-" if {$debug} {\n"
+" if {0 && $debug} {\n"
" puts \"setting menuvar: $item: $old -> $val\"\n"
" }\n"
" set menu_var($item) $val\n"
@@ -1133,7 +1268,12 @@
"\n"
"proc all_query_vars {} {\n"
" global query_ans_list query_aro_list all_settings\n"
+" global cache_all_query_vars\n"
" \n"
+" if {$cache_all_query_vars != \"\"} {\n"
+" return $cache_all_query_vars\n"
+" }\n"
+"\n"
" set qry \"\"\n"
" foreach item $query_ans_list {\n"
" if {$qry == \"\"} {\n"
@@ -1149,6 +1289,8 @@
" append qry \",$item\"\n"
" }\n"
" }\n"
+" set cache_all_query_vars $qry\n"
+"\n"
" return $qry\n"
"}\n"
"\n"
@@ -1157,8 +1299,6 @@
"\n"
" set qry [all_query_vars]\n"
"\n"
-" #puts \"into query_all $quiet\"\n"
-"\n"
" set qargs [list \"-Q\" $qry]\n"
" set all [run_remote_cmd $qargs]\n"
"\n"
@@ -1288,13 +1428,25 @@
" }\n"
"}\n"
"\n"
+"proc ptime {time} {\n"
+" set usec [lindex [split $time] 0]\n"
+" set sec [format \"%.3f\" [expr \"$usec / 1000000.0\"]]\n"
+" puts \"time: $sec secs.\"\n"
+"}\n"
+"\n"
"proc do_var {item} {\n"
" global connected_to_x11vnc item_cascade menu_var\n"
"\n"
+" set debug [in_debug_mode]\n"
+"\n"
" set string 0\n"
" if {[is_action $item]} {\n"
" # Menu item is action:\n"
-" do_action $item\n"
+" if {$debug} {\n"
+" ptime [time {do_action $item}]\n"
+" } else {\n"
+" do_action $item\n"
+" }\n"
" return\n"
" }\n"
"\n"
@@ -1319,7 +1471,11 @@
" set new 1\n"
" }\n"
" if {$connected_to_x11vnc} {\n"
-" push_new_value $item $name $new 1\n"
+" if {$debug} {\n"
+" ptime [time {push_new_value $item $name $new 1}]\n"
+" } else {\n"
+" push_new_value $item $name $new 1\n"
+" }\n"
" }\n"
"}\n"
"\n"
@@ -1370,7 +1526,8 @@
" }\n"
"}\n"
"\n"
-"proc split_query {query} {\n"
+"proc split_query0 {query} {\n"
+" # original slower way with regexp/regsub\n"
" regsub -all {aro=} $query {ans=} query\n"
" set items {}\n"
" while {1} {\n"
@@ -1390,6 +1547,38 @@
" return $items\n"
"}\n"
"\n"
+"proc split_query {query} {\n"
+" regsub -all {aro=} $query {ans=} query\n"
+" set items {}\n"
+" while {1} {\n"
+" set n [string first \"ans=\" $query]\n"
+" if {$n < 0} {\n"
+" break\n"
+" }\n"
+" set from [expr $n+4]\n"
+"\n"
+" set m [string first \",ans=\" $query]\n"
+" if {$m < 0} {\n"
+" set more 0\n"
+" set item [string range $query $from end]\n"
+" } else {\n"
+" set more 1\n"
+" set to [expr $m-1]\n"
+" set item [string range $query $from $to]\n"
+" }\n"
+" if {$item != \"\"} {\n"
+" lappend items $item\n"
+" }\n"
+" if {$more} {\n"
+" incr m\n"
+" set query [string range $query $m end]\n"
+" } else {\n"
+" set query \"\"\n"
+" }\n"
+" }\n"
+" return $items\n"
+"}\n"
+"\n"
"proc set_x11_display {name} {\n"
" global x11_display\n"
" set x11_display \"x11vnc X display: $name\"\n"
@@ -1404,6 +1593,7 @@
"proc no_vnc_display {} {\n"
" set_vnc_display \"(*none*)\"\n"
"}\n"
+"\n"
"proc fetch_displays {} {\n"
"\n"
" set qargs [list \"-Q\" \"display,vncdisplay\"]\n"
@@ -1905,6 +2095,8 @@
"\n"
" lappend cmd $x11vnc_prog\n"
"\n"
+" set saw_id 0\n"
+"\n"
" foreach item [lsort [array names menu_var]] {\n"
" if {![active_when_starting $item]} {\n"
" continue\n"
@@ -1912,6 +2104,27 @@
" if {[is_action $item]} {\n"
" continue\n"
" }\n"
+" if {$item == \"debug_gui\"} {\n"
+" continue\n"
+" }\n"
+" if {$item == \"id\" || $item == \"sid\"} {\n"
+" set val $menu_var($item);\n"
+" if {$val == \"0x0\" || $val == \"root\"} {\n"
+" continue\n"
+" }\n"
+" }\n"
+" if {$item == \"sid\" && $saw_id} {\n"
+" continue\n"
+" }\n"
+" if {$item == \"id\"} {\n"
+" set saw_id 1\n"
+" }\n"
+" if {$item == \"progressive\" && $menu_var($item) == \"0\"} {\n"
+" continue\n"
+" }\n"
+" if {$item == \"dontdisconnect\" && $menu_var($item) == \"-1\"} {\n"
+" continue\n"
+" }\n"
"\n"
" if {[value_is_bool $item]} {\n"
" if {[info exists menu_var($item)]} {\n"
@@ -1923,7 +2136,11 @@
" if {[info exists menu_var($item)]} {\n"
" if {$menu_var($item) != \"\"\n"
" && $menu_var($item) != $unset_str} {\n"
-" lappend cmd \"-$item\"\n"
+" set nitem $item\n"
+" if {$nitem == \"screen_blank\"} {\n"
+" set nitem \"sb\"\n"
+" }\n"
+" lappend cmd \"-$nitem\"\n"
" lappend cmd $menu_var($item)\n"
" }\n"
" }\n"
@@ -2002,6 +2219,7 @@
" lappend cmd \"-display\"\n"
" lappend cmd $x11vnc_xdisplay\n"
" }\n"
+" lappend cmd \"-sync\"\n"
" foreach word $opts {\n"
" lappend cmd $word\n"
" }\n"
@@ -2017,11 +2235,18 @@
"}\n"
"\n"
" set output \"\"\n"
+" menus_disable\n"
" stop_watch on\n"
" catch {set output [eval exec $cmd]}\n"
" stop_watch off\n"
+" menus_enable\n"
" if {$debug} {\n"
-" append_text \"output: $output\\n\"\n"
+" if {[string length $output] > 100} {\n"
+" set str [string range $output 0 100]\n"
+" append_text \"output: $str ...\\n\"\n"
+" } else {\n"
+" append_text \"output: $output\\n\"\n"
+" }\n"
" }\n"
" return $output\n"
"}\n"
@@ -2089,6 +2314,7 @@
"global bfont\n"
"global connected_to_x11vnc\n"
"global delay_sleep extra_sleep extra_sleep_split\n"
+"global cache_all_query_vars\n"
"\n"
"set unset_str \"(unset)\"\n"
"set connected_to_x11vnc 0\n"
@@ -2099,9 +2325,9 @@
"set reply_xdisplay \"\"\n"
"set all_settings \"None so far.\"\n"
"set always_update 1\n"
+"set cache_all_query_vars \"\"\n"
"\n"
-"#set delay_sleep 500\n"
-"#set extra_sleep 1500\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"
OpenPOWER on IntegriCloud