Commit 2cc1b1d3 authored by runge's avatar runge

x11vnc: synchronous mode for -remote, string cleanup

parent f28038b2
2004-12-19 Karl Runge <runge@karlrunge.com>
* x11vnc: string cleanup, synchronous remote-control option -sync
* libvncserver/cursor.c: zero underCursorBufferLen when cursor freed.
2004-12-16 Karl Runge <runge@karlrunge.com> 2004-12-16 Karl Runge <runge@karlrunge.com>
* test/encodingstest.c: fix decl bug in main() * test/encodingstest.c: fix decl bug in main()
* x11vnc: use XFIXES extension to show the exact cursor shape. * x11vnc: use XFIXES extension to show the exact cursor shape.
......
...@@ -529,6 +529,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,rfbBool freeOld) ...@@ -529,6 +529,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,rfbBool freeOld)
free(rfbScreen->underCursorBuffer); free(rfbScreen->underCursorBuffer);
rfbScreen->underCursorBuffer=0; rfbScreen->underCursorBuffer=0;
rfbScreen->underCursorBufferLen=0;
if(rfbScreen->cursor && (freeOld || rfbScreen->cursor->cleanup)) if(rfbScreen->cursor && (freeOld || rfbScreen->cursor->cleanup))
rfbFreeCursor(rfbScreen->cursor); rfbFreeCursor(rfbScreen->cursor);
......
2004-12-19 Karl Runge <runge@karlrunge.com>
* cleanup putenv, snprint, other string manip.
* add -sync mode to remote control for better control
* allow -remote and -query at same time.
2004-12-16 Karl Runge <runge@karlrunge.com> 2004-12-16 Karl Runge <runge@karlrunge.com>
* support for XFIXES extension to show the exact cursor shape, * support for XFIXES extension to show the exact cursor shape,
working on Linux/Xorg and Solaris 10. disable with -noxfixes working on Linux/Xorg and Solaris 10. disable with -noxfixes
......
This diff is collapsed.
...@@ -47,6 +47,7 @@ catch {rename send {}} ...@@ -47,6 +47,7 @@ catch {rename send {}}
# Q means it is an action worth querying after running. # Q means it is an action worth querying after running.
# D means it is a good idea to delay a little before querying # D means it is a good idea to delay a little before querying
# (i.e. perhaps it causes x11vnc to do a lot of work, new fb) # (i.e. perhaps it causes x11vnc to do a lot of work, new fb)
# No longer used, -sync is used instead.
# P means the string can be +/- appended/deleted (string may not # P means the string can be +/- appended/deleted (string may not
# be the same after the remote command) # be the same after the remote command)
# G means gui internal item # G means gui internal item
...@@ -839,7 +840,8 @@ proc entry_delete {} { ...@@ -839,7 +840,8 @@ proc entry_delete {} {
# Utilities for remote control and updating vars. # Utilities for remote control and updating vars.
proc push_new_value {item name new {query 1}} { proc push_new_value0 {item name new {query 1}} {
# old way w/o -sync
global menu_var always_update remote_output query_output global menu_var always_update remote_output query_output
global delay_sleep extra_sleep extra_sleep_split global delay_sleep extra_sleep extra_sleep_split
...@@ -953,6 +955,125 @@ proc push_new_value {item name new {query 1}} { ...@@ -953,6 +955,125 @@ proc push_new_value {item name new {query 1}} {
} }
} }
proc push_new_value {item name new {query 1}} {
global menu_var always_update remote_output query_output
global delay_sleep extra_sleep extra_sleep_split
global query_result_list
set debug [in_debug_mode]
set getout 0
set print_getout 0;
set do_query_all 0
set newnew ""
if {$item == "disconnect"} {
set newnew "N/A"
set do_query_all 1
} elseif {$always_update} {
set do_query_all 1
}
if {$item == "remote-cmd"} {
# kludge for arbitrary remote command:
if {[regexp {^Q:} $new]} {
# extra kludge for Q:var to mean -Q var
regsub {^Q:} $new "" new
set qonly 1
} else {
set qonly 0
}
# need to extract item from new:
set qtmp $new
regsub {:.*$} $qtmp "" qtmp
if {$qonly} {
set rargs [list "-Q" "$qtmp"]
set print_getout 1
set qargs ""
} else {
set rargs [list "-R" "$new"]
set qargs ""
}
set getout 1
} elseif {[value_is_string $item]} {
# string var:
set rargs [list "-R" "$name:$new"]
set qargs [list "-Q" "$name"]
} else {
# boolean var:
set rargs [list "-R" "$name"]
set qargs [list "-Q" "$name"]
}
if {! $query && ! $always_update} {
set getout 1
} elseif {$item == "noremote"} {
set getout 1
} elseif {[is_action $item] && ![opt_match Q $item] && $rargs != ""} {
set getout 1
} elseif {[regexp {^(sid|id)$} $item] && ![regexp {^0x} $new]} {
set getout 1
}
set remote_output ""
set query_output ""
if {!$debug} {
append_text "x11vnc $rargs ..."
}
if {$getout} {
set remote_output [run_remote_cmd $rargs]
if {$print_getout} {
append_text "\t$remote_output"
}
append_text "\n"
return
}
if {$do_query_all} {
set all [all_query_vars]
set qargs [list "-Q" $all]
}
set rqargs [concat $rargs $qargs]
set query [run_remote_cmd $rqargs]
set query_output $query
set query_result_list ""
if {$newnew != ""} {
set new $newnew
}
if {![see_if_ok $query $item "$name:$new"]} {
# failed
if {[regexp {^a..=} $query]} {
# but some result came back
# synchronize everything with a 2nd call.
set query_output [query_all 1]
} else {
# server may be dead
if {$item != "ping" && $item != "attach"} {
try_connect
}
}
} else {
# succeeded
# synchronize this variable (or variables)
# for a speedup used the list parsed by see_if_ok.
update_menu_vars "USE_LIST"
if {$do_query_all} {
global all_settings
set all_settings $query
}
}
}
# For updating a string variable. Also used for simple OK/Skip dialogs # For updating a string variable. Also used for simple OK/Skip dialogs
# with entry = 0. # with entry = 0.
proc entry_dialog {item {entry 1}} { proc entry_dialog {item {entry 1}} {
...@@ -1042,14 +1163,25 @@ proc check_var {item} { ...@@ -1042,14 +1163,25 @@ proc check_var {item} {
} }
proc see_if_ok {query item expected} { proc see_if_ok {query item expected} {
global query_result_list
set ok 0 set ok 0
set found "" set found ""
foreach q [split_query $query] {
if {[regexp "^$item:" $q]} { set query_result_list [split_query $query]
foreach q $query_result_list {
# if {[regexp "^$item:" $q]} {
# set found $q
# }
if {[string first "$item:" $q] == 0} {
set found $q set found $q
} }
if {$q == $expected} { if {$q == $expected} {
set ok 1 set ok 1
if {$found != ""} {
break;
}
} }
} }
if {$found == ""} { if {$found == ""} {
...@@ -1076,23 +1208,26 @@ proc see_if_ok {query item expected} { ...@@ -1076,23 +1208,26 @@ proc see_if_ok {query item expected} {
} }
proc update_menu_vars {{query ""}} { proc update_menu_vars {{query ""}} {
global all_settings menu_var global all_settings menu_var query_result_list
set debug [in_debug_mode] set debug [in_debug_mode]
if {$query == ""} { if {$query == "USE_LIST"} {
set qstr $all_settings ;
} elseif {$query == ""} {
set query_result_list [split_query $all_settings]
} else { } else {
set qstr $query set query_result_list [split_query $query]
} }
foreach piece [split_query $qstr] {
foreach piece $query_result_list {
if {[regexp {^([^:][^:]*):(.*)$} $piece m0 item val]} { if {[regexp {^([^:][^:]*):(.*)$} $piece m0 item val]} {
if {[info exists menu_var($item)]} { if {[info exists menu_var($item)]} {
set old $menu_var($item) set old $menu_var($item)
if {$val == "N/A"} { if {$val == "N/A"} {
continue continue
} }
if {$debug} { if {0 && $debug} {
puts "setting menuvar: $item: $old -> $val" puts "setting menuvar: $item: $old -> $val"
} }
set menu_var($item) $val set menu_var($item) $val
...@@ -1127,7 +1262,12 @@ proc clear_all {} { ...@@ -1127,7 +1262,12 @@ proc clear_all {} {
proc all_query_vars {} { proc all_query_vars {} {
global query_ans_list query_aro_list all_settings global query_ans_list query_aro_list all_settings
global cache_all_query_vars
if {$cache_all_query_vars != ""} {
return $cache_all_query_vars
}
set qry "" set qry ""
foreach item $query_ans_list { foreach item $query_ans_list {
if {$qry == ""} { if {$qry == ""} {
...@@ -1143,6 +1283,8 @@ proc all_query_vars {} { ...@@ -1143,6 +1283,8 @@ proc all_query_vars {} {
append qry ",$item" append qry ",$item"
} }
} }
set cache_all_query_vars $qry
return $qry return $qry
} }
...@@ -1151,8 +1293,6 @@ proc query_all {{quiet 0}} { ...@@ -1151,8 +1293,6 @@ proc query_all {{quiet 0}} {
set qry [all_query_vars] set qry [all_query_vars]
#puts "into query_all $quiet"
set qargs [list "-Q" $qry] set qargs [list "-Q" $qry]
set all [run_remote_cmd $qargs] set all [run_remote_cmd $qargs]
...@@ -1282,13 +1422,25 @@ proc do_action {item} { ...@@ -1282,13 +1422,25 @@ proc do_action {item} {
} }
} }
proc ptime {time} {
set usec [lindex [split $time] 0]
set sec [format "%.3f" [expr "$usec / 1000000.0"]]
puts "time: $sec secs."
}
proc do_var {item} { proc do_var {item} {
global connected_to_x11vnc item_cascade menu_var global connected_to_x11vnc item_cascade menu_var
set debug [in_debug_mode]
set string 0 set string 0
if {[is_action $item]} { if {[is_action $item]} {
# Menu item is action: # Menu item is action:
do_action $item if {$debug} {
ptime [time {do_action $item}]
} else {
do_action $item
}
return return
} }
...@@ -1313,7 +1465,11 @@ proc do_var {item} { ...@@ -1313,7 +1465,11 @@ proc do_var {item} {
set new 1 set new 1
} }
if {$connected_to_x11vnc} { if {$connected_to_x11vnc} {
push_new_value $item $name $new 1 if {$debug} {
ptime [time {push_new_value $item $name $new 1}]
} else {
push_new_value $item $name $new 1
}
} }
} }
...@@ -1364,7 +1520,8 @@ proc value_is_bool {item} { ...@@ -1364,7 +1520,8 @@ proc value_is_bool {item} {
} }
} }
proc split_query {query} { proc split_query0 {query} {
# original slower way with regexp/regsub
regsub -all {aro=} $query {ans=} query regsub -all {aro=} $query {ans=} query
set items {} set items {}
while {1} { while {1} {
...@@ -1384,6 +1541,38 @@ proc split_query {query} { ...@@ -1384,6 +1541,38 @@ proc split_query {query} {
return $items return $items
} }
proc split_query {query} {
regsub -all {aro=} $query {ans=} query
set items {}
while {1} {
set n [string first "ans=" $query]
if {$n < 0} {
break
}
set from [expr $n+4]
set m [string first ",ans=" $query]
if {$m < 0} {
set more 0
set item [string range $query $from end]
} else {
set more 1
set to [expr $m-1]
set item [string range $query $from $to]
}
if {$item != ""} {
lappend items $item
}
if {$more} {
incr m
set query [string range $query $m end]
} else {
set query ""
}
}
return $items
}
proc set_x11_display {name} { proc set_x11_display {name} {
global x11_display global x11_display
set x11_display "x11vnc X display: $name" set x11_display "x11vnc X display: $name"
...@@ -1398,6 +1587,7 @@ proc no_x11_display {} { ...@@ -1398,6 +1587,7 @@ proc no_x11_display {} {
proc no_vnc_display {} { proc no_vnc_display {} {
set_vnc_display "(*none*)" set_vnc_display "(*none*)"
} }
proc fetch_displays {} { proc fetch_displays {} {
set qargs [list "-Q" "display,vncdisplay"] set qargs [list "-Q" "display,vncdisplay"]
...@@ -1899,6 +2089,8 @@ proc get_start_x11vnc_cmd {} { ...@@ -1899,6 +2089,8 @@ proc get_start_x11vnc_cmd {} {
lappend cmd $x11vnc_prog lappend cmd $x11vnc_prog
set saw_id 0
foreach item [lsort [array names menu_var]] { foreach item [lsort [array names menu_var]] {
if {![active_when_starting $item]} { if {![active_when_starting $item]} {
continue continue
...@@ -1906,6 +2098,27 @@ proc get_start_x11vnc_cmd {} { ...@@ -1906,6 +2098,27 @@ proc get_start_x11vnc_cmd {} {
if {[is_action $item]} { if {[is_action $item]} {
continue continue
} }
if {$item == "debug_gui"} {
continue
}
if {$item == "id" || $item == "sid"} {
set val $menu_var($item);
if {$val == "0x0" || $val == "root"} {
continue
}
}
if {$item == "sid" && $saw_id} {
continue
}
if {$item == "id"} {
set saw_id 1
}
if {$item == "progressive" && $menu_var($item) == "0"} {
continue
}
if {$item == "dontdisconnect" && $menu_var($item) == "-1"} {
continue
}
if {[value_is_bool $item]} { if {[value_is_bool $item]} {
if {[info exists menu_var($item)]} { if {[info exists menu_var($item)]} {
...@@ -1917,7 +2130,11 @@ proc get_start_x11vnc_cmd {} { ...@@ -1917,7 +2130,11 @@ proc get_start_x11vnc_cmd {} {
if {[info exists menu_var($item)]} { if {[info exists menu_var($item)]} {
if {$menu_var($item) != "" if {$menu_var($item) != ""
&& $menu_var($item) != $unset_str} { && $menu_var($item) != $unset_str} {
lappend cmd "-$item" set nitem $item
if {$nitem == "screen_blank"} {
set nitem "sb"
}
lappend cmd "-$nitem"
lappend cmd $menu_var($item) lappend cmd $menu_var($item)
} }
} }
...@@ -1996,6 +2213,7 @@ proc run_remote_cmd {opts} { ...@@ -1996,6 +2213,7 @@ proc run_remote_cmd {opts} {
lappend cmd "-display" lappend cmd "-display"
lappend cmd $x11vnc_xdisplay lappend cmd $x11vnc_xdisplay
} }
lappend cmd "-sync"
foreach word $opts { foreach word $opts {
lappend cmd $word lappend cmd $word
} }
...@@ -2011,11 +2229,18 @@ if {0} { ...@@ -2011,11 +2229,18 @@ if {0} {
} }
set output "" set output ""
menus_disable
stop_watch on stop_watch on
catch {set output [eval exec $cmd]} catch {set output [eval exec $cmd]}
stop_watch off stop_watch off
menus_enable
if {$debug} { if {$debug} {
append_text "output: $output\n" if {[string length $output] > 100} {
set str [string range $output 0 100]
append_text "output: $str ...\n"
} else {
append_text "output: $output\n"
}
} }
return $output return $output
} }
...@@ -2083,6 +2308,7 @@ global menu_var unset_str ...@@ -2083,6 +2308,7 @@ global menu_var unset_str
global bfont global bfont
global connected_to_x11vnc global connected_to_x11vnc
global delay_sleep extra_sleep extra_sleep_split global delay_sleep extra_sleep extra_sleep_split
global cache_all_query_vars
set unset_str "(unset)" set unset_str "(unset)"
set connected_to_x11vnc 0 set connected_to_x11vnc 0
...@@ -2093,9 +2319,9 @@ set help_indent 24; ...@@ -2093,9 +2319,9 @@ set help_indent 24;
set reply_xdisplay "" set reply_xdisplay ""
set all_settings "None so far." set all_settings "None so far."
set always_update 1 set always_update 1
set cache_all_query_vars ""
#set delay_sleep 500 # these are no longer used under x11vnc -sync:
#set extra_sleep 1500
set delay_sleep 350 set delay_sleep 350
set extra_sleep 1000 set extra_sleep 1000
set extra_sleep_split 4 set extra_sleep_split 4
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "December 2004" "x11vnc " "User Commands" .TH X11VNC "1" "December 2004" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.6.3pre, lastmod: 2004-12-17 version: 0.6.3pre, lastmod: 2004-12-19
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -661,28 +661,36 @@ To include button events use "Button1", ... etc. ...@@ -661,28 +661,36 @@ To include button events use "Button1", ... etc.
.PP .PP
\fB-nodragging\fR \fB-nodragging\fR
.IP .IP
Do not update the display during mouse dragging events Do not update the display during mouse dragging
(mouse motion with a button held down). Greatly events (mouse motion with a button held down).
improves response on slow setups, but you lose all Greatly improves response on slow setups, but you lose
visual feedback for drags, text selection, and some all visual feedback for drags, text selection, and some
menu traversals. menu traversals. It overrides any \fB-pointer_mode\fR setting
(think of it as pointer_mode 0)
.PP .PP
\fB-pointer_mode\fR \fIn\fR \fB-pointer_mode\fR \fIn\fR
.IP .IP
Various pointer update schemes. The problem is pointer Various pointer update schemes. The problem is pointer
motion can cause rapid changes on the screen, e.g. a motion can cause rapid changes on the screen, e.g. a
window drag. Neither x11vnc nor the bandwidth to the window drag. Neither x11vnc's screen polling nor the
vncviewers can keep up these rapid screen changes: bandwidth to the vncviewers can keep up these rapid
everything bogs down when dragging or scrolling. screen changes: everything bogs down when dragging
Note that most video h/w is optimized for writing, not or scrolling. Note that most video h/w is optimized
reading (a 50X rate difference is possible) and x11vnc for writing, not reading (a 50X rate difference is
is reading all the time. So a scheme has to be used to possible) and x11vnc is reading all the time. So a
"eat" much of that pointer input before re-polling the scheme has to be used to "eat" much of that pointer
screen. n can be 1 to 4. n=1 was the original scheme input before re-polling the screen. n can be 1 to 4.
used to about Jan 2004. n=2 is an improved scheme. .IP
n=3 is basically a dynamic \fB-nodragging\fR mode: it detects n=1 was the original scheme used to about Jan 2004: it
if the mouse drag motion has paused and refreshes basically just skips \fB-input_skip\fR pointer events before
the display. n=4 is TBD. The default n is 2. repolling the screen. n=2 is an improved scheme:
by watching the current rate it tries to detect if
it should try to "eat" more pointer events. n=3 is
basically a dynamic \fB-nodragging\fR mode: it detects if the
mouse drag motion has paused and refreshes the display.
n=4 is TBD, it will try measure screen read and client
write rates and try to insert "frames" between the
on/off states of mode 3. The default n is 2.
.PP .PP
\fB-input_skip\fR \fIn\fR \fB-input_skip\fR \fIn\fR
.IP .IP
...@@ -1157,6 +1165,27 @@ button_mask mouse_x mouse_y bpp depth indexed_color ...@@ -1157,6 +1165,27 @@ button_mask mouse_x mouse_y bpp depth indexed_color
dpy_x dpy_y rfbport rfbwait rfbauth passwd alwaysshared dpy_x dpy_y rfbport rfbwait rfbauth passwd alwaysshared
dontdisconnect httpdir enablehttpproxy dontdisconnect httpdir enablehttpproxy
.PP .PP
\fB-sync\fR
.IP
By default \fB-remote\fR commands are run asynchronously, that
is, the request is posted and the program immediately
exits. Use \fB-sync\fR to have the program wait for an
acknowledgement from the x11vnc server that command
was processed. On the other hand \fB-query\fR requests are
always processed synchronously because they have wait
for the result.
.IP
Also note that if both \fB-remote\fR and \fB-query\fR requests are
supplied on the command line, the \fB-remote\fR is processed
first (synchronously: no need for \fB-sync),\fR and then
the \fB-query\fR request is processed in the normal way.
This allows for a reliable way to see if the \fB-remote\fR
command was processed by querying for any new settings.
Note however that there is timeout of a few seconds so
if the x11vnc takes longer than that to process the
requests the requestor will think that a failure has
taken place.
.PP
\fB-noremote\fR \fB-noremote\fR
.IP .IP
Do not process any remote control commands or queries. Do not process any remote control commands or queries.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment