Commit 543e64d3 authored by runge's avatar runge

main.c: XReadScreen check, fix 64bit use of cursors, x11vnc: first round of...

 main.c: XReadScreen check, fix 64bit use of cursors, x11vnc: first round of beta-testing fixes, RFE's.
parent 50568f1a
2005-06-14 Karl Runge <runge@karlrunge.com>
* configure.ac: XReadScreen and XReadDisplay checks.
* libvncserver/cursor.c: fix unsigned long crash for 64bits.
* x11vnc: first round of beta-testing fixes, RFE's.
2005-06-10 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> 2005-06-10 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* configure.ac: fix that annoying SUN /usr/ccs location of "ar" * configure.ac: fix that annoying SUN /usr/ccs location of "ar"
......
...@@ -58,6 +58,8 @@ AH_TEMPLATE(HAVE_LIBXFIXES, [XFIXES extension build environment present]) ...@@ -58,6 +58,8 @@ AH_TEMPLATE(HAVE_LIBXFIXES, [XFIXES extension build environment present])
AH_TEMPLATE(HAVE_LIBXDAMAGE, [XDAMAGE extension build environment present]) AH_TEMPLATE(HAVE_LIBXDAMAGE, [XDAMAGE extension build environment present])
AH_TEMPLATE(HAVE_LIBXTRAP, [DEC-XTRAP extension build environment present]) AH_TEMPLATE(HAVE_LIBXTRAP, [DEC-XTRAP extension build environment present])
AH_TEMPLATE(HAVE_RECORD, [RECORD extension build environment present]) AH_TEMPLATE(HAVE_RECORD, [RECORD extension build environment present])
AH_TEMPLATE(HAVE_SOLARIS_XREADSCREEN, [Solaris XReadScreen available])
AH_TEMPLATE(HAVE_IRIX_XREADDISPLAY, [IRIX XReadDisplay available])
if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
AC_CHECK_LIB(X11, XGetImage, HAVE_X="true", AC_CHECK_LIB(X11, XGetImage, HAVE_X="true",
HAVE_X="false", HAVE_X="false",
...@@ -70,6 +72,14 @@ if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then ...@@ -70,6 +72,14 @@ if test "$X_CFLAGS" != "-DX_DISPLAY_MISSING"; then
[AC_DEFINE(HAVE_XSHM)], , [AC_DEFINE(HAVE_XSHM)], ,
$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS) $X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
AC_CHECK_LIB(Xext, XReadScreen,
[AC_DEFINE(HAVE_SOLARIS_XREADSCREEN)], ,
$X_LIBS $X_PRELIBS -lX11 $X_EXTRA_LIBS)
AC_CHECK_HEADER(X11/extensions/readdisplay.h,
[AC_DEFINE(HAVE_IRIX_XREADDISPLAY)], ,
[#include <X11/Xlib.h>])
AC_CHECK_LIB(Xtst, XTestGrabControl, AC_CHECK_LIB(Xtst, XTestGrabControl,
X_PRELIBS="$X_PRELIBS -lXtst" X_PRELIBS="$X_PRELIBS -lXtst"
[AC_DEFINE(HAVE_XTESTGRABCONTROL) HAVE_XTESTGRABCONTROL="true"], , [AC_DEFINE(HAVE_XTESTGRABCONTROL) HAVE_XTESTGRABCONTROL="true"], ,
......
...@@ -525,7 +525,7 @@ void rfbShowCursor(rfbClientPtr cl) ...@@ -525,7 +525,7 @@ void rfbShowCursor(rfbClientPtr cl)
int gmax, gshift; int gmax, gshift;
int bmax, bshift; int bmax, bshift;
int amax = 255; /* alphaSource is always 8bits of info per pixel */ int amax = 255; /* alphaSource is always 8bits of info per pixel */
unsigned long rmask, gmask, bmask; unsigned int rmask, gmask, bmask;
rmax = s->serverFormat.redMax; rmax = s->serverFormat.redMax;
gmax = s->serverFormat.greenMax; gmax = s->serverFormat.greenMax;
...@@ -544,8 +544,9 @@ void rfbShowCursor(rfbClientPtr cl) ...@@ -544,8 +544,9 @@ void rfbShowCursor(rfbClientPtr cl)
* we loop over the whole cursor ignoring c->mask[], * we loop over the whole cursor ignoring c->mask[],
* using the extracted alpha value instead. * using the extracted alpha value instead.
*/ */
char *dest, *src, *aptr; char *dest;
unsigned long val, *dv, *sv; unsigned char *src, *aptr;
unsigned int val, dval, sval;
int rdst, gdst, bdst; /* fb RGB */ int rdst, gdst, bdst; /* fb RGB */
int asrc, rsrc, gsrc, bsrc; /* rich source ARGB */ int asrc, rsrc, gsrc, bsrc; /* rich source ARGB */
...@@ -553,23 +554,42 @@ void rfbShowCursor(rfbClientPtr cl) ...@@ -553,23 +554,42 @@ void rfbShowCursor(rfbClientPtr cl)
src = c->richSource + (j+j1)*c->width*bpp + (i+i1)*bpp; src = c->richSource + (j+j1)*c->width*bpp + (i+i1)*bpp;
aptr = c->alphaSource + (j+j1)*c->width + (i+i1); aptr = c->alphaSource + (j+j1)*c->width + (i+i1);
dv = (unsigned long *)dest; asrc = *aptr;
sv = (unsigned long *)src;
asrc = *((unsigned char *)aptr);
if (!asrc) { if (!asrc) {
continue; continue;
} }
if (bpp == 1) {
dval = *((unsigned char*) dest);
sval = *((unsigned char*) src);
} else if (bpp == 2) {
dval = *((unsigned short*) dest);
sval = *((unsigned short*) src);
} else if (bpp == 3) {
unsigned char *dst = (unsigned char *) dest;
dval = 0;
dval |= ((*(dst+0)) << 0);
dval |= ((*(dst+1)) << 8);
dval |= ((*(dst+2)) << 16);
sval = 0;
sval |= ((*(src+0)) << 0);
sval |= ((*(src+1)) << 8);
sval |= ((*(src+2)) << 16);
} else if (bpp == 4) {
dval = *((unsigned int*) dest);
sval = *((unsigned int*) src);
} else {
continue;
}
/* extract dest and src RGB */ /* extract dest and src RGB */
rdst = (*dv & rmask) >> rshift; /* fb */ rdst = (dval & rmask) >> rshift; /* fb */
gdst = (*dv & gmask) >> gshift; gdst = (dval & gmask) >> gshift;
bdst = (*dv & bmask) >> bshift; bdst = (dval & bmask) >> bshift;
rsrc = (*sv & rmask) >> rshift; /* richcursor */ rsrc = (sval & rmask) >> rshift; /* richcursor */
gsrc = (*sv & gmask) >> gshift; gsrc = (sval & gmask) >> gshift;
bsrc = (*sv & bmask) >> bshift; bsrc = (sval & bmask) >> bshift;
/* blend in fb data. */ /* blend in fb data. */
if (! c->alphaPreMultiplied) { if (! c->alphaPreMultiplied) {
......
2005-06-14 Karl Runge <runge@karlrunge.com>
* -DNOGUI and -DVIEWONLY build options
* -noskip_dups the default (windows viewer sends no ups when
repeating)
* HAVE_SOLARIS_XREADSCREEN and HAVE_IRIX_XREADDISPLAY
* Alt+Button+Motion to wireframe. tunable in WIREFRAME_PARMS
* copyrect now the default under -scale (works OK, but must
send a cleanup update)
* fix -pedantic and Sun cc warnings and errors (unsigned, etc..)
* print out fatal error messages under -quiet
* -seldir to control and debug selection transfers.
* fix crashes on 64bit wrt unsigned long in rich cursors.
* fix kde guessing errors
* more scrolling and wireframe tweaks.
2005-06-03 Karl Runge <runge@karlrunge.com> 2005-06-03 Karl Runge <runge@karlrunge.com>
* make scrollcopyrect more or less usable under -scale * make scrollcopyrect more or less usable under -scale
* add -fixscreen for periodic cleanup of painting errors. * add -fixscreen for periodic cleanup of painting errors.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -164,16 +164,18 @@ Misc ...@@ -164,16 +164,18 @@ Misc
-- D -- D
=F rc: =F rc:
norc norc
nolookup
-- --
nofb nofb
-- --
=D nobell =D nobell
=D nosel =D nosel
noprimary noprimary
nolookup seldir:
-- --
xtrap xtrap
xrecord xrecord
=RA reset_record
-- --
bg bg
=-C:ignore,exit sigpipe: =-C:ignore,exit sigpipe:
......
...@@ -170,16 +170,18 @@ ...@@ -170,16 +170,18 @@
" -- D\n" " -- D\n"
" =F rc:\n" " =F rc:\n"
" norc\n" " norc\n"
" nolookup\n"
" --\n" " --\n"
" nofb\n" " nofb\n"
" --\n" " --\n"
" =D nobell\n" " =D nobell\n"
" =D nosel\n" " =D nosel\n"
" noprimary\n" " noprimary\n"
" nolookup\n" " seldir:\n"
" --\n" " --\n"
" xtrap\n" " xtrap\n"
" xrecord\n" " xrecord\n"
" =RA reset_record\n"
" --\n" " --\n"
" bg\n" " bg\n"
" =-C:ignore,exit sigpipe:\n" " =-C:ignore,exit sigpipe:\n"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "June 2005" "x11vnc " "User Commands" .TH X11VNC "1" "June 2005" "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.7.2, lastmod: 2005-06-03 version: 0.7.2, lastmod: 2005-06-14
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -186,13 +186,17 @@ the notation "m/n" may be used to denote fractions ...@@ -186,13 +186,17 @@ the notation "m/n" may be used to denote fractions
exactly, e.g. \fB-scale\fR 2/3 exactly, e.g. \fB-scale\fR 2/3
.IP .IP
Scaling Options: can be added after \fIfraction\fR via Scaling Options: can be added after \fIfraction\fR via
":", to supply multiple ":" options use commas. If ":", to supply multiple ":" options use commas.
you just want a quick, rough scaling without blending, If you just want a quick, rough scaling without
append ":nb" to \fIfraction\fR (e.g. \fB-scale\fR 1/3:nb). blending, append ":nb" to \fIfraction\fR (e.g. \fB-scale\fR
No blending is the default for 8bpp indexed color, to 1/3:nb). No blending is the default for 8bpp indexed
force blending for this case use ":fb". By default color, to force blending for this case use ":fb".
\fB-scrollcopyrect\fR and \fB-wirecopyrect\fR are disabled under .IP
\fB-scale,\fR to enable them use ":cr". To disable \fB-scrollcopyrect\fR and \fB-wirecopyrect\fR under
\fB-scale\fR use ":nocr". If you need to to enable them use
":cr" or specify them explicitly on the command line.
If a slow link is detected, ":nocr" may be applied
automatically. Default: :cr
.IP .IP
More esoteric options: for compatibility with vncviewers More esoteric options: for compatibility with vncviewers
the scaled width is adjusted to be a multiple of 4: the scaled width is adjusted to be a multiple of 4:
...@@ -717,10 +721,14 @@ Example: "\fB-skip_keycodes\fR \fI94,114\fR" ...@@ -717,10 +721,14 @@ Example: "\fB-skip_keycodes\fR \fI94,114\fR"
\fB-skip_dups,\fR \fB-noskip_dups\fR \fB-skip_dups,\fR \fB-noskip_dups\fR
.IP .IP
Some VNC viewers send impossible repeated key events, Some VNC viewers send impossible repeated key events,
e.g. key-down, key-down, key-up, key-up all for the e.g. key-down, key-down, key-up, key-up all for the same
same key, or 20 downs in a row for the same key! key, or 20 downs in a row for the same modifier key!
Setting \fB-skip_dups\fR means to skip these duplicates and Setting \fB-skip_dups\fR means to skip these duplicates and
just process the first event. Default: \fB-skip_dups\fR just process the first event. Note: some VNC viewers
assume they can send down's without the corresponding
up's and so you should not set this option for
these viewers (symptom: some keys do not autorepeat)
Default: \fB-noskip_dups\fR
.PP .PP
\fB-add_keysyms,\fR \fB-noadd_keysyms\fR \fB-add_keysyms,\fR \fB-noadd_keysyms\fR
.IP .IP
...@@ -834,6 +842,15 @@ Do not poll the PRIMARY selection for changes to send ...@@ -834,6 +842,15 @@ Do not poll the PRIMARY selection for changes to send
back to clients. (PRIMARY is still set on received back to clients. (PRIMARY is still set on received
changes, however). changes, however).
.PP .PP
\fB-seldir\fR \fIstring\fR
.IP
If direction string is "send", only send the selection
to viewers, and if it is "recv" only receive it from
viewers. To work around apps setting the selection
too frequently and messing up the other end. You can
actually supply a comma separated list of directions,
including "debug" to turn on debugging output.
.PP
\fB-cursor\fR \fI[mode],\fR \fB-nocursor\fR \fB-cursor\fR \fI[mode],\fR \fB-nocursor\fR
.IP .IP
Sets how the pointer cursor shape (little icon at the Sets how the pointer cursor shape (little icon at the
...@@ -1032,8 +1049,8 @@ Shorter aliases: \fB-wf\fR [str] and \fB-nowf\fR ...@@ -1032,8 +1049,8 @@ Shorter aliases: \fB-wf\fR [str] and \fB-nowf\fR
The value "str" is optional and, of course, is The value "str" is optional and, of course, is
packed with many tunable parameters for this scheme: packed with many tunable parameters for this scheme:
.IP .IP
Format: shade,linewidth,percent,T+B+L+R,t1+t2+t3+t4 Format: shade,linewidth,percent,T+B+L+R,mod,t1+t2+t3+t4
Default: 0xff,3,0,32+8+8+8,0.15+0.30+5.0+0.125 Default: 0xff,3,0,32+8+8+8,all,0.15+0.30+5.0+0.125
.IP .IP
If you leave nothing between commas: ",," the default If you leave nothing between commas: ",," the default
value is used. If you don't specify enough commas, value is used. If you don't specify enough commas,
...@@ -1055,6 +1072,14 @@ This is a speedup to quickly exclude a window from being ...@@ -1055,6 +1072,14 @@ This is a speedup to quickly exclude a window from being
wireframed: set them all to zero to not try the speedup wireframed: set them all to zero to not try the speedup
(scrolling and selecting text will likely be slower). (scrolling and selecting text will likely be slower).
.IP .IP
"mod" specifies if a button down event in the
interior of the window with a modifier key (Alt, Shift,
etc.) down should indicate a wireframe opportunity.
It can be "0" or "none" to skip it, "1" or "all"
to apply it to any modifier, or "Shift", "Alt",
"Control", "Meta", "Super", or "Hyper" to only
apply for that type of modifier key.
.IP
"t1+t2+t3+t4" specify four floating point times in "t1+t2+t3+t4" specify four floating point times in
seconds: t1 is how long to wait for the pointer to move, seconds: t1 is how long to wait for the pointer to move,
t2 is how long to wait for the window to start moving t2 is how long to wait for the window to start moving
...@@ -1082,10 +1107,11 @@ the window was not covered by any other windows, and ...@@ -1082,10 +1107,11 @@ the window was not covered by any other windows, and
region (this may look odd as the remaining pieces come region (this may look odd as the remaining pieces come
in, but helps on a slow link). Default: "always" in, but helps on a slow link). Default: "always"
.IP .IP
Note: there can be painting errors when using \fB-scale\fR Note: there can be painting errors or slow response
so CopyRect is skipped when scaling unless you specify when using \fB-scale\fR so you may want to disable CopyRect
"\fB-wirecopyrect\fR \fIalways\fR" on the command line or by in this case "\fB-wirecopyrect\fR \fInever\fR" on the command
remote-control. Or you can also use "\fB-scale\fR \fIxxx:cr\fR" line or by remote-control. Or you can also use the
"\fB-scale\fR \fIxxx:nocr\fR" scale option.
.PP .PP
\fB-debug_wireframe\fR \fB-debug_wireframe\fR
.IP .IP
...@@ -1131,16 +1157,24 @@ may be seen when using this mode: ...@@ -1131,16 +1157,24 @@ may be seen when using this mode:
4 Super_L's in a row: reset RECORD context, 4 Super_L's in a row: reset RECORD context,
5 Super_L's in a row: try to push a black screen 5 Super_L's in a row: try to push a black screen
.IP .IP
note: Alt_L is the Left "Alt" key (a single key)
Super_L is the Left "Super" key (Windows flag).
Both of these are modifier keys, and so should not
generate characters when pressed by themselves. Also,
your VNC viewer may have its own refresh hot-key
or button.
.IP
"mode" can be "never" (same as \fB-noscrollcopyrect)\fR "mode" can be "never" (same as \fB-noscrollcopyrect)\fR
to never try the copyrect, "keys" means to try it to never try the copyrect, "keys" means to try it
in response to keystrokes only, "mouse" means to in response to keystrokes only, "mouse" means to
try it in response to mouse events only, "always" try it in response to mouse events only, "always"
means to do both. Default: "always" means to do both. Default: "always"
.IP .IP
Note: there can be painting errors when using \fB-scale\fR Note: there can be painting errors or slow response
so CopyRect is skipped when scaling unless you specify when using \fB-scale\fR so you may want to disable CopyRect
"\fB-scrollcopyrect\fR \fIalways\fR" on the command line or by in this case "\fB-scrollcopyrect\fR \fInever\fR" on the command
remote-control. You can also use "\fB-scale\fR \fIxxx:cr\fR" line or by remote-control. Or you can also use the
"\fB-scale\fR \fIxxx:nocr\fR" scale option.
.PP .PP
\fB-scr_area\fR \fIn\fR \fB-scr_area\fR \fIn\fR
.IP .IP
...@@ -1303,22 +1337,22 @@ it is intended for cases when the \fB-scrollcopyrect\fR or ...@@ -1303,22 +1337,22 @@ it is intended for cases when the \fB-scrollcopyrect\fR or
but it can be used for any scenario. This option but it can be used for any scenario. This option
periodically performs costly operations and so periodically performs costly operations and so
interactive response may be reduced when it is on. interactive response may be reduced when it is on.
The 3 Alt_L's in a row described under \fB-scrollcopyrect\fR The 3 Alt_L's (the Left "Alt" key) taps in a row
can be used instead to manually request a screen repaint described under \fB-scrollcopyrect\fR can be used instead to
when it is needed. manually request a screen repaint when it is needed.
.IP .IP
\fIstring\fR is a comma separated list of one or more \fIstring\fR is a comma separated list of one or more of
of the following: "V=t", "C=t", and "X=t". the following: "V=t", "C=t", and "X=t". In these
In these "t" stands for a time in seconds (it is "t" stands for a time in seconds (it is a floating
a floating point even though one should usually use point even though one should usually use values > 2 to
values > 2 to avoid wasting resources). V sets how avoid wasting resources). V sets how frequently the
frequently the entire screen should be sent to viewers entire screen should be sent to viewers (it is like the
(it is like the 3 Alt_L's). C sets how long after a 3 Alt_L's). C sets how long to wait after a CopyRect
CopyRect the full screen should be repainted. X sets to repaint the full screen. X sets how frequently
how frequently to reread the full X11 framebuffer from to reread the full X11 framebuffer from the X server
the X server and push it out to connected viewers. and push it out to connected viewers. Use of X should
Use of X should be rare. Examples: \fB-fixscreen\fR V=10 be rare, please report a bug if you find you need it.
\fB-fixscreen\fR C=10 Examples: \fB-fixscreen\fR V=10 \fB-fixscreen\fR C=10
.PP .PP
\fB-debug_scroll\fR \fB-debug_scroll\fR
.IP .IP
...@@ -1945,6 +1979,8 @@ noprimary enable \fB-noprimary\fR mode. ...@@ -1945,6 +1979,8 @@ noprimary enable \fB-noprimary\fR mode.
.IP .IP
primary disable \fB-noprimary\fR mode. primary disable \fB-noprimary\fR mode.
.IP .IP
seldir:str set \fB-seldir\fR to "str"
.IP
cursor:mode enable \fB-cursor\fR "mode". cursor:mode enable \fB-cursor\fR "mode".
.IP .IP
show_cursor enable showing a cursor. show_cursor enable showing a cursor.
...@@ -2022,6 +2058,8 @@ noxrecord disable all use of RECORD extension. ...@@ -2022,6 +2058,8 @@ noxrecord disable all use of RECORD extension.
.IP .IP
xrecord enable use of RECORD extension. xrecord enable use of RECORD extension.
.IP .IP
reset_record reset RECORD extension (if avail.).
.IP
pointer_mode:n set \fB-pointer_mode\fR to n. same as "pm" pointer_mode:n set \fB-pointer_mode\fR to n. same as "pm"
.IP .IP
input_skip:n set \fB-input_skip\fR to n. input_skip:n set \fB-input_skip\fR to n.
...@@ -2180,14 +2218,6 @@ in these cases the value returned is "N/A". To direct ...@@ -2180,14 +2218,6 @@ in these cases the value returned is "N/A". To direct
a query straight to the VNC_CONNECT property or connect a query straight to the VNC_CONNECT property or connect
file use "qry=..." instead of "cmd=..." file use "qry=..." instead of "cmd=..."
.IP .IP
Here is the current list of "variables" that can
be supplied to the \fB-query\fR command. This includes the
"N/A" ones that return no useful info. For variables
names that do not correspond to an x11vnc option or
remote command, we hope the name makes it obvious what
the returned value corresponds to (hint: the ext_*
variables correspond to the presence of X extensions):
.IP
ans= stop quit exit shutdown ping blacken zero ans= stop quit exit shutdown ping blacken zero
refresh reset close disconnect id sid waitmapped refresh reset close disconnect id sid waitmapped
nowaitmapped clip flashcmap noflashcmap shiftcmap nowaitmapped clip flashcmap noflashcmap shiftcmap
...@@ -2204,23 +2234,23 @@ xrandr noxrandr xrandr_mode padgeom quiet q noquiet ...@@ -2204,23 +2234,23 @@ xrandr noxrandr xrandr_mode padgeom quiet q noquiet
modtweak nomodtweak xkb noxkb skip_keycodes skip_dups modtweak nomodtweak xkb noxkb skip_keycodes skip_dups
noskip_dups add_keysyms noadd_keysyms clear_mods noskip_dups add_keysyms noadd_keysyms clear_mods
noclear_mods clear_keys noclear_keys remap repeat noclear_mods clear_keys noclear_keys remap repeat
norepeat fb nofb bell nobell sel nosel primary noprimary norepeat fb nofb bell nobell sel nosel primary
cursorshape nocursorshape cursorpos nocursorpos cursor noprimary seldir cursorshape nocursorshape cursorpos
show_cursor noshow_cursor nocursor arrow xfixes nocursorpos cursor show_cursor noshow_cursor nocursor
noxfixes xdamage noxdamage xd_area xd_mem alphacut arrow xfixes noxfixes xdamage noxdamage xd_area xd_mem
alphafrac alpharemove noalpharemove alphablend alphacut alphafrac alpharemove noalpharemove alphablend
noalphablend xwarppointer xwarp noxwarppointer noalphablend xwarppointer xwarp noxwarppointer noxwarp
noxwarp buttonmap dragging nodragging wireframe_mode buttonmap dragging nodragging wireframe_mode wireframe
wireframe wf nowireframe nowf wirecopyrect wcr wf nowireframe nowf wirecopyrect wcr nowirecopyrect
nowirecopyrect nowcr scr_area scr_skip scr_inc scr_keys nowcr scr_area scr_skip scr_inc scr_keys scr_term
scr_term scr_keyrepeat scr_parms scrollcopyrect scr scr_keyrepeat scr_parms scrollcopyrect scr
noscrollcopyrect noscr fixscreen noxrecord xrecord noscrollcopyrect noscr fixscreen noxrecord xrecord
pointer_mode pm input_skip input client_input speeds reset_record pointer_mode pm input_skip input
debug_pointer dp nodebug_pointer nodp debug_keyboard client_input speeds debug_pointer dp nodebug_pointer
dk nodebug_keyboard nodk deferupdate defer wait_ui nodp debug_keyboard dk nodebug_keyboard nodk deferupdate
wait_bog nowait_bog wait readtimeout nap nonap sb defer wait_ui wait_bog nowait_bog wait readtimeout
screen_blank fs gaps grow fuzz snapfb nosnapfb nap nonap sb screen_blank fs gaps grow fuzz snapfb
rawfb progressive rfbport http nohttp httpport nosnapfb rawfb progressive rfbport http nohttp httpport
httpdir enablehttpproxy noenablehttpproxy alwaysshared httpdir enablehttpproxy noenablehttpproxy alwaysshared
noalwaysshared nevershared noalwaysshared dontdisconnect noalwaysshared nevershared noalwaysshared dontdisconnect
nodontdisconnect desktop debug_xevents nodebug_xevents nodontdisconnect desktop debug_xevents nodebug_xevents
...@@ -2230,19 +2260,19 @@ debug_wireframe debug_scroll nodebug_scroll debug_scroll ...@@ -2230,19 +2260,19 @@ debug_wireframe debug_scroll nodebug_scroll debug_scroll
debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg
nodbg noremote nodbg noremote
.IP .IP
aro= display vncdisplay desktopname http_url auth aro= display vncdisplay desktopname guess_desktop
users rootshift clipshift scale_str scaled_x scaled_y http_url auth users rootshift clipshift scale_str
scale_numer scale_denom scale_fac scaling_blend scaled_x scaled_y scale_numer scale_denom
scaling_nomult4 scaling_pad scaling_interpolate inetd scale_fac scaling_blend scaling_nomult4 scaling_pad
privremote unsafe safer nocmds passwdfile using_shm scaling_interpolate inetd privremote unsafe safer nocmds
logfile o flag rc norc h help V version lastmod bg passwdfile using_shm logfile o flag rc norc h help V
sigpipe threads readrate netrate netlatency pipeinput version lastmod bg sigpipe threads readrate netrate
clients client_count pid ext_xtest ext_xtrap ext_xrecord netlatency pipeinput clients client_count pid ext_xtest
ext_xkb ext_xshm ext_xinerama ext_overlay ext_xfixes ext_xtrap ext_xrecord ext_xkb ext_xshm ext_xinerama
ext_xdamage ext_xrandr rootwin num_buttons button_mask ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin
mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y num_buttons button_mask mouse_x mouse_y bpp depth
wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y indexed_color dpy_x dpy_y wdpy_x wdpy_y off_x off_y
rfbauth passwd cdpy_x cdpy_y coff_x coff_y rfbauth passwd
.PP .PP
\fB-sync\fR \fB-sync\fR
.IP .IP
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; version 2 of the License.
* (at your option) any later version.
* *
* This software is distributed in the hope that it will be useful, * This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -174,12 +173,13 @@ ...@@ -174,12 +173,13 @@
* -DSCROLL_COPYRECT=0 to have -noscrollcopyrect as the default. * -DSCROLL_COPYRECT=0 to have -noscrollcopyrect as the default.
* -DSCROLL_COPYRECT_PARMS=... set default -scrollcopyrect parameters. * -DSCROLL_COPYRECT_PARMS=... set default -scrollcopyrect parameters.
* -DXDAMAGE=0 to have -noxdamage as the default. * -DXDAMAGE=0 to have -noxdamage as the default.
* -DSKIDPUPS=0 to have -noskip_dups as the default. * -DSKIPDUPS=0 to have -noskip_dups as the default or vice versa.
* *
* -DPOINTER_MODE_DEFAULT={0,1,2,3,4} set default -pointer_mode. * -DPOINTER_MODE_DEFAULT={0,1,2,3,4} set default -pointer_mode.
* -DBOLDLY_CLOSE_DISPLAY=0 to not close X DISPLAY under -rawfb. * -DBOLDLY_CLOSE_DISPLAY=0 to not close X DISPLAY under -rawfb.
* -DSMALL_FOOTPRINT=1 for smaller binary size (no help, no gui, etc) * -DSMALL_FOOTPRINT=1 for smaller binary size (no help, no gui, etc)
* use 2 or 3 for even smaller footprint. * use 2 or 3 for even smaller footprint.
* -DNOGUI do not include the gui tkx11vnc.
* *
* Set these in CPPFLAGS before running configure. E.g.: * Set these in CPPFLAGS before running configure. E.g.:
* *
...@@ -209,6 +209,10 @@ ...@@ -209,6 +209,10 @@
#define SMALL_FOOTPRINT 0 #define SMALL_FOOTPRINT 0
#endif #endif
#if SMALL_FOOTPRINT
#define NOGUI
#endif
#if (SMALL_FOOTPRINT > 1) #if (SMALL_FOOTPRINT > 1)
#define LIBVNCSERVER_HAVE_XKEYBOARD 0 #define LIBVNCSERVER_HAVE_XKEYBOARD 0
#define LIBVNCSERVER_HAVE_LIBXINERAMA 0 #define LIBVNCSERVER_HAVE_LIBXINERAMA 0
...@@ -308,20 +312,26 @@ extern int h_errno; ...@@ -308,20 +312,26 @@ extern int h_errno;
/* solaris/sun */ /* solaris/sun */
#if defined (__SVR4) && defined (__sun) #if defined (__SVR4) && defined (__sun)
#define SOLARIS # define SOLARIS
#define SOLARIS_OVERLAY # ifdef LIBVNCSERVER_HAVE_SOLARIS_XREADSCREEN
#define OVERLAY_OS # define SOLARIS_OVERLAY
# define OVERLAY_OS
# endif
#endif #endif
#ifdef SOLARIS_OVERLAY #ifdef SOLARIS_OVERLAY
#include <X11/extensions/transovl.h> #include <X11/extensions/transovl.h>
#endif #endif
/* irix/sgi */ /* irix/sgi */
#if defined(__sgi) #if defined(__sgi)
#define IRIX # define IRIX
#define IRIX_OVERLAY # ifdef LIBVNCSERVER_HAVE_IRIX_XREADDISPLAY
#define OVERLAY_OS # define IRIX_OVERLAY
# define OVERLAY_OS
# endif
#endif #endif
#ifdef IRIX_OVERLAY #ifdef IRIX_OVERLAY
#include <X11/extensions/readdisplay.h> #include <X11/extensions/readdisplay.h>
#endif #endif
...@@ -372,7 +382,7 @@ double xdamage_scheduled_mark = 0.0; ...@@ -372,7 +382,7 @@ double xdamage_scheduled_mark = 0.0;
sraRegionPtr xdamage_scheduled_mark_region = NULL; sraRegionPtr xdamage_scheduled_mark_region = NULL;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.7.2 lastmod: 2005-06-03"; char lastmod[] = "0.7.2 lastmod: 2005-06-14";
int hack_val = 0; int hack_val = 0;
/* X display info */ /* X display info */
...@@ -473,6 +483,7 @@ int scaling_interpolate = 0; /* use interpolation scheme when shrinking */ ...@@ -473,6 +483,7 @@ int scaling_interpolate = 0; /* use interpolation scheme when shrinking */
int scaled_x = 0, scaled_y = 0; /* dimensions of scaled display */ int scaled_x = 0, scaled_y = 0; /* dimensions of scaled display */
int scale_numer = 0, scale_denom = 0; /* n/m */ int scale_numer = 0, scale_denom = 0; /* n/m */
/* scale cursor */ /* scale cursor */
char *scale_cursor_str = NULL; char *scale_cursor_str = NULL;
double scale_cursor_fac = 1.0; double scale_cursor_fac = 1.0;
...@@ -811,7 +822,10 @@ char *listen_str = NULL; ...@@ -811,7 +822,10 @@ char *listen_str = NULL;
char *allow_once = NULL; /* one time -allow */ char *allow_once = NULL; /* one time -allow */
char *accept_cmd = NULL; /* for -accept */ char *accept_cmd = NULL; /* for -accept */
char *gone_cmd = NULL; /* for -gone */ char *gone_cmd = NULL; /* for -gone */
int view_only = 0; /* clients can only watch. */ #ifndef VIEWONLY
#define VIEWONLY 0
#endif
int view_only = VIEWONLY; /* clients can only watch. */
char *allowed_input_view_only = NULL; char *allowed_input_view_only = NULL;
char *allowed_input_normal = NULL; char *allowed_input_normal = NULL;
char *allowed_input_str = NULL; char *allowed_input_str = NULL;
...@@ -881,7 +895,7 @@ int show_dragging = 1; /* process mouse movement events */ ...@@ -881,7 +895,7 @@ int show_dragging = 1; /* process mouse movement events */
int wireframe = WIREFRAME; /* try to emulate wireframe wm moves */ int wireframe = WIREFRAME; /* try to emulate wireframe wm moves */
/* shade,linewidth,percent,T+B+L+R,t1+t2+t3+t4 */ /* shade,linewidth,percent,T+B+L+R,t1+t2+t3+t4 */
#ifndef WIREFRAME_PARMS #ifndef WIREFRAME_PARMS
#define WIREFRAME_PARMS "0xff,3,0,32+8+8+8,0.15+0.30+5.0+0.125" #define WIREFRAME_PARMS "0xff,3,0,32+8+8+8,all,0.15+0.30+5.0+0.125"
#endif #endif
char *wireframe_str = NULL; char *wireframe_str = NULL;
char *wireframe_copyrect = NULL; char *wireframe_copyrect = NULL;
...@@ -937,6 +951,12 @@ char *scroll_key_list_str = NULL; ...@@ -937,6 +951,12 @@ char *scroll_key_list_str = NULL;
KeySym *scroll_key_list = NULL; KeySym *scroll_key_list = NULL;
int pointer_queued_sent = 0; int pointer_queued_sent = 0;
#ifndef SCALING_COPYRECT
#define SCALING_COPYRECT 1
#endif
int scaling_copyrect0 = SCALING_COPYRECT;
int scaling_copyrect = SCALING_COPYRECT;
int scrollcopyrect_min_area = 60000; /* minimum rectangle area */ int scrollcopyrect_min_area = 60000; /* minimum rectangle area */
int debug_scroll = 0; int debug_scroll = 0;
double pointer_flush_delay = 0.0; double pointer_flush_delay = 0.0;
...@@ -997,7 +1017,7 @@ int sound_bell = 1; /* actually send it */ ...@@ -997,7 +1017,7 @@ int sound_bell = 1; /* actually send it */
int xkbcompat = 0; /* ignore XKEYBOARD extension */ int xkbcompat = 0; /* ignore XKEYBOARD extension */
int use_xkb_modtweak = 0; /* -xkb */ int use_xkb_modtweak = 0; /* -xkb */
#ifndef SKIPDUPS #ifndef SKIPDUPS
#define SKIPDUPS 1 #define SKIPDUPS 0
#endif #endif
int skip_duplicate_key_events = SKIPDUPS; int skip_duplicate_key_events = SKIPDUPS;
char *skip_keycodes = NULL; char *skip_keycodes = NULL;
...@@ -1041,6 +1061,7 @@ int ui_skip = 10; /* see watchloop. negative means ignore input */ ...@@ -1041,6 +1061,7 @@ int ui_skip = 10; /* see watchloop. negative means ignore input */
int watch_selection = 1; /* normal selection/cutbuffer maintenance */ int watch_selection = 1; /* normal selection/cutbuffer maintenance */
int watch_primary = 1; /* more dicey, poll for changes in PRIMARY */ int watch_primary = 1; /* more dicey, poll for changes in PRIMARY */
char *sel_direction = NULL; /* "send" or "recv" for one-way */
char *sigpipe = NULL; /* skip, ignore, exit */ char *sigpipe = NULL; /* skip, ignore, exit */
...@@ -1206,7 +1227,7 @@ char *lblanks(char *str) { ...@@ -1206,7 +1227,7 @@ char *lblanks(char *str) {
int scan_hexdec(char *str, unsigned long *num) { int scan_hexdec(char *str, unsigned long *num) {
if (sscanf(str, "0x%lx", num) != 1) { if (sscanf(str, "0x%lx", num) != 1) {
if (sscanf(str, "%ld", num) != 1) { if (sscanf(str, "%lu", num) != 1) {
return 0; return 0;
} }
} }
...@@ -1241,7 +1262,7 @@ int parse_geom(char *str, int *wp, int *hp, int *xp, int *yp, int W, int H) { ...@@ -1241,7 +1262,7 @@ int parse_geom(char *str, int *wp, int *hp, int *xp, int *yp, int W, int H) {
void set_env(char *name, char *value) { void set_env(char *name, char *value) {
char *str; char *str;
str = (char *)malloc(strlen(name)+strlen(value)+2); str = (char *) malloc(strlen(name)+strlen(value)+2);
sprintf(str, "%s=%s", name, value); sprintf(str, "%s=%s", name, value);
putenv(str); putenv(str);
} }
...@@ -1255,6 +1276,7 @@ int pick_windowid(unsigned long *num) { ...@@ -1255,6 +1276,7 @@ int pick_windowid(unsigned long *num) {
set_env("DISPLAY", use_dpy); set_env("DISPLAY", use_dpy);
} }
if (no_external_cmds) { if (no_external_cmds) {
rfbLogEnable(1);
rfbLog("cannot run external commands in -nocmds mode:\n"); rfbLog("cannot run external commands in -nocmds mode:\n");
rfbLog(" \"%s\"\n", "xwininfo"); rfbLog(" \"%s\"\n", "xwininfo");
rfbLog(" exiting.\n"); rfbLog(" exiting.\n");
...@@ -1608,7 +1630,7 @@ char **user_list(char *user_str) { ...@@ -1608,7 +1630,7 @@ char **user_list(char *user_str) {
n++; n++;
} }
} }
list = (char **) malloc((n+1)*(sizeof(char *))); list = (char **) malloc((n+1)*sizeof(char *));
p = strtok(user_str, ","); p = strtok(user_str, ",");
i = 0; i = 0;
...@@ -1996,7 +2018,7 @@ int switch_user(char *user, int fb_mode) { ...@@ -1996,7 +2018,7 @@ int switch_user(char *user, int fb_mode) {
user2uid(user, &uid, &name, &home); user2uid(user, &uid, &name, &home);
if (uid == -1 || uid == 0) { if (uid == (uid_t) -1 || uid == 0) {
return 0; return 0;
} }
...@@ -2186,7 +2208,8 @@ int dotted_ip(char *host) { ...@@ -2186,7 +2208,8 @@ int dotted_ip(char *host) {
int get_port(int sock, int remote) { int get_port(int sock, int remote) {
struct sockaddr_in saddr; struct sockaddr_in saddr;
int saddr_len, saddr_port; unsigned int saddr_len;
int saddr_port;
saddr_len = sizeof(saddr); saddr_len = sizeof(saddr);
memset(&saddr, 0, sizeof(saddr)); memset(&saddr, 0, sizeof(saddr));
...@@ -2213,7 +2236,8 @@ int get_local_port(int sock) { ...@@ -2213,7 +2236,8 @@ int get_local_port(int sock) {
char *get_host(int sock, int remote) { char *get_host(int sock, int remote) {
struct sockaddr_in saddr; struct sockaddr_in saddr;
int saddr_len, saddr_port; unsigned int saddr_len;
int saddr_port;
char *saddr_ip_str = NULL; char *saddr_ip_str = NULL;
saddr_len = sizeof(saddr); saddr_len = sizeof(saddr);
...@@ -2326,7 +2350,7 @@ char *ident_username(rfbClientPtr client) { ...@@ -2326,7 +2350,7 @@ char *ident_username(rfbClientPtr client) {
} }
newhost = ip2host(client->host); newhost = ip2host(client->host);
len = strlen(user) + 1 + strlen(newhost) + 1; len = strlen(user) + 1 + strlen(newhost) + 1;
str = (char *)malloc(len); str = (char *) malloc(len);
sprintf(str, "%s@%s", user, newhost); sprintf(str, "%s@%s", user, newhost);
free(newhost); free(newhost);
return str; return str;
...@@ -2438,15 +2462,20 @@ XImage *xreadscreen(Display *disp, Drawable d, int x, int y, ...@@ -2438,15 +2462,20 @@ XImage *xreadscreen(Display *disp, Drawable d, int x, int y,
#ifdef SOLARIS_OVERLAY #ifdef SOLARIS_OVERLAY
return XReadScreen(disp, d, x, y, width, height, return XReadScreen(disp, d, x, y, width, height,
show_cursor); show_cursor);
#endif #else
#ifdef IRIX_OVERLAY # ifdef IRIX_OVERLAY
{ unsigned long hints = 0, hints_ret; { unsigned long hints = 0, hints_ret;
if (show_cursor) hints |= XRD_READ_POINTER; if (show_cursor) hints |= XRD_READ_POINTER;
return XReadDisplay(disp, d, x, y, width, height, return XReadDisplay(disp, d, x, y, width, height,
hints, &hints_ret); hints, &hints_ret);
} }
#endif # else
/* unused vars warning: */
if (disp || d || x || y || width || height || show_cursor) {}
return NULL; return NULL;
# endif
#endif
} }
XImage *XGetSubImage_wr(Display *disp, Drawable d, int x, int y, XImage *XGetSubImage_wr(Display *disp, Drawable d, int x, int y,
...@@ -2539,7 +2568,8 @@ XImage *XCreateImage_wr(Display *disp, Visual *visual, unsigned int depth, ...@@ -2539,7 +2568,8 @@ XImage *XCreateImage_wr(Display *disp, Visual *visual, unsigned int depth,
void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) {
char *src, *dst; char *src, *dst;
int line, pixelsize = bpp/8; unsigned int line;
int pixelsize = bpp/8;
int bpl = wdpy_x * pixelsize; int bpl = wdpy_x * pixelsize;
if (clipshift) { if (clipshift) {
...@@ -2600,7 +2630,8 @@ void copy_image(XImage *dest, int x, int y, unsigned int w, unsigned int h) { ...@@ -2600,7 +2630,8 @@ void copy_image(XImage *dest, int x, int y, unsigned int w, unsigned int h) {
if (use_snapfb && snap_fb && dest != snaprect) { if (use_snapfb && snap_fb && dest != snaprect) {
char *src, *dst; char *src, *dst;
int line, pixelsize = bpp/8; unsigned int line;
int pixelsize = bpp/8;
src = snap->data + snap->bytes_per_line*y + pixelsize*x; src = snap->data + snap->bytes_per_line*y + pixelsize*x;
dst = dest->data; dst = dest->data;
...@@ -2613,7 +2644,8 @@ void copy_image(XImage *dest, int x, int y, unsigned int w, unsigned int h) { ...@@ -2613,7 +2644,8 @@ void copy_image(XImage *dest, int x, int y, unsigned int w, unsigned int h) {
} else if (raw_fb) { } else if (raw_fb) {
copy_raw_fb(dest, x, y, w, h); copy_raw_fb(dest, x, y, w, h);
} else if (using_shm && w == dest->width && h == dest->height) { } else if (using_shm && (int) w == dest->width &&
(int) h == dest->height) {
XShmGetImage_wr(dpy, window, dest, x, y, AllPlanes); XShmGetImage_wr(dpy, window, dest, x, y, AllPlanes);
} else { } else {
...@@ -2639,6 +2671,9 @@ void XTRAP_FakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, ...@@ -2639,6 +2671,9 @@ void XTRAP_FakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
DEBUG_SKIPPED_INPUT(debug_keyboard, "keyboard: no-XTRAP"); DEBUG_SKIPPED_INPUT(debug_keyboard, "keyboard: no-XTRAP");
return; return;
} }
/* unused vars warning: */
if (dpy || key || down || delay) {}
#if LIBVNCSERVER_HAVE_LIBXTRAP #if LIBVNCSERVER_HAVE_LIBXTRAP
XESimulateXEventRequest(trap_ctx, down ? KeyPress : KeyRelease, XESimulateXEventRequest(trap_ctx, down ? KeyPress : KeyRelease,
key, 0, 0, 0); key, 0, 0, 0);
...@@ -2661,7 +2696,8 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down, ...@@ -2661,7 +2696,8 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
} }
if (xtrap_input) { if (xtrap_input) {
return XTRAP_FakeKeyEvent_wr(dpy, key, down, delay); XTRAP_FakeKeyEvent_wr(dpy, key, down, delay);
return;
} }
if (! xtest_present) { if (! xtest_present) {
...@@ -2684,6 +2720,9 @@ void XTRAP_FakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, ...@@ -2684,6 +2720,9 @@ void XTRAP_FakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
DEBUG_SKIPPED_INPUT(debug_keyboard, "button: no-XTRAP"); DEBUG_SKIPPED_INPUT(debug_keyboard, "button: no-XTRAP");
return; return;
} }
/* unused vars warning: */
if (dpy || button || is_press || delay) {}
#if LIBVNCSERVER_HAVE_LIBXTRAP #if LIBVNCSERVER_HAVE_LIBXTRAP
XESimulateXEventRequest(trap_ctx, XESimulateXEventRequest(trap_ctx,
is_press ? ButtonPress : ButtonRelease, button, 0, 0, 0); is_press ? ButtonPress : ButtonRelease, button, 0, 0, 0);
...@@ -2696,7 +2735,8 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press, ...@@ -2696,7 +2735,8 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
unsigned long delay) { unsigned long delay) {
if (xtrap_input) { if (xtrap_input) {
return XTRAP_FakeButtonEvent_wr(dpy, button, is_press, delay); XTRAP_FakeButtonEvent_wr(dpy, button, is_press, delay);
return;
} }
if (! xtest_present) { if (! xtest_present) {
...@@ -2719,6 +2759,9 @@ void XTRAP_FakeMotionEvent_wr(Display* dpy, int screen, int x, int y, ...@@ -2719,6 +2759,9 @@ void XTRAP_FakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
DEBUG_SKIPPED_INPUT(debug_keyboard, "motion: no-XTRAP"); DEBUG_SKIPPED_INPUT(debug_keyboard, "motion: no-XTRAP");
return; return;
} }
/* unused vars warning: */
if (dpy || screen || x || y || delay) {}
#if LIBVNCSERVER_HAVE_LIBXTRAP #if LIBVNCSERVER_HAVE_LIBXTRAP
XESimulateXEventRequest(trap_ctx, MotionNotify, 0, x, y, 0); XESimulateXEventRequest(trap_ctx, MotionNotify, 0, x, y, 0);
#else #else
...@@ -2730,7 +2773,8 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y, ...@@ -2730,7 +2773,8 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
unsigned long delay) { unsigned long delay) {
if (xtrap_input) { if (xtrap_input) {
return XTRAP_FakeMotionEvent_wr(dpy, screen, x, y, delay); XTRAP_FakeMotionEvent_wr(dpy, screen, x, y, delay);
return;
} }
if (debug_pointer) { if (debug_pointer) {
...@@ -2787,6 +2831,8 @@ Bool XETrapQueryExtension_wr(Display *dpy, int *ev, int *er, int *op) { ...@@ -2787,6 +2831,8 @@ Bool XETrapQueryExtension_wr(Display *dpy, int *ev, int *er, int *op) {
return XETrapQueryExtension(dpy, (INT32 *)ev, (INT32 *)er, return XETrapQueryExtension(dpy, (INT32 *)ev, (INT32 *)er,
(INT32 *)op); (INT32 *)op);
#else #else
/* unused vars warning: */
if (dpy || ev || er || op) {}
return False; return False;
#endif #endif
} }
...@@ -2805,6 +2851,8 @@ int XTestGrabControl_wr(Display *dpy, Bool impervious) { ...@@ -2805,6 +2851,8 @@ int XTestGrabControl_wr(Display *dpy, Bool impervious) {
int XTRAP_GrabControl_wr(Display *dpy, Bool impervious) { int XTRAP_GrabControl_wr(Display *dpy, Bool impervious) {
if (! xtrap_present) { if (! xtrap_present) {
/* unused vars warning: */
if (dpy || impervious) {}
return 0; return 0;
} }
#if LIBVNCSERVER_HAVE_LIBXTRAP #if LIBVNCSERVER_HAVE_LIBXTRAP
...@@ -3185,6 +3233,9 @@ int xrecord_skip_keysym(rfbKeySym keysym) { ...@@ -3185,6 +3233,9 @@ int xrecord_skip_keysym(rfbKeySym keysym) {
} }
int xrecord_skip_button(int new, int old) { int xrecord_skip_button(int new, int old) {
/* unused vars warning: */
if (new || old) {}
return 0; return 0;
} }
...@@ -3405,7 +3456,7 @@ short period of time with a painting error: two cursors, one above the other. ...@@ -3405,7 +3456,7 @@ short period of time with a painting error: two cursors, one above the other.
w = req->width; w = req->width;
h = req->height; h = req->height;
if (w*h < scrollcopyrect_min_area) { if (w*h < (unsigned int) scrollcopyrect_min_area) {
good = 0; good = 0;
} else if (!src || !dst) { } else if (!src || !dst) {
good = 0; good = 0;
...@@ -3561,7 +3612,7 @@ void record_CW(XPointer ptr, XRecordInterceptData *rec_data) { ...@@ -3561,7 +3612,7 @@ void record_CW(XPointer ptr, XRecordInterceptData *rec_data) {
int x, y, w, h; int x, y, w, h;
int x0, y0, w0, h0, x1, y1, w1, h1, x2, y2, w2, h2; int x0, y0, w0, h0, x1, y1, w1, h1, x2, y2, w2, h2;
static int index = 0; static int index = 0;
unsigned long vals[4]; unsigned int vals[4];
unsigned tmask; unsigned tmask;
char *data; char *data;
int dba = 0, db = debug_scroll; int dba = 0, db = debug_scroll;
...@@ -3660,13 +3711,18 @@ if (db > 1) fprintf(stderr, "record_CW-%d\n", k++); ...@@ -3660,13 +3711,18 @@ if (db > 1) fprintf(stderr, "record_CW-%d\n", k++);
data += sz_xConfigureWindowReq; data += sz_xConfigureWindowReq;
for (i=0; i<req->length; i++) { for (i=0; i<req->length; i++) {
unsigned long v; unsigned int v;
v = *( (unsigned long *) data); /*
* We use unsigned int for the values. There were
* some crashes on 64bit machines with unsigned longs.
* Need to check that X protocol sends 32bit values.
*/
v = *( (unsigned int *) data);
if (db > 1) fprintf(stderr, " vals[%d] 0x%x/%d\n", i, v, v);
vals[i] = v; vals[i] = v;
data += 4; data += sizeof(unsigned int);
} }
if (index >= MAX_CW) { if (index >= MAX_CW) {
int i, j; int i, j;
...@@ -4126,6 +4182,9 @@ void record_grab(XPointer ptr, XRecordInterceptData *rec_data) { ...@@ -4126,6 +4182,9 @@ void record_grab(XPointer ptr, XRecordInterceptData *rec_data) {
; ;
} }
XRecordFreeData(rec_data); XRecordFreeData(rec_data);
/* unused vars warning: */
if (ptr) {}
} }
#endif #endif
...@@ -4242,8 +4301,8 @@ void shutdown_record_context(XRecordContext rc, int bequiet, int reopen) { ...@@ -4242,8 +4301,8 @@ void shutdown_record_context(XRecordContext rc, int bequiet, int reopen) {
void check_xrecord_reset(int force) { void check_xrecord_reset(int force) {
static double last_reset = 0.0; static double last_reset = 0.0;
int reset_time = 90, reset_idle = 10; int reset_time = 60, require_idle = 10;
int reset_time2 = 600, reset_idle2 = 40; int reset_time2 = 600, require_idle2 = 40;
double now; double now;
XErrorHandler old_handler = NULL; XErrorHandler old_handler = NULL;
...@@ -4254,7 +4313,7 @@ void check_xrecord_reset(int force) { ...@@ -4254,7 +4313,7 @@ void check_xrecord_reset(int force) {
} else { } else {
/* more dicey if not watching grabserver */ /* more dicey if not watching grabserver */
reset_time = reset_time2; reset_time = reset_time2;
reset_idle = reset_idle2; require_idle = require_idle2;
} }
if (!use_xrecord) { if (!use_xrecord) {
...@@ -4287,9 +4346,9 @@ void check_xrecord_reset(int force) { ...@@ -4287,9 +4346,9 @@ void check_xrecord_reset(int force) {
; ;
} else if (now < last_reset + reset_time) { } else if (now < last_reset + reset_time) {
return; return;
} else if (now < last_pointer_click_time + reset_idle) { } else if (now < last_pointer_click_time + require_idle) {
return; return;
} else if (now < last_keyboard_time + reset_idle) { } else if (now < last_keyboard_time + require_idle) {
return; return;
} }
X_LOCK; X_LOCK;
...@@ -4843,23 +4902,35 @@ int trapped_record_xerror = 0; ...@@ -4843,23 +4902,35 @@ int trapped_record_xerror = 0;
int trap_xerror(Display *d, XErrorEvent *error) { int trap_xerror(Display *d, XErrorEvent *error) {
trapped_xerror = 1; trapped_xerror = 1;
trapped_xerror_event = error; trapped_xerror_event = error;
if (d) {} /* unused vars warning: */
return 0; return 0;
} }
int trap_xioerror(Display *d) { int trap_xioerror(Display *d) {
trapped_xioerror = 1; trapped_xioerror = 1;
if (d) {} /* unused vars warning: */
return 0; return 0;
} }
int trap_getimage_xerror(Display *d, XErrorEvent *error) { int trap_getimage_xerror(Display *d, XErrorEvent *error) {
trapped_getimage_xerror = 1; trapped_getimage_xerror = 1;
trapped_xerror_event = error; trapped_xerror_event = error;
if (d) {} /* unused vars warning: */
return 0; return 0;
} }
int trap_record_xerror(Display *d, XErrorEvent *error) { int trap_record_xerror(Display *d, XErrorEvent *error) {
trapped_record_xerror = 1; trapped_record_xerror = 1;
trapped_record_xerror_event = error; trapped_record_xerror_event = error;
if (d) {} /* unused vars warning: */
return 0; return 0;
} }
...@@ -4868,12 +4939,18 @@ void interrupted(int); ...@@ -4868,12 +4939,18 @@ void interrupted(int);
static int Xerror(Display *d, XErrorEvent *error) { static int Xerror(Display *d, XErrorEvent *error) {
X_UNLOCK; X_UNLOCK;
interrupted(0); interrupted(0);
if (d) {} /* unused vars warning: */
return (*Xerror_def)(d, error); return (*Xerror_def)(d, error);
} }
static int XIOerr(Display *d) { static int XIOerr(Display *d) {
X_UNLOCK; X_UNLOCK;
interrupted(-1); interrupted(-1);
if (d) {} /* unused vars warning: */
return (*XIOerr_def)(d); return (*XIOerr_def)(d);
} }
...@@ -4919,9 +4996,9 @@ int crash_debug = 1; ...@@ -4919,9 +4996,9 @@ int crash_debug = 1;
void initialize_crash_handler(void) { void initialize_crash_handler(void) {
int pid = program_pid; int pid = program_pid;
crash_stack_command1 = malloc(1000); crash_stack_command1 = (char *) malloc(1000);
crash_stack_command2 = malloc(1000); crash_stack_command2 = (char *) malloc(1000);
crash_debug_command = malloc(1000); crash_debug_command = (char *) malloc(1000);
snprintf(crash_stack_command1, 500, "echo where > /tmp/gdb.%d;" snprintf(crash_stack_command1, 500, "echo where > /tmp/gdb.%d;"
" env PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/bin" " env PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/bin"
...@@ -5122,7 +5199,7 @@ int wait_until_mapped(Window win) { ...@@ -5122,7 +5199,7 @@ int wait_until_mapped(Window win) {
while (1) { while (1) {
if (! valid_window(win, NULL, 0)) { if (! valid_window(win, NULL, 0)) {
if (time(0) > start + waittime) { if (time(0) > start + waittime) {
return 0; break;
} }
usleep(ms * 1000); usleep(ms * 1000);
continue; continue;
...@@ -5311,16 +5388,19 @@ rfbClientPtr *client_match(char *str) { ...@@ -5311,16 +5388,19 @@ rfbClientPtr *client_match(char *str) {
iter = rfbGetClientIterator(screen); iter = rfbGetClientIterator(screen);
while( (cl = rfbClientIteratorNext(iter)) ) { while( (cl = rfbClientIteratorNext(iter)) ) {
if (strstr(str, "0x") == str) { if (strstr(str, "0x") == str) {
unsigned int in;
int id; int id;
ClientData *cd = (ClientData *) cl->clientData; ClientData *cd = (ClientData *) cl->clientData;
if (sscanf(str, "0x%x", &id) != 1) { if (sscanf(str, "0x%x", &in) != 1) {
if (hex_warn++) { if (hex_warn++) {
continue; continue;
} }
rfbLog("skipping bad client hex id: %s\n", str); rfbLog("skipping invalid client hex id: %s\n",
str);
continue; continue;
} }
if ( cd->uid == id) { id = (unsigned int) in;
if (cd->uid == id) {
cl_list[i++] = cl; cl_list[i++] = cl;
} }
} else { } else {
...@@ -5515,6 +5595,7 @@ static int run_user_command(char *cmd, rfbClientPtr client, char *mode) { ...@@ -5515,6 +5595,7 @@ static int run_user_command(char *cmd, rfbClientPtr client, char *mode) {
set_env("RFB_CLIENT_COUNT", str); set_env("RFB_CLIENT_COUNT", str);
if (no_external_cmds) { if (no_external_cmds) {
rfbLogEnable(1);
rfbLog("cannot run external commands in -nocmds mode:\n"); rfbLog("cannot run external commands in -nocmds mode:\n");
rfbLog(" \"%s\"\n", cmd); rfbLog(" \"%s\"\n", cmd);
rfbLog(" exiting.\n"); rfbLog(" exiting.\n");
...@@ -5591,7 +5672,7 @@ static void client_gone(rfbClientPtr client) { ...@@ -5591,7 +5672,7 @@ static void client_gone(rfbClientPtr client) {
*/ */
if ((client->state == RFB_PROTOCOL_VERSION || if ((client->state == RFB_PROTOCOL_VERSION ||
client->state == RFB_AUTHENTICATION) && accepted_client) { client->state == RFB_AUTHENTICATION) && accepted_client) {
rfbLog("connect_once: bad password or early " rfbLog("connect_once: invalid password or early "
"disconnect.\n"); "disconnect.\n");
rfbLog("connect_once: waiting for next connection.\n"); rfbLog("connect_once: waiting for next connection.\n");
accepted_client = 0; accepted_client = 0;
...@@ -5643,6 +5724,7 @@ static int check_access(char *addr) { ...@@ -5643,6 +5724,7 @@ static int check_access(char *addr) {
char line[1024], *q; char line[1024], *q;
if (stat(allow_list, &sbuf) != 0) { if (stat(allow_list, &sbuf) != 0) {
rfbLogEnable(1);
rfbLog("check_access: failure stating file: %s\n", rfbLog("check_access: failure stating file: %s\n",
allow_list); allow_list);
rfbLogPerror("stat"); rfbLogPerror("stat");
...@@ -5653,11 +5735,12 @@ static int check_access(char *addr) { ...@@ -5653,11 +5735,12 @@ static int check_access(char *addr) {
len2 = strlen(allow_once) + 2; len2 = strlen(allow_once) + 2;
len += len2; len += len2;
} }
list = malloc(len); list = (char *) malloc(len);
list[0] = '\0'; list[0] = '\0';
in = fopen(allow_list, "r"); in = fopen(allow_list, "r");
if (in == NULL) { if (in == NULL) {
rfbLogEnable(1);
rfbLog("check_access: cannot open: %s\n", allow_list); rfbLog("check_access: cannot open: %s\n", allow_list);
rfbLogPerror("fopen"); rfbLogPerror("fopen");
clean_up_exit(1); clean_up_exit(1);
...@@ -5666,7 +5749,8 @@ static int check_access(char *addr) { ...@@ -5666,7 +5749,8 @@ static int check_access(char *addr) {
if ( (q = strchr(line, '#')) != NULL) { if ( (q = strchr(line, '#')) != NULL) {
*q = '\0'; *q = '\0';
} }
if (strlen(list) + strlen(line) >= len - len2) { if (strlen(list) + strlen(line) >=
(size_t) (len - len2)) {
/* file grew since our stat() */ /* file grew since our stat() */
break; break;
} }
...@@ -5683,7 +5767,7 @@ static int check_access(char *addr) { ...@@ -5683,7 +5767,7 @@ static int check_access(char *addr) {
if (allow_once) { if (allow_once) {
len += strlen(allow_once) + 1; len += strlen(allow_once) + 1;
} }
list = malloc(len); list = (char *) malloc(len);
list[0] = '\0'; list[0] = '\0';
strcat(list, allow_list); strcat(list, allow_list);
if (allow_once) { if (allow_once) {
...@@ -5759,7 +5843,7 @@ static int ugly_accept_window(char *addr, char *userhost, int X, int Y, ...@@ -5759,7 +5843,7 @@ static int ugly_accept_window(char *addr, char *userhost, int X, int Y,
#define t2x2_width 16 #define t2x2_width 16
#define t2x2_height 16 #define t2x2_height 16
static char t2x2_bits[] = { static unsigned char t2x2_bits[] = {
0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff,
0x33, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33,
0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33}; 0xff, 0xff, 0xff, 0xff, 0x33, 0x33, 0x33, 0x33};
...@@ -5854,8 +5938,8 @@ static char t2x2_bits[] = { ...@@ -5854,8 +5938,8 @@ static char t2x2_bits[] = {
XSetWMProtocols(dpy, awin, &wm_delete_window, 1); XSetWMProtocols(dpy, awin, &wm_delete_window, 1);
if (! ico) { if (! ico) {
ico = XCreateBitmapFromData(dpy, awin, t2x2_bits, t2x2_width, ico = XCreateBitmapFromData(dpy, awin, (char *) t2x2_bits,
t2x2_height); t2x2_width, t2x2_height);
} }
hints.flags = PPosition | PSize | PMinSize; hints.flags = PPosition | PSize | PMinSize;
...@@ -5872,6 +5956,7 @@ static char t2x2_bits[] = { ...@@ -5872,6 +5956,7 @@ static char t2x2_bits[] = {
XSelectInput(dpy, awin, evmask); XSelectInput(dpy, awin, evmask);
if (! font_info && (font_info = XLoadQueryFont(dpy, "fixed")) == NULL) { if (! font_info && (font_info = XLoadQueryFont(dpy, "fixed")) == NULL) {
rfbLogEnable(1);
rfbLog("ugly_accept_window: cannot locate font fixed.\n"); rfbLog("ugly_accept_window: cannot locate font fixed.\n");
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
...@@ -5974,7 +6059,7 @@ static char t2x2_bits[] = { ...@@ -5974,7 +6059,7 @@ static char t2x2_bits[] = {
case ClientMessage: case ClientMessage:
if (ev.xclient.message_type == wm_protocols && if (ev.xclient.message_type == wm_protocols &&
ev.xclient.data.l[0] == wm_delete_window) { (Atom) ev.xclient.data.l[0] == wm_delete_window) {
out = 0; out = 0;
} }
break; break;
...@@ -6058,23 +6143,28 @@ static int action_match(char *action, int rc) { ...@@ -6058,23 +6143,28 @@ static int action_match(char *action, int rc) {
} else if (strstr(p, "view") == p) { } else if (strstr(p, "view") == p) {
k = 3; k = 3;
} else { } else {
rfbLog("bad action line: %s\n", action); rfbLogEnable(1);
rfbLog("invalid action line: %s\n", action);
clean_up_exit(1); clean_up_exit(1);
} }
if (*q == '*') { if (*q == '*') {
cases[k] = -1; cases[k] = -1;
} else if (sscanf(q, "%d", &in) == 1) { } else if (sscanf(q, "%d", &in) == 1) {
if (in < 0) { if (in < 0) {
rfbLog("bad action line: %s\n", action); rfbLogEnable(1);
rfbLog("invalid action line: %s\n",
action);
clean_up_exit(1); clean_up_exit(1);
} }
cases[k] = in; cases[k] = in;
} else { } else {
rfbLog("bad action line: %s\n", action); rfbLogEnable(1);
rfbLog("invalid action line: %s\n", action);
clean_up_exit(1); clean_up_exit(1);
} }
} else { } else {
rfbLog("bad action line: %s\n", action); rfbLogEnable(1);
rfbLog("invalid action line: %s\n", action);
clean_up_exit(1); clean_up_exit(1);
} }
p = strtok(NULL, ","); p = strtok(NULL, ",");
...@@ -6282,7 +6372,7 @@ static int accept_client(rfbClientPtr client) { ...@@ -6282,7 +6372,7 @@ static int accept_client(rfbClientPtr client) {
return 0; return 0;
} }
return 0; /* NOTREACHED */ /* return 0; NOTREACHED */
} }
/* /*
...@@ -6376,7 +6466,7 @@ static int do_reverse_connect(char *str) { ...@@ -6376,7 +6466,7 @@ static int do_reverse_connect(char *str) {
} }
/* copy in to host */ /* copy in to host */
host = (char *) malloc((size_t) len+1); host = (char *) malloc(len+1);
if (! host) { if (! host) {
rfbLog("reverse_connect: could not malloc string %d\n", len); rfbLog("reverse_connect: could not malloc string %d\n", len);
return 0; return 0;
...@@ -6784,6 +6874,73 @@ void clear_modifiers(int init) { ...@@ -6784,6 +6874,73 @@ void clear_modifiers(int init) {
XFlush(dpy); XFlush(dpy);
} }
KeySym simple_mods[] = {
XK_Shift_L, XK_Shift_R,
XK_Control_L, XK_Control_R,
XK_Meta_L, XK_Meta_R,
XK_Alt_L, XK_Alt_R,
XK_Super_L, XK_Super_R,
XK_Hyper_L, XK_Hyper_R,
XK_Mode_switch,
NoSymbol
};
#define NSIMPLE_MODS 13
int track_mod_state(rfbKeySym keysym, rfbBool down, rfbBool set) {
KeySym sym = (KeySym) keysym;
static rfbBool isdown[NSIMPLE_MODS];
static int first = 1;
int i;
/*
* simple tracking method for the modifier state without
* contacting the Xserver. Ignores, of course what keys are
* pressed on the physical display.
*
* This is unrelated to our mod_tweak and xkb stuff.
* Just a simple thing for heuristics, etc.
*/
if (first) {
for (i=0; i<NSIMPLE_MODS; i++) {
isdown[i] = FALSE;
}
first = 0;
}
if (sym != NoSymbol) {
for (i=0; i<NSIMPLE_MODS; i++) {
if (sym == simple_mods[i]) {
if (set) {
isdown[i] = down;
return 1;
} else {
if (isdown[i]) {
return 1;
} else {
return 0;
}
}
break;
}
}
/* not a modifier */
if (set) {
return 0;
} else {
return -1;
}
}
/* called with NoSymbol: return 1 if any pressed: */
for (i=0; i<NSIMPLE_MODS; i++) {
if (isdown[i]) {
return 1;
}
}
return 0;
}
/* /*
* Attempt to set all keys to Up position. Can mess up typing at the * Attempt to set all keys to Up position. Can mess up typing at the
* physical keyboard so use with caution. * physical keyboard so use with caution.
...@@ -7070,12 +7227,14 @@ static keyremap_t *keyremaps = NULL; ...@@ -7070,12 +7227,14 @@ static keyremap_t *keyremaps = NULL;
void add_remap(char *line) { void add_remap(char *line) {
char str1[256], str2[256]; char str1[256], str2[256];
KeySym ksym1, ksym2; KeySym ksym1, ksym2;
int isbtn = 0, i; int isbtn = 0;
unsigned int i;
static keyremap_t *current = NULL; static keyremap_t *current = NULL;
keyremap_t *remap; keyremap_t *remap;
if (sscanf(line, "%s %s", str1, str2) != 2) { if (sscanf(line, "%s %s", str1, str2) != 2) {
rfbLog("remap: bad line: %s\n", line); rfbLogEnable(1);
rfbLog("remap: invalid line: %s\n", line);
clean_up_exit(1); clean_up_exit(1);
} }
if (sscanf(str1, "0x%x", &i) == 1) { if (sscanf(str1, "0x%x", &i) == 1) {
...@@ -7089,14 +7248,13 @@ void add_remap(char *line) { ...@@ -7089,14 +7248,13 @@ void add_remap(char *line) {
ksym2 = XStringToKeysym(str2); ksym2 = XStringToKeysym(str2);
} }
if (ksym2 == NoSymbol) { if (ksym2 == NoSymbol) {
int i; if (sscanf(str2, "Button%u", &i) == 1) {
if (sscanf(str2, "Button%d", &i) == 1) {
ksym2 = (KeySym) i; ksym2 = (KeySym) i;
isbtn = 1; isbtn = 1;
} }
} }
if (ksym1 == NoSymbol || ksym2 == NoSymbol) { if (ksym1 == NoSymbol || ksym2 == NoSymbol) {
rfbLog("warning: skipping bad remap line: %s", line); rfbLog("warning: skipping invalid remap line: %s", line);
return; return;
} }
remap = (keyremap_t *) malloc((size_t) sizeof(keyremap_t)); remap = (keyremap_t *) malloc((size_t) sizeof(keyremap_t));
...@@ -7242,11 +7400,13 @@ void initialize_remap(char *infile) { ...@@ -7242,11 +7400,13 @@ void initialize_remap(char *infile) {
if (strstr(infile, "DEAD") == infile) { if (strstr(infile, "DEAD") == infile) {
; ;
} else if (!strchr(infile, '-')) { } else if (!strchr(infile, '-')) {
rfbLogEnable(1);
rfbLog("remap: cannot open: %s\n", infile); rfbLog("remap: cannot open: %s\n", infile);
rfbLogPerror("fopen"); rfbLogPerror("fopen");
clean_up_exit(1); clean_up_exit(1);
} }
if ((in = tmpfile()) == NULL) { if ((in = tmpfile()) == NULL) {
rfbLogEnable(1);
rfbLog("remap: cannot open tmpfile for %s\n", infile); rfbLog("remap: cannot open tmpfile for %s\n", infile);
rfbLogPerror("tmpfile"); rfbLogPerror("tmpfile");
clean_up_exit(1); clean_up_exit(1);
...@@ -7833,7 +7993,8 @@ xkbmodifiers[] For the KeySym bound to this (keycode,group,level) store ...@@ -7833,7 +7993,8 @@ xkbmodifiers[] For the KeySym bound to this (keycode,group,level) store
} }
state++; state++;
} }
if (xkbstate[kc][grp][lvl] == -1 && grp == 1) { if (xkbstate[kc][grp][lvl] == (unsigned int) -1
&& grp == 1) {
/* /*
* Hack on Solaris 9 for Mode_switch * Hack on Solaris 9 for Mode_switch
* for Group2 characters. We force the * for Group2 characters. We force the
...@@ -7896,7 +8057,8 @@ xkbmodifiers[] For the KeySym bound to this (keycode,group,level) store ...@@ -7896,7 +8057,8 @@ xkbmodifiers[] For the KeySym bound to this (keycode,group,level) store
while (p) { while (p) {
k = 1; k = 1;
if (sscanf(p, "%d", &k) != 1 || k < 0 || k >= 0x100) { if (sscanf(p, "%d", &k) != 1 || k < 0 || k >= 0x100) {
rfbLog("bad skip_keycodes: %s %s\n", rfbLogEnable(1);
rfbLog("invalid skip_keycodes: %s %s\n",
skip_keycodes, p); skip_keycodes, p);
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -7932,6 +8094,8 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym, ...@@ -7932,6 +8094,8 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym,
static int Kc_last_down = -1; static int Kc_last_down = -1;
static KeySym Ks_last_down = NoSymbol; static KeySym Ks_last_down = NoSymbol;
if (client) {} /* unused vars warning: */
X_LOCK; X_LOCK;
if (debug_keyboard) { if (debug_keyboard) {
...@@ -7990,7 +8154,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym, ...@@ -7990,7 +8154,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym,
} }
/* save it if state is OK and not told to skip */ /* save it if state is OK and not told to skip */
if (state == -1) { if (state == (unsigned int) -1) {
continue; continue;
} }
if (skipkeycode[kc] && debug_keyboard) { if (skipkeycode[kc] && debug_keyboard) {
...@@ -8295,7 +8459,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym, ...@@ -8295,7 +8459,7 @@ static void xkb_tweak_keyboard(rfbBool down, rfbKeySym keysym,
kc = kc_vec[kci]; kc = kc_vec[kci];
ms = xkbmodifiers[kc][grp][lvl]; ms = xkbmodifiers[kc][grp][lvl];
if (! ms || ms != b) { if (! ms || ms != (unsigned int) b) {
continue; continue;
} }
...@@ -8957,6 +9121,42 @@ double typing_rate(double time_window, int *repeating) { ...@@ -8957,6 +9121,42 @@ double typing_rate(double time_window, int *repeating) {
return ((double) cnt)/dt; return ((double) cnt)/dt;
} }
int skip_cr_when_scaling(char *mode) {
int got = 0;
if (!scaling) {
return 0;
}
if (scaling_copyrect != scaling_copyrect0) {
/* user override via -scale: */
if (! scaling_copyrect) {
return 1;
} else {
return 0;
}
}
if (*mode == 's') {
got = got_scrollcopyrect;
} else if (*mode == 'w') {
got = got_wirecopyrect;
}
if (scaling_copyrect || got) {
int lat, rate;
int link = link_rate(&lat, &rate);
if (link == LR_DIALUP) {
return 1;
} else if (rate < 25) {
/* the fill-in of the repair may be too slow */
return 1;
} else {
return 0;
}
} else {
return 1;
}
}
/* /*
* key event handler. See the above functions for contortions for * key event handler. See the above functions for contortions for
* running under -modtweak. * running under -modtweak.
...@@ -9021,15 +9221,15 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { ...@@ -9021,15 +9221,15 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
key_history[idx].down = down; key_history[idx].down = down;
key_history[idx].time = tnow; key_history[idx].time = tnow;
if (down && skip_duplicate_key_events && if (down && (keysym == XK_Alt_L || keysym == XK_Super_L)) {
(keysym == XK_Alt_L || keysym == XK_Super_L)) { int i, k, run = 0, ups = 0;
int i, k, run = 0;
double delay = 1.0; double delay = 1.0;
KeySym ks; KeySym ks;
for (i=0; i<16; i++) { for (i=0; i<16; i++) {
k = idx - i; k = idx - i;
if (k < 0) k += KEY_HIST; if (k < 0) k += KEY_HIST;
if (!key_history[k].down) { if (!key_history[k].down) {
ups++;
continue; continue;
} }
ks = key_history[k].sym; ks = key_history[k].sym;
...@@ -9043,7 +9243,9 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { ...@@ -9043,7 +9243,9 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
break; break;
} }
} }
if (run == 3 && keysym == XK_Alt_L) { if (ups < 2) {
;
} else if (run == 3 && keysym == XK_Alt_L) {
rfbLog("3*Alt_L, calling: refresh_screen(0)\n"); rfbLog("3*Alt_L, calling: refresh_screen(0)\n");
refresh_screen(0); refresh_screen(0);
} else if (run == 4 && keysym == XK_Alt_L) { } else if (run == 4 && keysym == XK_Alt_L) {
...@@ -9133,6 +9335,8 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { ...@@ -9133,6 +9335,8 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
return; return;
} }
track_mod_state(keysym, down, TRUE); /* ignores remaps */
last_keyboard_client = client; last_keyboard_client = client;
last_event = last_input = now; last_event = last_input = now;
last_keyboard_input = now; last_keyboard_input = now;
...@@ -9172,12 +9376,13 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { ...@@ -9172,12 +9376,13 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
} }
if (use_xrecord && ! xrecording && down) { if (use_xrecord && ! xrecording && down) {
if (scaling && ! got_scrollcopyrect) {
; if (!strcmp(scroll_copyrect, "never")) {
} else if (!strcmp(scroll_copyrect, "never")) {
; ;
} else if (!strcmp(scroll_copyrect, "mouse")) { } else if (!strcmp(scroll_copyrect, "mouse")) {
; ;
} else if (skip_cr_when_scaling("scroll")) {
;
} else if (! xrecord_skip_keysym(keysym)) { } else if (! xrecord_skip_keysym(keysym)) {
snapshot_stack_list(0, 0.25); snapshot_stack_list(0, 0.25);
xrecord_watch(1, SCR_KEY); xrecord_watch(1, SCR_KEY);
...@@ -9308,14 +9513,15 @@ static void buttonparse(int from, char **s) { ...@@ -9308,14 +9513,15 @@ static void buttonparse(int from, char **s) {
t = strtok(list, "+"); t = strtok(list, "+");
while (t) { while (t) {
KeySym ksym; KeySym ksym;
unsigned int ui;
int i; int i;
if (n >= MAX_BUTTON_EVENTS - 20) { if (n >= MAX_BUTTON_EVENTS - 20) {
rfbLog("buttonparse: too many button map " rfbLog("buttonparse: too many button map "
"events: %s\n", list); "events: %s\n", list);
break; break;
} }
if (sscanf(t, "0x%x", &i) == 1) { if (sscanf(t, "0x%x", &ui) == 1) {
ksym = (KeySym) i; /* hex value */ ksym = (KeySym) ui; /* hex value */
} else { } else {
X_LOCK; X_LOCK;
ksym = XStringToKeysym(t); /* string value */ ksym = XStringToKeysym(t); /* string value */
...@@ -9509,6 +9715,7 @@ void snapshot_stack_list(int free_only, double allowed_age) { ...@@ -9509,6 +9715,7 @@ void snapshot_stack_list(int free_only, double allowed_age) {
static double last_snap = 0.0, last_free = 0.0; static double last_snap = 0.0, last_free = 0.0;
double now; double now;
int num, rc, i; int num, rc, i;
unsigned int ui;
Window r, w; Window r, w;
Window *list; Window *list;
...@@ -9534,7 +9741,8 @@ void snapshot_stack_list(int free_only, double allowed_age) { ...@@ -9534,7 +9741,8 @@ void snapshot_stack_list(int free_only, double allowed_age) {
last_free = now; last_free = now;
X_LOCK; X_LOCK;
rc = XQueryTree(dpy, rootwin, &r, &w, &list, &num); rc = XQueryTree(dpy, rootwin, &r, &w, &list, &ui);
num = (int) ui;
if (! rc) { if (! rc) {
stack_list_num = 0; stack_list_num = 0;
...@@ -9558,6 +9766,10 @@ void snapshot_stack_list(int free_only, double allowed_age) { ...@@ -9558,6 +9766,10 @@ void snapshot_stack_list(int free_only, double allowed_age) {
stack_list[i].time = now; stack_list[i].time = now;
} }
stack_list_num = num; stack_list_num = num;
if (debug_wireframe > 1) {
fprintf(stderr, "snapshot_stack_list: num=%d len=%d\n",
stack_list_num, stack_list_len);
}
XFree(list); XFree(list);
X_UNLOCK; X_UNLOCK;
...@@ -9717,14 +9929,14 @@ static void update_x11_pointer_mask(int mask) { ...@@ -9717,14 +9929,14 @@ static void update_x11_pointer_mask(int mask) {
last_pointer_click_time = dnow(); last_pointer_click_time = dnow();
} }
if (scaling && ! got_scrollcopyrect) { if (nofb) {
xr_mouse = 0;
} else if (nofb) {
xr_mouse = 0; xr_mouse = 0;
} else if (!strcmp(scroll_copyrect, "never")) { } else if (!strcmp(scroll_copyrect, "never")) {
xr_mouse = 0; xr_mouse = 0;
} else if (!strcmp(scroll_copyrect, "keys")) { } else if (!strcmp(scroll_copyrect, "keys")) {
xr_mouse = 0; xr_mouse = 0;
} else if (skip_cr_when_scaling("scroll")) {
xr_mouse = 0;
} else if (xrecord_skip_button(mask, button_mask)) { } else if (xrecord_skip_button(mask, button_mask)) {
xr_mouse = 0; xr_mouse = 0;
} }
...@@ -10215,6 +10427,7 @@ void initialize_pipeinput(void) { ...@@ -10215,6 +10427,7 @@ void initialize_pipeinput(void) {
set_child_info(); set_child_info();
if (no_external_cmds) { if (no_external_cmds) {
rfbLogEnable(1);
rfbLog("cannot run external commands in -nocmds mode:\n"); rfbLog("cannot run external commands in -nocmds mode:\n");
rfbLog(" \"%s\"\n", p); rfbLog(" \"%s\"\n", p);
rfbLog(" exiting.\n"); rfbLog(" exiting.\n");
...@@ -10512,15 +10725,18 @@ int handle_subwin_resize(char *msg) { ...@@ -10512,15 +10725,18 @@ int handle_subwin_resize(char *msg) {
int new_x, new_y; int new_x, new_y;
int i, check = 10, ms = 250; /* 2.5 secs total... */ int i, check = 10, ms = 250; /* 2.5 secs total... */
if (msg) {} /* unused vars warning: */
if (! subwin) { if (! subwin) {
return 0; /* hmmm... */ return 0; /* hmmm... */
} }
if (! valid_window(subwin, NULL, 0)) { if (! valid_window(subwin, NULL, 0)) {
rfbLogEnable(1);
rfbLog("subwin 0x%lx went away!\n", subwin); rfbLog("subwin 0x%lx went away!\n", subwin);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
} }
if (! get_window_size(subwin, &new_x, &new_y)) { if (! get_window_size(subwin, &new_x, &new_y)) {
rfbLogEnable(1);
rfbLog("could not get size of subwin 0x%lx\n", subwin); rfbLog("could not get size of subwin 0x%lx\n", subwin);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
...@@ -10536,6 +10752,7 @@ int handle_subwin_resize(char *msg) { ...@@ -10536,6 +10752,7 @@ int handle_subwin_resize(char *msg) {
usleep(ms * 1000); usleep(ms * 1000);
if (! get_window_size(subwin, &newer_x, &newer_y)) { if (! get_window_size(subwin, &newer_x, &newer_y)) {
rfbLogEnable(1);
rfbLog("could not get size of subwin 0x%lx\n", subwin); rfbLog("could not get size of subwin 0x%lx\n", subwin);
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -10790,6 +11007,36 @@ static void selection_request(XEvent *ev) { ...@@ -10790,6 +11007,36 @@ static void selection_request(XEvent *ev) {
XFlush(dpy); XFlush(dpy);
} }
int check_sel_direction(char *dir, char *label, char *sel, int len) {
int db = 0, ok = 1;
if (sel_direction) {
if (strstr(sel_direction, "debug")) {
db = 1;
}
if (strcmp(sel_direction, "debug")) {
if (strstr(sel_direction, dir) == NULL) {
ok = 0;
}
}
}
if (db) {
char str[40];
int n = 40;
strncpy(str, sel, n);
str[n-1] = '\0';
if (len < n) {
str[len] = '\0';
}
rfbLog("%s: %s...\n", label, str);
if (ok) {
rfbLog("%s: %s-ing it.\n", label, dir);
} else {
rfbLog("%s: NOT %s-ing it.\n", label, dir);
}
}
return ok;
}
/* /*
* CUT_BUFFER0 property on the local display has changed, we read and * CUT_BUFFER0 property on the local display has changed, we read and
* store it and send it out to any connected VNC clients. * store it and send it out to any connected VNC clients.
...@@ -10798,7 +11045,7 @@ static void selection_request(XEvent *ev) { ...@@ -10798,7 +11045,7 @@ static void selection_request(XEvent *ev) {
*/ */
static void cutbuffer_send(void) { static void cutbuffer_send(void) {
Atom type; Atom type;
int format, slen, dlen; int format, slen, dlen, len;
unsigned long nitems = 0, bytes_after = 0; unsigned long nitems = 0, bytes_after = 0;
unsigned char* data = NULL; unsigned char* data = NULL;
...@@ -10838,7 +11085,10 @@ static void cutbuffer_send(void) { ...@@ -10838,7 +11085,10 @@ static void cutbuffer_send(void) {
if (!screen) { if (!screen) {
return; return;
} }
rfbSendServerCutText(screen, selection_str, strlen(selection_str)); len = strlen(selection_str);
if (check_sel_direction("send", "cutbuffer_send", selection_str, len)) {
rfbSendServerCutText(screen, selection_str, len);
}
} }
/* /*
...@@ -10856,7 +11106,7 @@ static void cutbuffer_send(void) { ...@@ -10856,7 +11106,7 @@ static void cutbuffer_send(void) {
#define CHKSZ 32 #define CHKSZ 32
static void selection_send(XEvent *ev) { static void selection_send(XEvent *ev) {
Atom type; Atom type;
int format, slen, dlen, oldlen, newlen, toobig = 0; int format, slen, dlen, oldlen, newlen, toobig = 0, len;
static int err = 0, sent_one = 0; static int err = 0, sent_one = 0;
char before[CHKSZ], after[CHKSZ]; char before[CHKSZ], after[CHKSZ];
unsigned long nitems = 0, bytes_after = 0; unsigned long nitems = 0, bytes_after = 0;
...@@ -10934,7 +11184,11 @@ static void selection_send(XEvent *ev) { ...@@ -10934,7 +11184,11 @@ static void selection_send(XEvent *ev) {
if (!screen) { if (!screen) {
return; return;
} }
rfbSendServerCutText(screen, selection_str, newlen);
len = newlen;
if (check_sel_direction("send", "selection_send", selection_str, len)) {
rfbSendServerCutText(screen, selection_str, len);
}
} }
/* -- xevents.c -- */ /* -- xevents.c -- */
...@@ -11419,6 +11673,10 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) { ...@@ -11419,6 +11673,10 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) {
return; return;
} }
if (! check_sel_direction("recv", "xcut_receive", text, len)) {
return;
}
X_LOCK; X_LOCK;
/* associate this text with PRIMARY (and SECONDARY...) */ /* associate this text with PRIMARY (and SECONDARY...) */
...@@ -11432,9 +11690,9 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) { ...@@ -11432,9 +11690,9 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) {
/* duplicate the text string for our own use. */ /* duplicate the text string for our own use. */
if (xcut_str != NULL) { if (xcut_str != NULL) {
free(xcut_str); free(xcut_str);
xcut_str = NULL;
} }
xcut_str = (unsigned char *) xcut_str = (char *) malloc((size_t) (len+1));
malloc((size_t) (len+1) * sizeof(unsigned char));
strncpy(xcut_str, text, len); strncpy(xcut_str, text, len);
xcut_str[len] = '\0'; /* make sure null terminated */ xcut_str[len] = '\0'; /* make sure null terminated */
...@@ -11541,12 +11799,12 @@ int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync) { ...@@ -11541,12 +11799,12 @@ int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync) {
int rc = 1; int rc = 1;
if (remote_cmd) { if (remote_cmd) {
rcmd = (char *)malloc(strlen(remote_cmd) + 5); rcmd = (char *) malloc(strlen(remote_cmd) + 5);
strcpy(rcmd, "cmd="); strcpy(rcmd, "cmd=");
strcat(rcmd, remote_cmd); strcat(rcmd, remote_cmd);
} }
if (query_cmd) { if (query_cmd) {
qcmd = (char *)malloc(strlen(query_cmd) + 5); qcmd = (char *) malloc(strlen(query_cmd) + 5);
strcpy(qcmd, "qry="); strcpy(qcmd, "qry=");
strcat(qcmd, query_cmd); strcat(qcmd, query_cmd);
} }
...@@ -11578,7 +11836,7 @@ char *add_item(char *instr, char *item) { ...@@ -11578,7 +11836,7 @@ char *add_item(char *instr, char *item) {
return str; return str;
} }
len = strlen(instr) + 1 + strlen(item) + 1; len = strlen(instr) + 1 + strlen(item) + 1;
str = (char *)malloc(len); str = (char *) malloc(len);
str[0] = '\0'; str[0] = '\0';
/* n.b. instr will be modified; caller replaces with returned string */ /* n.b. instr will be modified; caller replaces with returned string */
...@@ -11618,7 +11876,7 @@ char *delete_item(char *instr, char *item) { ...@@ -11618,7 +11876,7 @@ char *delete_item(char *instr, char *item) {
return str; return str;
} }
len = strlen(instr) + 1; len = strlen(instr) + 1;
str = (char *)malloc(len); str = (char *) malloc(len);
str[0] = '\0'; str[0] = '\0';
/* n.b. instr will be modified; caller replaces with returned string */ /* n.b. instr will be modified; caller replaces with returned string */
...@@ -11764,7 +12022,7 @@ void http_connections(int on) { ...@@ -11764,7 +12022,7 @@ void http_connections(int on) {
void reset_httpport(int old, int new) { void reset_httpport(int old, int new) {
int hp = new; int hp = new;
if (hp < 0) { if (hp < 0) {
rfbLog("reset_httpport: bad httpport: %d\n", hp); rfbLog("reset_httpport: invalid httpport: %d\n", hp);
} else if (hp == old) { } else if (hp == old) {
rfbLog("reset_httpport: unchanged httpport: %d\n", hp); rfbLog("reset_httpport: unchanged httpport: %d\n", hp);
} else if (inetd) { } else if (inetd) {
...@@ -11785,7 +12043,7 @@ void reset_httpport(int old, int new) { ...@@ -11785,7 +12043,7 @@ void reset_httpport(int old, int new) {
void reset_rfbport(int old, int new) { void reset_rfbport(int old, int new) {
int rp = new; int rp = new;
if (rp < 0) { if (rp < 0) {
rfbLog("reset_rfbport: bad rfbport: %d\n", rp); rfbLog("reset_rfbport: invalid rfbport: %d\n", rp);
} else if (rp == old) { } else if (rp == old) {
rfbLog("reset_rfbport: unchanged rfbport: %d\n", rp); rfbLog("reset_rfbport: unchanged rfbport: %d\n", rp);
} else if (inetd) { } else if (inetd) {
...@@ -12719,7 +12977,7 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -12719,7 +12977,7 @@ char *process_remote_cmd(char *cmd, int stringonly) {
} }
free(before); free(before);
} else { } else {
rfbLog("bad listen string: %s\n", listen_str); rfbLog("invalid listen string: %s\n", listen_str);
free(listen_str); free(listen_str);
listen_str = before; listen_str = before;
} }
...@@ -13389,6 +13647,18 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -13389,6 +13647,18 @@ char *process_remote_cmd(char *cmd, int stringonly) {
rfbLog("remote_cmd: disabling watch_primary.\n"); rfbLog("remote_cmd: disabling watch_primary.\n");
watch_primary = 0; watch_primary = 0;
} else if (strstr(p, "seldir") == p) {
COLON_CHECK("seldir:")
if (query) {
snprintf(buf, bufn, "ans=%s%s%s", p, co,
NONUL(sel_direction));
goto qry;
}
p += strlen("seldir:");
rfbLog("remote_cmd: setting -seldir to %s\n", p);
if (sel_direction) free(sel_direction);
sel_direction = strdup(p);
} else if (!strcmp(p, "set_no_cursor")) { /* skip-cmd-list */ } else if (!strcmp(p, "set_no_cursor")) { /* skip-cmd-list */
rfbLog("remote_cmd: calling set_no_cursor()\n"); rfbLog("remote_cmd: calling set_no_cursor()\n");
set_no_cursor(); set_no_cursor();
...@@ -14032,6 +14302,14 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -14032,6 +14302,14 @@ char *process_remote_cmd(char *cmd, int stringonly) {
if (orig != noxrecord) { if (orig != noxrecord) {
initialize_xrecord(); initialize_xrecord();
} }
} else if (!strcmp(p, "reset_record")) {
NOTAPP
if (use_xrecord) {
rfbLog("resetting RECORD\n");
check_xrecord_reset(1);
} else {
rfbLog("RECORD is disabled, not resetting.\n");
}
} else if (strstr(p, "pointer_mode") == p) { } else if (strstr(p, "pointer_mode") == p) {
int pm; int pm;
...@@ -14735,6 +15013,9 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -14735,6 +15013,9 @@ char *process_remote_cmd(char *cmd, int stringonly) {
} else if (!strcmp(p, "desktopname")) { } else if (!strcmp(p, "desktopname")) {
snprintf(buf, bufn, "aro=%s:%s", p, snprintf(buf, bufn, "aro=%s:%s", p,
NONUL(rfb_desktop_name)); NONUL(rfb_desktop_name));
} else if (!strcmp(p, "guess_desktop")) {
snprintf(buf, bufn, "aro=%s:%s", p,
NONUL(guess_desktop()));
} else if (!strcmp(p, "http_url")) { } else if (!strcmp(p, "http_url")) {
if (screen->httpListenSock > -1) { if (screen->httpListenSock > -1) {
snprintf(buf, bufn, "aro=%s:http://%s:%d", p, snprintf(buf, bufn, "aro=%s:http://%s:%d", p,
...@@ -15049,7 +15330,7 @@ void add_region_xdamage(sraRegionPtr new_region) { ...@@ -15049,7 +15330,7 @@ void add_region_xdamage(sraRegionPtr new_region) {
reg = xdamage_regions[prev_tick]; reg = xdamage_regions[prev_tick];
if (reg != NULL) { if (reg != NULL) {
if (0) fprintf(stderr, "add_region_xdamage: prev_tick: %d reg %p\n", prev_tick, reg); if (0) fprintf(stderr, "add_region_xdamage: prev_tick: %d reg %p\n", prev_tick, (void *)reg);
sraRgnOr(reg, new_region); sraRgnOr(reg, new_region);
} }
} }
...@@ -15112,6 +15393,8 @@ int collect_xdamage(int scancnt, int call) { ...@@ -15112,6 +15393,8 @@ int collect_xdamage(int scancnt, int call) {
int dup_x[DUPSZ], dup_y[DUPSZ], dup_w[DUPSZ], dup_h[DUPSZ]; int dup_x[DUPSZ], dup_y[DUPSZ], dup_w[DUPSZ], dup_h[DUPSZ];
double tm, dt; double tm, dt;
if (scancnt) {} /* unused vars warning: */
if (! xdamage_present || ! use_xdamage) { if (! xdamage_present || ! use_xdamage) {
return 0; return 0;
} }
...@@ -16043,22 +16326,23 @@ void setup_cursors(void) { ...@@ -16043,22 +16326,23 @@ void setup_cursors(void) {
cursor_info_t *ci = cursors[i]; cursor_info_t *ci = cursors[i];
if (scaling_cursor && scale_cursor_fac != 1.0) { if (scaling_cursor && scale_cursor_fac != 1.0) {
int w, h, x, y, i; int w, h, x, y, k;
unsigned long *pixels; unsigned long *pixels;
w = ci->wx; w = ci->wx;
h = ci->wy; h = ci->wy;
pixels = (unsigned long *) malloc(4*w*h); pixels = (unsigned long *) malloc(w * h
* sizeof(unsigned long));
i = 0; k = 0;
for (y=0; y<h; y++) { for (y=0; y<h; y++) {
for (x=0; x<w; x++) { for (x=0; x<w; x++) {
char d = ci->data[i]; char d = ci->data[k];
char m = ci->mask[i]; char m = ci->mask[k];
unsigned long *p; unsigned long *p;
p = pixels + i; p = pixels + k;
/* set alpha on */ /* set alpha on */
*p = 0xff000000; *p = 0xff000000;
...@@ -16081,7 +16365,7 @@ void setup_cursors(void) { ...@@ -16081,7 +16365,7 @@ void setup_cursors(void) {
*p |= 0x00000000; *p |= 0x00000000;
} }
} }
i++; k++;
} }
} }
...@@ -16125,8 +16409,8 @@ void setup_cursors(void) { ...@@ -16125,8 +16409,8 @@ void setup_cursors(void) {
white = WhitePixel(dpy, scr); white = WhitePixel(dpy, scr);
} }
rfb_curs->richSource rfb_curs->richSource = (unsigned char *)
= (char *)calloc(ci->wx * ci->wy, 1); calloc(ci->wx * ci->wy, 1);
for (y = 0; y < ci->wy; y++) { for (y = 0; y < ci->wy; y++) {
for (x = 0; x < ci->wx; x++) { for (x = 0; x < ci->wx; x++) {
...@@ -16293,7 +16577,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16293,7 +16577,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
static unsigned long black = 0, white = 1; static unsigned long black = 0, white = 1;
static int first = 1; static int first = 1;
char *bitmap, *rich, *alpha; char *bitmap, *rich, *alpha;
char *new_pixels = NULL; char *pixels_new = NULL;
int n_opaque, n_trans, n_alpha, len, histo[256]; int n_opaque, n_trans, n_alpha, len, histo[256];
int send_alpha = 0, alpha_shift, thresh; int send_alpha = 0, alpha_shift, thresh;
int i, x, y; int i, x, y;
...@@ -16308,6 +16592,8 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16308,6 +16592,8 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
if (scaling_cursor && scale_cursor_fac != 1.0) { if (scaling_cursor && scale_cursor_fac != 1.0) {
int W, H; int W, H;
char *pixels_use = (char *) pixels;
unsigned int *pixels32 = NULL;
W = w; W = w;
H = h; H = h;
...@@ -16315,15 +16601,52 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16315,15 +16601,52 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
w = scale_round(W, scale_cursor_fac); w = scale_round(W, scale_cursor_fac);
h = scale_round(H, scale_cursor_fac); h = scale_round(H, scale_cursor_fac);
new_pixels = (char *) malloc(4 * w * h); pixels_new = (char *) malloc(4*w*h);
scale_rect(scale_cursor_fac, scaling_cursor_blend, if (sizeof(unsigned long) == 8) {
scaling_cursor_interpolate, 4, int i, j, k = 0;
(char *) pixels, 4*W, new_pixels, 4*w, /*
W, H, w, h, * to avoid 64bpp code in scale_rect() we knock
0, 0, W, H, 0); * down to unsigned int on 64bit machines:
*/
pixels32 = (unsigned int*) malloc(4*W*H);
for (j=0; j<H; j++) {
for (i=0; i<W; i++) {
*(pixels32+k) = 0xffffffff & (*(pixels+k));
k++;
}
}
pixels_use = (char *) pixels32;
}
pixels = (unsigned long *) new_pixels; scale_rect(scale_cursor_fac, scaling_cursor_blend,
scaling_cursor_interpolate,
4, pixels_use, 4*W, pixels_new, 4*w,
W, H, w, h, 0, 0, W, H, 0);
if (sizeof(unsigned long) == 8) {
int i, j, k = 0;
unsigned long *pixels64;
unsigned int* source = (unsigned int*) pixels_new;
/*
* now knock it back up to unsigned long:
*/
pixels64 = (unsigned long*) malloc(8*w*h);
for (j=0; j<h; j++) {
for (i=0; i<w; i++) {
*(pixels64+k) = (unsigned long) (*(source+k));
k++;
}
}
free(pixels_new);
pixels_new = (char *) pixels64;
if (pixels32) {
free(pixels32);
pixels32 = NULL;
}
}
pixels = (unsigned long *) pixels_new;
xhot = scale_round(xhot, scale_cursor_fac); xhot = scale_round(xhot, scale_cursor_fac);
yhot = scale_round(yhot, scale_cursor_fac); yhot = scale_round(yhot, scale_cursor_fac);
...@@ -16331,7 +16654,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16331,7 +16654,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
len = w * h; len = w * h;
/* for bitmap data */ /* for bitmap data */
bitmap = (char *)malloc(len+1); bitmap = (char *) malloc(len+1);
bitmap[len] = '\0'; bitmap[len] = '\0';
/* for rich cursor pixel data */ /* for rich cursor pixel data */
...@@ -16356,7 +16679,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16356,7 +16679,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
n_alpha++; n_alpha++;
} }
histo[a]++; histo[a]++;
if (a < alpha_threshold) { if (a < (unsigned int) alpha_threshold) {
n_trans++; n_trans++;
} else { } else {
n_opaque++; n_opaque++;
...@@ -16399,7 +16722,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16399,7 +16722,7 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
a = a >> 24; /* alpha channel */ a = a >> 24; /* alpha channel */
if (a < thresh) { if (a < (unsigned int) thresh) {
bitmap[i] = ' '; bitmap[i] = ' ';
} else { } else {
bitmap[i] = 'x'; bitmap[i] = 'x';
...@@ -16482,8 +16805,8 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16482,8 +16805,8 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
c = rfbMakeXCursor(w, h, bitmap, bitmap); c = rfbMakeXCursor(w, h, bitmap, bitmap);
free(bitmap); free(bitmap);
if (new_pixels) { if (pixels_new) {
free(new_pixels); free(pixels_new);
} }
/* set up the cursor parameters: */ /* set up the cursor parameters: */
...@@ -16493,10 +16816,10 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h, ...@@ -16493,10 +16816,10 @@ rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
c->cleanupSource = FALSE; c->cleanupSource = FALSE;
c->cleanupMask = FALSE; c->cleanupMask = FALSE;
c->cleanupRichSource = FALSE; c->cleanupRichSource = FALSE;
c->richSource = rich; c->richSource = (unsigned char *) rich;
if (alpha_blend && !indexed_color) { if (alpha_blend && !indexed_color) {
c->alphaSource = alpha; c->alphaSource = (unsigned char *) alpha;
c->alphaPreMultiplied = TRUE; c->alphaPreMultiplied = TRUE;
} else { } else {
free(alpha); free(alpha);
...@@ -17024,6 +17347,8 @@ int set_cursor(int x, int y, int which) { ...@@ -17024,6 +17347,8 @@ int set_cursor(int x, int y, int which) {
static int last = -1; static int last = -1;
int changed_cursor = 0; int changed_cursor = 0;
if (x || y) {} /* unused vars warning: */
if (which < 0) { if (which < 0) {
which = last; which = last;
} }
...@@ -17106,8 +17431,8 @@ void set_colormap(int reset) { ...@@ -17106,8 +17431,8 @@ void set_colormap(int reset) {
screen->colourMap.count = NCOLOR; screen->colourMap.count = NCOLOR;
screen->serverFormat.trueColour = FALSE; screen->serverFormat.trueColour = FALSE;
screen->colourMap.is16 = TRUE; screen->colourMap.is16 = TRUE;
screen->colourMap.data.shorts = (unsigned short*) screen->colourMap.data.shorts = (unsigned short *)
malloc(3*sizeof(short) * NCOLOR); malloc(3*sizeof(unsigned short) * NCOLOR);
} }
for (i=0; i < NCOLOR; i++) { for (i=0; i < NCOLOR; i++) {
...@@ -17319,13 +17644,14 @@ void set_visual(char *str) { ...@@ -17319,13 +17644,14 @@ void set_visual(char *str) {
} else if (strcmp(vstring, "DirectColor") == 0) { } else if (strcmp(vstring, "DirectColor") == 0) {
vis = DirectColor; vis = DirectColor;
} else { } else {
int v_in; unsigned int v_in;
if (sscanf(vstring, "0x%x", &v_in) != 1) { if (sscanf(vstring, "0x%x", &v_in) != 1) {
if (sscanf(vstring, "%d", &v_in) == 1) { if (sscanf(vstring, "%u", &v_in) == 1) {
visual_id = (VisualID) v_in; visual_id = (VisualID) v_in;
return; return;
} }
rfbLog("bad -visual arg: %s\n", vstring); rfbLogEnable(1);
rfbLog("invalid -visual arg: %s\n", vstring);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -17340,6 +17666,7 @@ void set_visual(char *str) { ...@@ -17340,6 +17666,7 @@ void set_visual(char *str) {
} else if (XMatchVisualInfo(dpy, scr, defdepth, vis, &vinfo)) { } else if (XMatchVisualInfo(dpy, scr, defdepth, vis, &vinfo)) {
; ;
} else { } else {
rfbLogEnable(1);
rfbLog("could not find visual: %s\n", vstring); rfbLog("could not find visual: %s\n", vstring);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
...@@ -17430,17 +17757,20 @@ void set_raw_fb_params(int restore) { ...@@ -17430,17 +17757,20 @@ void set_raw_fb_params(int restore) {
if (! dpy && raw_fb_orig_dpy) { if (! dpy && raw_fb_orig_dpy) {
dpy = XOpenDisplay(raw_fb_orig_dpy); dpy = XOpenDisplay(raw_fb_orig_dpy);
if (dpy) { if (dpy) {
rfbLog("reopened DISPLAY: %s\n", if (! quiet) rfbLog("reopened DISPLAY: %s\n",
raw_fb_orig_dpy); raw_fb_orig_dpy);
} else { } else {
rfbLog("WARNING: failed to reopen " if (! quiet) rfbLog("WARNING: failed to reopen "
"DISPLAY: %s\n", raw_fb_orig_dpy); "DISPLAY: %s\n", raw_fb_orig_dpy);
} }
} }
return; return;
} }
rfbLog("set_raw_fb_params: modifying settings for -rawfb mode.\n"); if (! quiet) {
rfbLog("set_raw_fb_params: modifying settings for "
"-rawfb mode.\n");
}
if (got_noviewonly) { if (got_noviewonly) {
/* /*
...@@ -17449,50 +17779,56 @@ void set_raw_fb_params(int restore) { ...@@ -17449,50 +17779,56 @@ void set_raw_fb_params(int restore) {
* (i.e. rawfb but also send user input to the X * (i.e. rawfb but also send user input to the X
* display, most likely using /dev/fb0 for some reason...) * display, most likely using /dev/fb0 for some reason...)
*/ */
rfbLog("rawfb: -noviewonly mode: still sending mouse and\n"); if (! quiet) {
rfbLog("rawfb: keyboard input to the X DISPLAY!!\n"); rfbLog("rawfb: -noviewonly mode: still sending mouse and\n");
rfbLog("rawfb: keyboard input to the X DISPLAY!!\n");
}
} else { } else {
/* Normal case: */ /* Normal case: */
if (! view_only) { if (! view_only) {
rfbLog("rawfb: setting view_only\n"); if (! quiet) rfbLog("rawfb: setting view_only\n");
view_only = 1; view_only = 1;
} }
if (watch_selection) { if (watch_selection) {
rfbLog("rawfb: turning off watch_selection\n"); if (! quiet) rfbLog("rawfb: turning off "
"watch_selection\n");
watch_selection = 0; watch_selection = 0;
} }
if (watch_primary) { if (watch_primary) {
rfbLog("rawfb: turning off watch_primary\n"); if (! quiet) rfbLog("rawfb: turning off "
"watch_primary\n");
watch_primary = 0; watch_primary = 0;
} }
if (watch_bell) { if (watch_bell) {
rfbLog("rawfb: turning off watch_bell\n"); if (! quiet) rfbLog("rawfb: turning off watch_bell\n");
watch_bell = 0; watch_bell = 0;
} }
if (no_autorepeat) { if (no_autorepeat) {
rfbLog("rawfb: turning off no_autorepeat\n"); if (! quiet) rfbLog("rawfb: turning off "
"no_autorepeat\n");
no_autorepeat = 0; no_autorepeat = 0;
} }
if (use_solid_bg) { if (use_solid_bg) {
rfbLog("rawfb: turning off use_solid_bg\n"); if (! quiet) rfbLog("rawfb: turning off "
"use_solid_bg\n");
use_solid_bg = 0; use_solid_bg = 0;
} }
multiple_cursors_mode = strdup("arrow"); multiple_cursors_mode = strdup("arrow");
} }
if (use_snapfb) { if (use_snapfb) {
rfbLog("rawfb: turning off use_snapfb\n"); if (! quiet) rfbLog("rawfb: turning off use_snapfb\n");
use_snapfb = 0; use_snapfb = 0;
} }
if (using_shm) { if (using_shm) {
rfbLog("rawfb: turning off using_shm\n"); if (! quiet) rfbLog("rawfb: turning off using_shm\n");
using_shm = 0; using_shm = 0;
} }
if (take_naps) { if (take_naps) {
rfbLog("rawfb: turning off take_naps\n"); if (! quiet) rfbLog("rawfb: turning off take_naps\n");
take_naps = 0; take_naps = 0;
} }
if (xrandr) { if (xrandr) {
rfbLog("rawfb: turning off xrandr\n"); if (! quiet) rfbLog("rawfb: turning off xrandr\n");
xrandr = 0; xrandr = 0;
} }
} }
...@@ -17664,6 +18000,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17664,6 +18000,7 @@ XImage *initialize_raw_fb(void) {
set_child_info(); set_child_info();
q += strlen("setup:"); q += strlen("setup:");
if (no_external_cmds) { if (no_external_cmds) {
rfbLogEnable(1);
rfbLog("cannot run external commands in -nocmds " rfbLog("cannot run external commands in -nocmds "
"mode:\n"); "mode:\n");
rfbLog(" \"%s\"\n", q); rfbLog(" \"%s\"\n", q);
...@@ -17673,12 +18010,14 @@ XImage *initialize_raw_fb(void) { ...@@ -17673,12 +18010,14 @@ XImage *initialize_raw_fb(void) {
rfbLog("running command to setup rawfb: %s\n", q); rfbLog("running command to setup rawfb: %s\n", q);
pipe = popen(q, "r"); pipe = popen(q, "r");
if (! pipe) { if (! pipe) {
rfbLogEnable(1);
rfbLog("popen of setup command failed.\n"); rfbLog("popen of setup command failed.\n");
rfbLogPerror("popen"); rfbLogPerror("popen");
clean_up_exit(1); clean_up_exit(1);
} }
line[0] = '\0'; line[0] = '\0';
if (fgets(line, 1024, pipe) == NULL) { if (fgets(line, 1024, pipe) == NULL) {
rfbLogEnable(1);
rfbLog("read of setup command failed.\n"); rfbLog("read of setup command failed.\n");
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -17770,11 +18109,13 @@ XImage *initialize_raw_fb(void) { ...@@ -17770,11 +18109,13 @@ XImage *initialize_raw_fb(void) {
} }
} }
if ((q = strrchr(str, '@')) == NULL) { if ((q = strrchr(str, '@')) == NULL) {
rfbLogEnable(1);
rfbLog("invalid rawfb str: %s\n", str); rfbLog("invalid rawfb str: %s\n", str);
clean_up_exit(1); clean_up_exit(1);
} }
/* @WxHxB */ /* @WxHxB */
if (sscanf(q, "@%dx%dx%d", &w, &h, &b) != 3) { if (sscanf(q, "@%dx%dx%d", &w, &h, &b) != 3) {
rfbLogEnable(1);
rfbLog("invalid rawfb str: %s\n", str); rfbLog("invalid rawfb str: %s\n", str);
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -17790,7 +18131,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17790,7 +18131,7 @@ XImage *initialize_raw_fb(void) {
rfbLog("no type prefix: %s\n", raw_fb_str); rfbLog("no type prefix: %s\n", raw_fb_str);
rfbLog(" but file exists, so assuming: map:%s\n", rfbLog(" but file exists, so assuming: map:%s\n",
raw_fb_str); raw_fb_str);
new = (char *)malloc(len); new = (char *) malloc(len);
strcpy(new, "map:"); strcpy(new, "map:");
strcat(new, str); strcat(new, str);
free(str); free(str);
...@@ -17814,6 +18155,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17814,6 +18155,7 @@ XImage *initialize_raw_fb(void) {
#if LIBVNCSERVER_HAVE_XSHM #if LIBVNCSERVER_HAVE_XSHM
raw_fb_addr = (char *) shmat(shmid, 0, SHM_RDONLY); raw_fb_addr = (char *) shmat(shmid, 0, SHM_RDONLY);
if (! raw_fb_addr) { if (! raw_fb_addr) {
rfbLogEnable(1);
rfbLog("failed to attach to shm: %d, %s\n", shmid, str); rfbLog("failed to attach to shm: %d, %s\n", shmid, str);
rfbLogPerror("shmat"); rfbLogPerror("shmat");
clean_up_exit(1); clean_up_exit(1);
...@@ -17822,6 +18164,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17822,6 +18164,7 @@ XImage *initialize_raw_fb(void) {
rfbLog("rawfb: shm: %d W: %d H: %d B: %d addr: %p\n", rfbLog("rawfb: shm: %d W: %d H: %d B: %d addr: %p\n",
shmid, w, h, b, raw_fb_addr); shmid, w, h, b, raw_fb_addr);
#else #else
rfbLogEnable(1);
rfbLog("x11vnc was compiled without shm support.\n"); rfbLog("x11vnc was compiled without shm support.\n");
rfbLogPerror("shmat"); rfbLogPerror("shmat");
clean_up_exit(1); clean_up_exit(1);
...@@ -17840,6 +18183,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17840,6 +18183,7 @@ XImage *initialize_raw_fb(void) {
fd = open(q, O_RDONLY); fd = open(q, O_RDONLY);
if (fd < 0) { if (fd < 0) {
rfbLogEnable(1);
rfbLog("failed to open file: %s, %s\n", q, str); rfbLog("failed to open file: %s, %s\n", q, str);
rfbLogPerror("open"); rfbLogPerror("open");
clean_up_exit(1); clean_up_exit(1);
...@@ -17861,6 +18205,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17861,6 +18205,7 @@ XImage *initialize_raw_fb(void) {
fd, 0); fd, 0);
if (raw_fb_addr == MAP_FAILED || raw_fb_addr == NULL) { if (raw_fb_addr == MAP_FAILED || raw_fb_addr == NULL) {
rfbLogEnable(1);
rfbLog("failed to mmap file: %s, %s\n", q, str); rfbLog("failed to mmap file: %s, %s\n", q, str);
rfbLog(" raw_fb_addr: %p\n", raw_fb_addr); rfbLog(" raw_fb_addr: %p\n", raw_fb_addr);
rfbLogPerror("mmap"); rfbLogPerror("mmap");
...@@ -17883,6 +18228,7 @@ XImage *initialize_raw_fb(void) { ...@@ -17883,6 +18228,7 @@ XImage *initialize_raw_fb(void) {
rfbLog(" W: %d H: %d B: %d sz: %d\n", w, h, b, size); rfbLog(" W: %d H: %d B: %d sz: %d\n", w, h, b, size);
} }
} else { } else {
rfbLogEnable(1);
rfbLog("invalid rawfb str: %s\n", str); rfbLog("invalid rawfb str: %s\n", str);
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -18017,6 +18363,7 @@ XImage *initialize_xdisplay_fb(void) { ...@@ -18017,6 +18363,7 @@ XImage *initialize_xdisplay_fb(void) {
wait_until_mapped(subwin); wait_until_mapped(subwin);
} }
if (!valid_window((Window) subwin, NULL, 0)) { if (!valid_window((Window) subwin, NULL, 0)) {
rfbLogEnable(1);
rfbLog("invalid sub-window: 0x%lx\n", subwin); rfbLog("invalid sub-window: 0x%lx\n", subwin);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
...@@ -18073,6 +18420,7 @@ XImage *initialize_xdisplay_fb(void) { ...@@ -18073,6 +18420,7 @@ XImage *initialize_xdisplay_fb(void) {
window = (Window) subwin; window = (Window) subwin;
if (! XGetWindowAttributes(dpy, window, &attr)) { if (! XGetWindowAttributes(dpy, window, &attr)) {
rfbLogEnable(1);
rfbLog("invalid window: 0x%lx\n", window); rfbLog("invalid window: 0x%lx\n", window);
X_UNLOCK; X_UNLOCK;
clean_up_exit(1); clean_up_exit(1);
...@@ -18107,6 +18455,7 @@ XImage *initialize_xdisplay_fb(void) { ...@@ -18107,6 +18455,7 @@ XImage *initialize_xdisplay_fb(void) {
vinfo_tmpl.visualid = visual_id; vinfo_tmpl.visualid = visual_id;
vinfo = XGetVisualInfo(dpy, VisualIDMask, &vinfo_tmpl, &n); vinfo = XGetVisualInfo(dpy, VisualIDMask, &vinfo_tmpl, &n);
if (vinfo == NULL || n == 0) { if (vinfo == NULL || n == 0) {
rfbLogEnable(1);
rfbLog("could not match visual_id: 0x%x\n", rfbLog("could not match visual_id: 0x%x\n",
(int) visual_id); (int) visual_id);
X_UNLOCK; X_UNLOCK;
...@@ -18120,7 +18469,8 @@ XImage *initialize_xdisplay_fb(void) { ...@@ -18120,7 +18469,8 @@ XImage *initialize_xdisplay_fb(void) {
} }
if (! quiet) { if (! quiet) {
fprintf(stderr, " initialize_xdisplay_fb()\n"); fprintf(stderr, " initialize_xdisplay_fb()\n");
fprintf(stderr, " Visual*: %p\n", vinfo->visual); fprintf(stderr, " Visual*: %p\n",
(void *) vinfo->visual);
fprintf(stderr, " visualid: 0x%x\n", fprintf(stderr, " visualid: 0x%x\n",
(int) vinfo->visualid); (int) vinfo->visualid);
fprintf(stderr, " screen: %d\n", vinfo->screen); fprintf(stderr, " screen: %d\n", vinfo->screen);
...@@ -18217,6 +18567,7 @@ XImage *initialize_xdisplay_fb(void) { ...@@ -18217,6 +18567,7 @@ XImage *initialize_xdisplay_fb(void) {
if (try < subwin_tries) { if (try < subwin_tries) {
usleep(250 * 1000); usleep(250 * 1000);
if (!get_window_size(window, &wdpy_x, &wdpy_y)) { if (!get_window_size(window, &wdpy_x, &wdpy_y)) {
rfbLogEnable(1);
rfbLog("could not get size of subwin " rfbLog("could not get size of subwin "
"0x%lx\n", subwin); "0x%lx\n", subwin);
X_UNLOCK; X_UNLOCK;
...@@ -18280,17 +18631,20 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend, ...@@ -18280,17 +18631,20 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend,
if (strstr(p+1, "pad") != NULL) { if (strstr(p+1, "pad") != NULL) {
*pad = 1; *pad = 1;
} }
if (strstr(p+1, "cr") != NULL) { if (strstr(p+1, "nocr") != NULL) {
/* global */ /* global */
got_scrollcopyrect = 1; scaling_copyrect = 0;
got_wirecopyrect = 1; } else if (strstr(p+1, "cr") != NULL) {
/* global */
scaling_copyrect = 1;
} }
*p = '\0'; *p = '\0';
} }
if (strchr(tstr, '.') != NULL) { if (strchr(tstr, '.') != NULL) {
double test, diff, eps = 1.0e-7; double test, diff, eps = 1.0e-7;
if (sscanf(tstr, "%lf", &f) != 1) { if (sscanf(tstr, "%lf", &f) != 1) {
rfbLog("bad -scale arg: %s\n", tstr); rfbLogEnable(1);
rfbLog("invalid -scale arg: %s\n", tstr);
clean_up_exit(1); clean_up_exit(1);
} }
*factor = (double) f; *factor = (double) f;
...@@ -18311,13 +18665,15 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend, ...@@ -18311,13 +18665,15 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend,
} }
} }
if (*factor < 0.01) { if (*factor < 0.01) {
rfbLogEnable(1);
rfbLog("-scale factor too small: %f\n", scale_fac); rfbLog("-scale factor too small: %f\n", scale_fac);
clean_up_exit(1); clean_up_exit(1);
} }
} else { } else {
if (sscanf(tstr, "%d/%d", &m, &n) != 2) { if (sscanf(tstr, "%d/%d", &m, &n) != 2) {
if (sscanf(tstr, "%d", &m) != 1) { if (sscanf(tstr, "%d", &m) != 1) {
rfbLog("bad -scale arg: %s\n", tstr); rfbLogEnable(1);
rfbLog("invalid -scale arg: %s\n", tstr);
clean_up_exit(1); clean_up_exit(1);
} else { } else {
/* e.g. -scale 1 or -scale 2 */ /* e.g. -scale 1 or -scale 2 */
...@@ -18325,11 +18681,13 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend, ...@@ -18325,11 +18681,13 @@ void parse_scale_string(char *str, double *factor, int *scaling, int *blend,
} }
} }
if (n <= 0 || m <=0) { if (n <= 0 || m <=0) {
rfbLog("bad -scale arg: %s\n", tstr); rfbLogEnable(1);
rfbLog("invalid -scale arg: %s\n", tstr);
clean_up_exit(1); clean_up_exit(1);
} }
*factor = ((double) m)/ n; *factor = ((double) m)/ n;
if (*factor < 0.01) { if (*factor < 0.01) {
rfbLogEnable(1);
rfbLog("-scale factor too small: %f\n", *factor); rfbLog("-scale factor too small: %f\n", *factor);
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -18470,6 +18828,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -18470,6 +18828,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
} }
if (! screen) { if (! screen) {
int i; int i;
rfbLogEnable(1);
rfbLog("\n"); rfbLog("\n");
rfbLog("failed to create rfb screen.\n"); rfbLog("failed to create rfb screen.\n");
for (i=0; i< *argc; i++) { for (i=0; i< *argc; i++) {
...@@ -18480,6 +18839,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -18480,6 +18839,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (create_screen && *argc != 1) { if (create_screen && *argc != 1) {
int i; int i;
rfbLogEnable(1);
rfbLog("*** unrecognized option(s) ***\n"); rfbLog("*** unrecognized option(s) ***\n");
for (i=1; i< *argc; i++) { for (i=1; i< *argc; i++) {
rfbLog("\t[%d] %s\n", i, argv[i]); rfbLog("\t[%d] %s\n", i, argv[i]);
...@@ -18740,6 +19100,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -18740,6 +19100,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (inetd) { if (inetd) {
int fd = dup(0); int fd = dup(0);
if (fd < 3) { if (fd < 3) {
rfbLogEnable(1);
rfbErr("dup(0) = %d failed.\n", fd); rfbErr("dup(0) = %d failed.\n", fd);
rfbLogPerror("dup"); rfbLogPerror("dup");
clean_up_exit(1); clean_up_exit(1);
...@@ -18778,7 +19139,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -18778,7 +19139,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (viewonly_passwd) { if (viewonly_passwd) {
/* append the view only passwd after the normal passwd */ /* append the view only passwd after the normal passwd */
char **passwds_new = malloc(3*sizeof(char**)); char **passwds_new = (char **) malloc(3*sizeof(char *));
char **passwds_old = (char **) screen->authPasswdData; char **passwds_old = (char **) screen->authPasswdData;
passwds_new[0] = passwds_old[0]; passwds_new[0] = passwds_old[0];
passwds_new[1] = viewonly_passwd; passwds_new[1] = viewonly_passwd;
...@@ -19148,7 +19509,7 @@ void solid_cde(char *color) { ...@@ -19148,7 +19509,7 @@ void solid_cde(char *color) {
cnt = 0; cnt = 0;
twin = 0x0; twin = 0x0;
for (i=0; i<length; i++) { for (i=0; i< (int) length; i++) {
if (*(data+i) != '\0') { if (*(data+i) != '\0') {
continue; continue;
} }
...@@ -19259,19 +19620,19 @@ void solid_gnome(char *color) { ...@@ -19259,19 +19620,19 @@ void solid_gnome(char *color) {
orig_option = strdup("stretched"); orig_option = strdup("stretched");
} }
if (strstr(orig_color, "'") != NULL) { if (strstr(orig_color, "'") != NULL) {
rfbLog("bad color: %s\n", orig_color); rfbLog("invalid color: %s\n", orig_color);
return; return;
} }
if (strstr(orig_option, "'") != NULL) { if (strstr(orig_option, "'") != NULL) {
rfbLog("bad option: %s\n", orig_option); rfbLog("invalid option: %s\n", orig_option);
return; return;
} }
cmd = (char *)malloc(strlen(set_option) - 2 + cmd = (char *) malloc(strlen(set_option) - 2 +
strlen(orig_option) + 1); strlen(orig_option) + 1);
sprintf(cmd, set_option, orig_option); sprintf(cmd, set_option, orig_option);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
cmd = (char *)malloc(strlen(set_color) - 2 + cmd = (char *) malloc(strlen(set_color) - 2 +
strlen(orig_color) + 1); strlen(orig_color) + 1);
sprintf(cmd, set_color, orig_color); sprintf(cmd, set_color, orig_color);
dt_cmd(cmd); dt_cmd(cmd);
...@@ -19300,15 +19661,15 @@ void solid_gnome(char *color) { ...@@ -19300,15 +19661,15 @@ void solid_gnome(char *color) {
} }
} }
if (strstr(color, "'") != NULL) { if (strstr(color, "'") != NULL) {
rfbLog("bad color: %s\n", color); rfbLog("invalid color: %s\n", color);
return; return;
} }
cmd = (char *)malloc(strlen(set_color) + strlen(color) + 1); cmd = (char *) malloc(strlen(set_color) + strlen(color) + 1);
sprintf(cmd, set_color, color); sprintf(cmd, set_color, color);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
cmd = (char *)malloc(strlen(set_option) + strlen("none") + 1); cmd = (char *) malloc(strlen(set_option) + strlen("none") + 1);
sprintf(cmd, set_option, "none"); sprintf(cmd, set_option, "none");
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
...@@ -19326,14 +19687,14 @@ void solid_kde(char *color) { ...@@ -19326,14 +19687,14 @@ void solid_kde(char *color) {
user = get_user_name(); user = get_user_name();
if (strstr(user, "'") != NULL) { if (strstr(user, "'") != NULL) {
rfbLog("bad user: %s\n", user); rfbLog("invalid user: %s\n", user);
free(user); free(user);
return; return;
} }
if (! color) { if (! color) {
len = strlen(bg_on) + strlen(user) + 1; len = strlen(bg_on) + strlen(user) + 1;
cmd = (char *)malloc(len); cmd = (char *) malloc(len);
sprintf(cmd, bg_on, user); sprintf(cmd, bg_on, user);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
...@@ -19343,18 +19704,18 @@ void solid_kde(char *color) { ...@@ -19343,18 +19704,18 @@ void solid_kde(char *color) {
} }
if (strstr(color, "'") != NULL) { if (strstr(color, "'") != NULL) {
rfbLog("bad color: %s\n", color); rfbLog("invalid color: %s\n", color);
return; return;
} }
len = strlen(set_color) + strlen(user) + strlen(color) + 1; len = strlen(set_color) + strlen(user) + strlen(color) + 1;
cmd = (char *)malloc(len); cmd = (char *) malloc(len);
sprintf(cmd, set_color, user, color); sprintf(cmd, set_color, user, color);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
len = strlen(bg_off) + strlen(user) + 1; len = strlen(bg_off) + strlen(user) + 1;
cmd = (char *)malloc(len); cmd = (char *) malloc(len);
sprintf(cmd, bg_off, user); sprintf(cmd, bg_off, user);
dt_cmd(cmd); dt_cmd(cmd);
free(cmd); free(cmd);
...@@ -19364,23 +19725,25 @@ void solid_kde(char *color) { ...@@ -19364,23 +19725,25 @@ void solid_kde(char *color) {
char *guess_desktop() { char *guess_desktop() {
Atom prop; Atom prop;
prop = XInternAtom(dpy, "XFCE_DESKTOP_WINDOW", True); prop = XInternAtom(dpy, "XFCE_DESKTOP_WINDOW", True);
if (prop != None) { if (prop != None) return "xfce";
return "xfce";
} /* special case windowmaker */
prop = XInternAtom(dpy, "_QT_DESKTOP_PROPERTIES", True); prop = XInternAtom(dpy, "_WINDOWMAKER_WM_PROTOCOLS", True);
if (prop != None) { if (prop != None) return "root";
return "kde";
} prop = XInternAtom(dpy, "_WINDOWMAKER_COMMAND", True);
if (prop != None) return "root";
prop = XInternAtom(dpy, "NAUTILUS_DESKTOP_WINDOW_ID", True); prop = XInternAtom(dpy, "NAUTILUS_DESKTOP_WINDOW_ID", True);
if (prop != None) { if (prop != None) return "gnome";
return "gnome";
} prop = XInternAtom(dpy, "KWIN_RUNNING", True);
if (prop != None) return "kde";
prop = XInternAtom(dpy, "_MOTIF_WM_INFO", True); prop = XInternAtom(dpy, "_MOTIF_WM_INFO", True);
if (prop != None) { if (prop != None) {
prop = XInternAtom(dpy, "_DT_WORKSPACE_LIST", True); prop = XInternAtom(dpy, "_DT_WORKSPACE_LIST", True);
if (prop != None) { if (prop != None) return "cde";
return "cde";
}
} }
return "root"; return "root";
} }
...@@ -19747,8 +20110,8 @@ void initialize_xinerama (void) { ...@@ -19747,8 +20110,8 @@ void initialize_xinerama (void) {
/* max len is 10000x10000+10000+10000 (23 chars) per geometry */ /* max len is 10000x10000+10000+10000 (23 chars) per geometry */
rcnt = (int) sraRgnCountRects(black_region); rcnt = (int) sraRgnCountRects(black_region);
bstr = (char *) malloc(30 * (rcnt+1) * sizeof(char)); bstr = (char *) malloc(30 * (rcnt+1));
tstr = (char *) malloc(30 * sizeof(char)); tstr = (char *) malloc(30);
bstr[0] = '\0'; bstr[0] = '\0';
iter = sraRgnGetIterator(black_region); iter = sraRgnGetIterator(black_region);
...@@ -19794,7 +20157,7 @@ void initialize_blackouts_and_xinerama(void) { ...@@ -19794,7 +20157,7 @@ void initialize_blackouts_and_xinerama(void) {
} }
} }
void push_sleep(n) { void push_sleep(int n) {
int i; int i;
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
rfbPE(-1); rfbPE(-1);
...@@ -20025,11 +20388,19 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, ...@@ -20025,11 +20388,19 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
if (xim == NULL) { if (xim == NULL) {
rfbErr("XCreateImage(%s) failed.\n", name); rfbErr("XCreateImage(%s) failed.\n", name);
if (quiet) {
fprintf(stderr, "XCreateImage(%s) failed.\n",
name);
}
return 0; return 0;
} }
xim->data = (char *) malloc(xim->bytes_per_line * xim->height); xim->data = (char *) malloc(xim->bytes_per_line * xim->height);
if (xim->data == NULL) { if (xim->data == NULL) {
rfbErr("XCreateImage(%s) data malloc failed.\n", name); rfbErr("XCreateImage(%s) data malloc failed.\n", name);
if (quiet) {
fprintf(stderr, "XCreateImage(%s) data malloc"
" failed.\n", name);
}
return 0; return 0;
} }
if (flip_byte_order) { if (flip_byte_order) {
...@@ -20050,6 +20421,9 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, ...@@ -20050,6 +20421,9 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
if (xim == NULL) { if (xim == NULL) {
rfbErr("XShmCreateImage(%s) failed.\n", name); rfbErr("XShmCreateImage(%s) failed.\n", name);
if (quiet) {
fprintf(stderr, "XShmCreateImage(%s) failed.\n", name);
}
X_UNLOCK; X_UNLOCK;
return 0; return 0;
} }
...@@ -22371,7 +22745,7 @@ int scan_for_updates(int count_only) { ...@@ -22371,7 +22745,7 @@ int scan_for_updates(int count_only) {
} }
/* -- gui.c -- */ /* -- gui.c -- */
#if SMALL_FOOTPRINT #ifdef NOGUI
char gui_code[] = ""; char gui_code[] = "";
#else #else
#include "tkx11vnc.h" #include "tkx11vnc.h"
...@@ -22390,7 +22764,7 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui, ...@@ -22390,7 +22764,7 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
FILE *pipe, *tmpf; FILE *pipe, *tmpf;
if (*gui_code == '\0') { if (*gui_code == '\0') {
rfbLog("gui not available in this program.\n"); rfbLog("gui not compiled into this program.\n");
exit(0); exit(0);
} }
if (getenv("DISPLAY") != NULL) { if (getenv("DISPLAY") != NULL) {
...@@ -22496,7 +22870,7 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui, ...@@ -22496,7 +22870,7 @@ void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int simple_gui,
"wish8.0"}; "wish8.0"};
int nwishes = 3, i; int nwishes = 3, i;
try = (char *)malloc(strlen(p) + 1 + strlen("wish8.4") + 1); try = (char *) malloc(strlen(p) + 1 + strlen("wish8.4") + 1);
for (i=0; i<nwishes; i++) { for (i=0; i<nwishes; i++) {
sprintf(try, "%s/%s", p, wishes[i]); sprintf(try, "%s/%s", p, wishes[i]);
if (stat(try, &sbuf) == 0) { if (stat(try, &sbuf) == 0) {
...@@ -22692,7 +23066,7 @@ Window descend_pointer(int depth, Window start, char *name_info, int len) { ...@@ -22692,7 +23066,7 @@ Window descend_pointer(int depth, Window start, char *name_info, int len) {
} }
if (! nm_cache) { if (! nm_cache) {
nm_cache = (char *)malloc(1024); nm_cache = (char *) malloc(1024);
nm_cache_len = 1024; nm_cache_len = 1024;
nm_cache[0] = '\0'; nm_cache[0] = '\0';
} }
...@@ -22701,7 +23075,7 @@ Window descend_pointer(int depth, Window start, char *name_info, int len) { ...@@ -22701,7 +23075,7 @@ Window descend_pointer(int depth, Window start, char *name_info, int len) {
free(nm_cache); free(nm_cache);
} }
nm_cache_len = 2*len; nm_cache_len = 2*len;
nm_cache = (char *)malloc(nm_cache_len); nm_cache = (char *) malloc(nm_cache_len);
} }
if (name_info) { if (name_info) {
...@@ -22947,8 +23321,8 @@ void parse_fixscreen(void) { ...@@ -22947,8 +23321,8 @@ void parse_fixscreen(void) {
} }
/* /*
WIREFRAME_PARMS "0xff,2,0,30+6+6+6,0.05+0.3+2.0,8" WIREFRAME_PARMS "0xff,2,0,30+6+6+6,Alt,0.05+0.3+2.0,8"
shade,linewidth,percent,T+B+L+R,t1+t2+t3 shade,linewidth,percent,T+B+L+R,mods,t1+t2+t3+t4
*/ */
#define LW_MAX 8 #define LW_MAX 8
unsigned long wireframe_shade; unsigned long wireframe_shade;
...@@ -22956,6 +23330,7 @@ int wireframe_lw; ...@@ -22956,6 +23330,7 @@ int wireframe_lw;
double wireframe_frac; double wireframe_frac;
int wireframe_top, wireframe_bot, wireframe_left, wireframe_right; int wireframe_top, wireframe_bot, wireframe_left, wireframe_right;
double wireframe_t1, wireframe_t2, wireframe_t3, wireframe_t4; double wireframe_t1, wireframe_t2, wireframe_t3, wireframe_t4;
char *wireframe_mods = NULL;
/* /*
* Parse the gory -wireframe string for parameters. * Parse the gory -wireframe string for parameters.
...@@ -23021,7 +23396,7 @@ void parse_wireframe_str(char *wf) { ...@@ -23021,7 +23396,7 @@ void parse_wireframe_str(char *wf) {
; ;
} else if (sscanf(str, "0x%lx", &n) == 1) { } else if (sscanf(str, "0x%lx", &n) == 1) {
wireframe_shade = n; wireframe_shade = n;
} else if (sscanf(str, "%ld", &n) == 1) { } else if (sscanf(str, "%lu", &n) == 1) {
wireframe_shade = n; wireframe_shade = n;
} else if (sscanf(str, "%lx", &n) == 1) { } else if (sscanf(str, "%lx", &n) == 1) {
wireframe_shade = n; wireframe_shade = n;
...@@ -23071,8 +23446,30 @@ void parse_wireframe_str(char *wf) { ...@@ -23071,8 +23446,30 @@ void parse_wireframe_str(char *wf) {
free(str); free(str);
} }
/* check_wireframe() timing heuristics. */ /*
* wireframe in interior with Modifier down.
* 0 => no mods
* 1 => all mods
* Shift,Alt,Control,Meta,Super,Hyper
*/
if (wireframe_mods) {
free(wireframe_mods);
}
wireframe_mods = NULL;
if ((str = part[4]) != NULL) { if ((str = part[4]) != NULL) {
if (*str == '0' || !strcmp(str, "none")) {
;
} else if (*str == '1' || !strcmp(str, "all")) {
wireframe_mods = strdup("all");
} else if (!strcmp(str, "Alt") || !strcmp(str, "Shift")
|| !strcmp(str, "Control") || !strcmp(str, "Meta")
|| !strcmp(str, "Super") || !strcmp(str, "Hyper")) {
wireframe_mods = strdup(str);
}
}
/* check_wireframe() timing heuristics. */
if ((str = part[5]) != NULL) {
double t1, t2, t3, t4; double t1, t2, t3, t4;
if (sscanf(str, "%lf+%lf+%lf+%lf", &t1, &t2, &t3, &t4) == 4) { if (sscanf(str, "%lf+%lf+%lf+%lf", &t1, &t2, &t3, &t4) == 4) {
wireframe_t1 = t1; wireframe_t1 = t1;
...@@ -23232,7 +23629,7 @@ void initialize_scroll_keys(void) { ...@@ -23232,7 +23629,7 @@ void initialize_scroll_keys(void) {
nkeys++; /* exclude/include 0 element */ nkeys++; /* exclude/include 0 element */
nkeys++; /* trailing NoSymbol */ nkeys++; /* trailing NoSymbol */
scroll_key_list = (KeySym *)malloc(nkeys*sizeof(KeySym)); scroll_key_list = (KeySym *) malloc(nkeys*sizeof(KeySym));
for (i=0; i<nkeys; i++) { for (i=0; i<nkeys; i++) {
scroll_key_list[i] = NoSymbol; scroll_key_list[i] = NoSymbol;
} }
...@@ -23257,8 +23654,8 @@ void initialize_scroll_keys(void) { ...@@ -23257,8 +23654,8 @@ void initialize_scroll_keys(void) {
} }
} }
} else { } else {
int in; unsigned int in;
if (sscanf(p, "%d", &in) == 1) { if (sscanf(p, "%u", &in) == 1) {
scroll_key_list[i++] = (rfbKeySym) in; scroll_key_list[i++] = (rfbKeySym) in;
} else if (sscanf(p, "0x%x", &in) == 1) { } else if (sscanf(p, "0x%x", &in) == 1) {
scroll_key_list[i++] = (rfbKeySym) in; scroll_key_list[i++] = (rfbKeySym) in;
...@@ -23320,11 +23717,11 @@ void initialize_scroll_matches(void) { ...@@ -23320,11 +23717,11 @@ void initialize_scroll_matches(void) {
if (strstr(s, "MOUSE:") == s) nmouse++; if (strstr(s, "MOUSE:") == s) nmouse++;
} }
if (nkey++) { if (nkey++) {
scroll_good_key = (char **)malloc(nkey*sizeof(char *)); scroll_good_key = (char **) malloc(nkey*sizeof(char *));
for (i=0; i<nkey; i++) scroll_good_key[i] = NULL; for (i=0; i<nkey; i++) scroll_good_key[i] = NULL;
} }
if (nmouse++) { if (nmouse++) {
scroll_good_mouse = (char **)malloc(nmouse*sizeof(char *)); scroll_good_mouse = (char **) malloc(nmouse*sizeof(char *));
for (i=0; i<nmouse; i++) scroll_good_mouse[i] = NULL; for (i=0; i<nmouse; i++) scroll_good_mouse[i] = NULL;
} }
nkey = 0; nkey = 0;
...@@ -23359,11 +23756,11 @@ void initialize_scroll_matches(void) { ...@@ -23359,11 +23756,11 @@ void initialize_scroll_matches(void) {
if (strstr(s, "MOUSE:") == s) nmouse++; if (strstr(s, "MOUSE:") == s) nmouse++;
} }
if (nkey++) { if (nkey++) {
scroll_skip_key = (char **)malloc(nkey*sizeof(char *)); scroll_skip_key = (char **) malloc(nkey*sizeof(char *));
for (i=0; i<nkey; i++) scroll_skip_key[i] = NULL; for (i=0; i<nkey; i++) scroll_skip_key[i] = NULL;
} }
if (nmouse++) { if (nmouse++) {
scroll_skip_mouse = (char **)malloc(nmouse*sizeof(char *)); scroll_skip_mouse = (char **) malloc(nmouse*sizeof(char *));
for (i=0; i<nmouse; i++) scroll_skip_mouse[i] = NULL; for (i=0; i<nmouse; i++) scroll_skip_mouse[i] = NULL;
} }
nkey = 0; nkey = 0;
...@@ -23470,7 +23867,7 @@ void draw_box(int x, int y, int w, int h, int restore) { ...@@ -23470,7 +23867,7 @@ void draw_box(int x, int y, int w, int h, int restore) {
save[i] = (saveline_t *) malloc(sizeof(saveline_t)); save[i] = (saveline_t *) malloc(sizeof(saveline_t));
save[i]->saved = 0; save[i]->saved = 0;
sz = (LW_MAX+1)*len*pixelsize; sz = (LW_MAX+1)*len*pixelsize;
save[i]->data = (char *)malloc(sz); save[i]->data = (char *) malloc(sz);
/* /*
* Four types of lines: * Four types of lines:
...@@ -24012,6 +24409,14 @@ int set_ypad(void) { ...@@ -24012,6 +24409,14 @@ int set_ypad(void) {
return y_accum; return y_accum;
} }
void scale_mark(int x1, int y1, int x2, int y2) {
int s = 2;
x1 = nfix(x1 - s, dpy_x);
y1 = nfix(y1 - s, dpy_y);
x2 = nfix(x2 + s, dpy_x+1);
y2 = nfix(y2 + s, dpy_y+1);
scale_and_mark_rect(x1, y1, x2, y2);
}
#define PUSH_TEST(n) \ #define PUSH_TEST(n) \
if (n) { \ if (n) { \
...@@ -24035,6 +24440,7 @@ int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy, ...@@ -24035,6 +24440,7 @@ int push_scr_ev(double *age, int type, int bdpush, int bdx, int bdy,
sraRegionPtr backfill, whole, tmpregion, tmpregion2; sraRegionPtr backfill, whole, tmpregion, tmpregion2;
int link, latency, netrate; int link, latency, netrate;
int ypad = 0; int ypad = 0;
double last_scroll_event_save = last_scroll_event;
/* we return the oldest one. */ /* we return the oldest one. */
*age = 0.0; *age = 0.0;
...@@ -24334,18 +24740,37 @@ if (db && bdpush) fprintf(stderr, "BDPUSH-TIME: 0x%lx\n", xrecord_wm_window); ...@@ -24334,18 +24740,37 @@ if (db && bdpush) fprintf(stderr, "BDPUSH-TIME: 0x%lx\n", xrecord_wm_window);
if (0) fprintf(stderr, " fb_push dt: %.4f", dt); if (0) fprintf(stderr, " fb_push dt: %.4f", dt);
if (scaling) { if (scaling) {
static double last_time = 0.0; static double last_time = 0.0;
double now = dnow(), delay = 0.35; double now = dnow(), delay = 0.4, first_wait = 3.0;
double trate;
if (now > last_time + delay) { int repeating, lat, rate;
int s = 2; int link = link_rate(&lat, &rate);
int x1 = nfix(x0 - s, dpy_x); int skip_first = 0;
int y1 = nfix(y0 - s, dpy_y);
int x2 = nfix(x0 + w0 + s, dpy_x+1); if (link == LR_DIALUP || rate < 35) {
int y2 = nfix(y0 + h0 + s, dpy_y+1); delay *= 4;
scale_and_mark_rect(x1, y1, x2, y2); } else if (link != LR_LAN || rate < 100) {
last_time = now; delay *= 2;
}
trate = typing_rate(0.0, &repeating);
if (xrecord_set_by_mouse || repeating >= 3) {
if (now > last_scroll_event_save + first_wait) {
skip_first = 1;
}
}
if (skip_first) {
/*
* try not to send the first one, but a
* single keystroke scroll would be OK.
*/
} else if (now > last_time + delay) {
scale_mark(x0, y0, x0 + w0, y0 + h0);
last_copyrect_fix = now; last_copyrect_fix = now;
} }
last_time = now;
} }
} }
...@@ -24523,12 +24948,22 @@ typedef struct scroll_result { ...@@ -24523,12 +24948,22 @@ typedef struct scroll_result {
int result; int result;
} scroll_result_t; } scroll_result_t;
#define SCR_RESULTS_MAX 64 #define SCR_RESULTS_MAX 256
scroll_result_t scroll_results[SCR_RESULTS_MAX]; scroll_result_t scroll_results[SCR_RESULTS_MAX];
int scrollability(Window win, int set) { int scrollability(Window win, int set) {
double oldest = -1.0; double oldest = -1.0;
int i, index = -1, next_index = -1; int i, index = -1, next_index = -1;
static int first = 1;
if (first) {
for (i=0; i<SCR_RESULTS_MAX; i++) {
scroll_results[i].win = None;
scroll_results[i].time = 0.0;
scroll_results[i].result = 0;
}
first = 0;
}
if (win == None) { if (win == None) {
return 0; return 0;
...@@ -24539,6 +24974,9 @@ int scrollability(Window win, int set) { ...@@ -24539,6 +24974,9 @@ int scrollability(Window win, int set) {
if (win == scroll_results[i].win) { if (win == scroll_results[i].win) {
return scroll_results[i].result; return scroll_results[i].result;
} }
if (scroll_results[i].win == None) {
break;
}
} }
return 0; return 0;
} }
...@@ -24552,6 +24990,9 @@ int scrollability(Window win, int set) { ...@@ -24552,6 +24990,9 @@ int scrollability(Window win, int set) {
index = i; index = i;
break; break;
} }
if (next_index >= 0 && scroll_results[i].win == None) {
break;
}
} }
if (set == SCR_SUCCESS) { if (set == SCR_SUCCESS) {
...@@ -24573,10 +25014,11 @@ int scrollability(Window win, int set) { ...@@ -24573,10 +25014,11 @@ int scrollability(Window win, int set) {
*/ */
set = 1; set = 1;
} else { } else {
scroll_results[index].time = dnow();
scroll_results[index].result = set; scroll_results[index].result = set;
} }
scroll_results[index].time = dnow();
} }
return set; return set;
} }
...@@ -24732,7 +25174,13 @@ int check_xrecord_keys(void) { ...@@ -24732,7 +25174,13 @@ int check_xrecord_keys(void) {
return 0; return 0;
} }
#if 0
/* not used for keyboard yet */
scroll_rep = scrollability(xrecord_ptr_window, SCR_NONE) + 1; scroll_rep = scrollability(xrecord_ptr_window, SCR_NONE) + 1;
if (scroll_rep == 1) {
scroll_rep = 2; /* if no info, assume the best. */
}
#endif
scroll_keysym = xrecord_scroll_keysym(last_rfb_keysym); scroll_keysym = xrecord_scroll_keysym(last_rfb_keysym);
...@@ -24742,7 +25190,7 @@ int check_xrecord_keys(void) { ...@@ -24742,7 +25190,7 @@ int check_xrecord_keys(void) {
max_spin = 2 * set_repeat_in; max_spin = 2 * set_repeat_in;
} else if (tnow < last_key_scroll + scroll_persist) { } else if (tnow < last_key_scroll + scroll_persist) {
max_spin = 1.25*(tnow - last_key_scroll); max_spin = 1.25*(tnow - last_key_scroll);
} else if (tnow < last_key_to_button_remap_time + scroll_persist) { } else if (tnow < last_key_to_button_remap_time + 1.5*scroll_persist) {
/* mostly a hack I use for testing -remap key -> btn4/btn5 */ /* mostly a hack I use for testing -remap key -> btn4/btn5 */
max_spin = scroll_persist; max_spin = scroll_persist;
} else if (scroll_keysym) { } else if (scroll_keysym) {
...@@ -24814,9 +25262,11 @@ if (0 || db) fprintf(stderr, "check_xrecord: more keys: %.3f 0x%x " ...@@ -24814,9 +25262,11 @@ if (0 || db) fprintf(stderr, "check_xrecord: more keys: %.3f 0x%x "
flush2 = 1; flush2 = 1;
XFlush(dpy); XFlush(dpy);
} }
#if LIBVNCSERVER_HAVE_RECORD
SCR_LOCK; SCR_LOCK;
XRecordProcessReplies(rdpy_data); XRecordProcessReplies(rdpy_data);
SCR_UNLOCK; SCR_UNLOCK;
#endif
X_UNLOCK; X_UNLOCK;
if (spin >= max_spin * spin_fac) { if (spin >= max_spin * spin_fac) {
...@@ -24958,6 +25408,9 @@ if (0) fprintf(stderr, "check_xrecord_mouse: IN xrecording: %d\n", xrecording); ...@@ -24958,6 +25408,9 @@ if (0) fprintf(stderr, "check_xrecord_mouse: IN xrecording: %d\n", xrecording);
} }
scroll_rep = scrollability(xrecord_ptr_window, SCR_NONE) + 1; scroll_rep = scrollability(xrecord_ptr_window, SCR_NONE) + 1;
if (scroll_rep == 1) {
scroll_rep = 2; /* if no info, assume the best. */
}
if (button_mask_prev) { if (button_mask_prev) {
already_down = 1; already_down = 1;
...@@ -25110,9 +25563,11 @@ if (db) fprintf(stderr, "check_xrecord: BUTTON_UP_SCROLL: %.3f\n", spin); ...@@ -25110,9 +25563,11 @@ if (db) fprintf(stderr, "check_xrecord: BUTTON_UP_SCROLL: %.3f\n", spin);
input++; input++;
} }
X_LOCK; X_LOCK;
#if LIBVNCSERVER_HAVE_RECORD
SCR_LOCK; SCR_LOCK;
XRecordProcessReplies(rdpy_data); XRecordProcessReplies(rdpy_data);
SCR_UNLOCK; SCR_UNLOCK;
#endif
X_UNLOCK; X_UNLOCK;
if (! input) { if (! input) {
...@@ -25250,23 +25705,12 @@ if (db) fprintf(stderr, "FLUSH-2\n"); ...@@ -25250,23 +25705,12 @@ if (db) fprintf(stderr, "FLUSH-2\n");
int check_xrecord(void) { int check_xrecord(void) {
int watch_keys = 0, watch_mouse = 0, consider_mouse; int watch_keys = 0, watch_mouse = 0, consider_mouse;
static int first = 1;
static int mouse_wants_back_in = 0; static int mouse_wants_back_in = 0;
if (first) {
int i;
for (i=0; i<SCR_RESULTS_MAX; i++) {
scroll_results[i].win = None;
scroll_results[i].time = 0.0;
scroll_results[i].result = 0;
}
first = 0;
}
if (! use_xrecord) { if (! use_xrecord) {
return 0; return 0;
} }
if (scaling && ! got_scrollcopyrect) { if (skip_cr_when_scaling("scroll")) {
return 0; return 0;
} }
...@@ -25411,7 +25855,7 @@ if (db2) fprintf(stderr, "moved_win: %4d %3d, %4d %3d 0x%lx ---\n", ...@@ -25411,7 +25855,7 @@ if (db2) fprintf(stderr, "moved_win: %4d %3d, %4d %3d 0x%lx ---\n",
for (k = stack_list_num - 1; k >= 0; k--) { for (k = stack_list_num - 1; k >= 0; k--) {
Window swin; Window swin;
if (dt_bad) { if (0 && dt_bad) {
break; break;
} }
...@@ -25701,6 +26145,53 @@ void check_fixscreen(void) { ...@@ -25701,6 +26145,53 @@ void check_fixscreen(void) {
} }
} }
int wireframe_mod_state() {
if (! wireframe_mods) {
return 0;
}
if (!strcmp(wireframe_mods, "all")) {
return track_mod_state(NoSymbol, FALSE, FALSE);
} else if (!strcmp(wireframe_mods, "Alt")) {
if (track_mod_state(XK_Alt_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Alt_R, FALSE, FALSE) == 1) {
return 1;
}
} else if (!strcmp(wireframe_mods, "Shift")) {
if (track_mod_state(XK_Shift_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Shift_R, FALSE, FALSE) == 1) {
return 1;
}
} else if (!strcmp(wireframe_mods, "Control")) {
if (track_mod_state(XK_Control_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Control_R, FALSE, FALSE) == 1) {
return 1;
}
} else if (!strcmp(wireframe_mods, "Meta")) {
if (track_mod_state(XK_Meta_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Meta_R, FALSE, FALSE) == 1) {
return 1;
}
} else if (!strcmp(wireframe_mods, "Super")) {
if (track_mod_state(XK_Super_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Super_R, FALSE, FALSE) == 1) {
return 1;
}
} else if (!strcmp(wireframe_mods, "Hyper")) {
if (track_mod_state(XK_Hyper_L, FALSE, FALSE) == 1) {
return 1;
} else if (track_mod_state(XK_Hyper_R, FALSE, FALSE) == 1) {
return 1;
}
}
return 0;
}
/* /*
* Applied just before any check_user_input() modes. Look for a * Applied just before any check_user_input() modes. Look for a
* ButtonPress; find window it happened in; find the wm frame window * ButtonPress; find window it happened in; find the wm frame window
...@@ -25748,7 +26239,7 @@ int check_wireframe(void) { ...@@ -25748,7 +26239,7 @@ int check_wireframe(void) {
double frame_changed_spin = wireframe_t2; double frame_changed_spin = wireframe_t2;
double max_spin = wireframe_t3; double max_spin = wireframe_t3;
double min_draw = wireframe_t4; double min_draw = wireframe_t4;
int near_edge; int try_it = 0;
DB_SET DB_SET
if (nofb) { if (nofb) {
...@@ -25795,8 +26286,13 @@ if (db) fprintf(stderr, " frame: x: %d y: %d w: %d h: %d px: %d py: %d fr ...@@ -25795,8 +26286,13 @@ if (db) fprintf(stderr, " frame: x: %d y: %d w: %d h: %d px: %d py: %d fr
* decorations on the edge of the window. * decorations on the edge of the window.
*/ */
near_edge = near_wm_edge(x, y, w, h, px, py); try_it = near_wm_edge(x, y, w, h, px, py);
if (! near_edge) {
/* Often Alt+ButtonDown starts a window move: */
if (! try_it && wireframe_mod_state()) {
try_it = 1;
}
if (! try_it) {
if (db) fprintf(stderr, "INTERIOR\n"); if (db) fprintf(stderr, "INTERIOR\n");
return 0; return 0;
} }
...@@ -26119,7 +26615,7 @@ if (db || db2) fprintf(stderr, "NO button_mask\n"); ...@@ -26119,7 +26615,7 @@ if (db || db2) fprintf(stderr, "NO button_mask\n");
; ;
} else if (win_gone || win_unmapped) { } else if (win_gone || win_unmapped) {
; ;
} else if (scaling && ! got_wirecopyrect) { } else if (skip_cr_when_scaling("wireframe")) {
; ;
} else if (w != orig_w || h != orig_h) { } else if (w != orig_w || h != orig_h) {
; ;
...@@ -26152,19 +26648,18 @@ if (db) fprintf(stderr, "send_copyrect: %d\n", sent_copyrect); ...@@ -26152,19 +26648,18 @@ if (db) fprintf(stderr, "send_copyrect: %d\n", sent_copyrect);
if (! obscured) { if (! obscured) {
fb_push_wait(0.1, FB_COPY); fb_push_wait(0.1, FB_COPY);
} else { } else {
/* no diff for now... */
fb_push_wait(0.1, FB_COPY); fb_push_wait(0.1, FB_COPY);
} }
if (scaling) { if (scaling) {
static double last_time = 0.0; static double last_time = 0.0;
double now = dnow(), delay = 0.35; double now = dnow(), delay = 0.35;
fb_push_wait(0.1, FB_COPY);
if (now > last_time + delay) { if (now > last_time + delay) {
int s = 2;
int x1 = nfix(x - s, dpy_x); scale_mark(x, y, x+w, y+h);
int y1 = nfix(y - s, dpy_y);
int x2 = nfix(x + w + s, dpy_x+1);
int y2 = nfix(y + h + s, dpy_y+1);
scale_and_mark_rect(x1, y1, x2, y2);
last_time = now; last_time = now;
last_copyrect_fix = now; last_copyrect_fix = now;
} }
...@@ -26374,6 +26869,8 @@ static void check_user_input3(double dt, double dtr, int tile_diffs) { ...@@ -26374,6 +26869,8 @@ static void check_user_input3(double dt, double dtr, int tile_diffs) {
int gcnt, ginput; int gcnt, ginput;
static int first = 1; static int first = 1;
if (dtr || tile_diffs) {} /* unused vars warning: */
if (first) { if (first) {
char *p = getenv("SPIN"); char *p = getenv("SPIN");
if (p) { if (p) {
...@@ -26535,6 +27032,8 @@ static void check_user_input4(double dt, double dtr, int tile_diffs) { ...@@ -26535,6 +27032,8 @@ static void check_user_input4(double dt, double dtr, int tile_diffs) {
} }
first = 0; first = 0;
ssec = time(0); ssec = time(0);
if (dtr) {} /* unused vars warning: */
} }
total_calls++; total_calls++;
...@@ -27893,13 +28392,17 @@ static void print_help(int mode) { ...@@ -27893,13 +28392,17 @@ static void print_help(int mode) {
" exactly, e.g. -scale 2/3\n" " exactly, e.g. -scale 2/3\n"
"\n" "\n"
" Scaling Options: can be added after \"fraction\" via\n" " Scaling Options: can be added after \"fraction\" via\n"
" \":\", to supply multiple \":\" options use commas. If\n" " \":\", to supply multiple \":\" options use commas.\n"
" you just want a quick, rough scaling without blending,\n" " If you just want a quick, rough scaling without\n"
" append \":nb\" to \"fraction\" (e.g. -scale 1/3:nb).\n" " blending, append \":nb\" to \"fraction\" (e.g. -scale\n"
" No blending is the default for 8bpp indexed color, to\n" " 1/3:nb). No blending is the default for 8bpp indexed\n"
" force blending for this case use \":fb\". By default\n" " color, to force blending for this case use \":fb\".\n"
" -scrollcopyrect and -wirecopyrect are disabled under\n" "\n"
" -scale, to enable them use \":cr\".\n" " To disable -scrollcopyrect and -wirecopyrect under\n"
" -scale use \":nocr\". If you need to to enable them use\n"
" \":cr\" or specify them explicitly on the command line.\n"
" If a slow link is detected, \":nocr\" may be applied\n"
" automatically. Default: %s\n"
"\n" "\n"
" More esoteric options: for compatibility with vncviewers\n" " More esoteric options: for compatibility with vncviewers\n"
" the scaled width is adjusted to be a multiple of 4:\n" " the scaled width is adjusted to be a multiple of 4:\n"
...@@ -28280,10 +28783,14 @@ static void print_help(int mode) { ...@@ -28280,10 +28783,14 @@ static void print_help(int mode) {
" Keysym). Run 'xmodmap -pk' to see your keymapping.\n" " Keysym). Run 'xmodmap -pk' to see your keymapping.\n"
" Example: \"-skip_keycodes 94,114\"\n" " Example: \"-skip_keycodes 94,114\"\n"
"-skip_dups Some VNC viewers send impossible repeated key events,\n" "-skip_dups Some VNC viewers send impossible repeated key events,\n"
"-noskip_dups e.g. key-down, key-down, key-up, key-up all for the\n" "-noskip_dups e.g. key-down, key-down, key-up, key-up all for the same\n"
" same key, or 20 downs in a row for the same key!\n" " key, or 20 downs in a row for the same modifier key!\n"
" Setting -skip_dups means to skip these duplicates and\n" " Setting -skip_dups means to skip these duplicates and\n"
" just process the first event. Default: %s\n" " just process the first event. Note: some VNC viewers\n"
" assume they can send down's without the corresponding\n"
" up's and so you should not set this option for\n"
" these viewers (symptom: some keys do not autorepeat)\n"
" Default: %s\n"
"-add_keysyms If a Keysym is received from a VNC viewer and\n" "-add_keysyms If a Keysym is received from a VNC viewer and\n"
"-noadd_keysyms that Keysym does not exist in the X server, then\n" "-noadd_keysyms that Keysym does not exist in the X server, then\n"
" add the Keysym to the X server's keyboard mapping.\n" " add the Keysym to the X server's keyboard mapping.\n"
...@@ -28376,6 +28883,12 @@ static void print_help(int mode) { ...@@ -28376,6 +28883,12 @@ static void print_help(int mode) {
"-noprimary Do not poll the PRIMARY selection for changes to send\n" "-noprimary Do not poll the PRIMARY selection for changes to send\n"
" back to clients. (PRIMARY is still set on received\n" " back to clients. (PRIMARY is still set on received\n"
" changes, however).\n" " changes, however).\n"
"-seldir string If direction string is \"send\", only send the selection\n"
" to viewers, and if it is \"recv\" only receive it from\n"
" viewers. To work around apps setting the selection\n"
" too frequently and messing up the other end. You can\n"
" actually supply a comma separated list of directions,\n"
" including \"debug\" to turn on debugging output.\n"
"\n" "\n"
"-cursor [mode] Sets how the pointer cursor shape (little icon at the\n" "-cursor [mode] Sets how the pointer cursor shape (little icon at the\n"
"-nocursor mouse pointer) should be handled. The \"mode\" string\n" "-nocursor mouse pointer) should be handled. The \"mode\" string\n"
...@@ -28537,7 +29050,7 @@ static void print_help(int mode) { ...@@ -28537,7 +29050,7 @@ static void print_help(int mode) {
" The value \"str\" is optional and, of course, is\n" " The value \"str\" is optional and, of course, is\n"
" packed with many tunable parameters for this scheme:\n" " packed with many tunable parameters for this scheme:\n"
"\n" "\n"
" Format: shade,linewidth,percent,T+B+L+R,t1+t2+t3+t4\n" " Format: shade,linewidth,percent,T+B+L+R,mod,t1+t2+t3+t4\n"
" Default: %s\n" " Default: %s\n"
"\n" "\n"
" If you leave nothing between commas: \",,\" the default\n" " If you leave nothing between commas: \",,\" the default\n"
...@@ -28560,6 +29073,14 @@ static void print_help(int mode) { ...@@ -28560,6 +29073,14 @@ static void print_help(int mode) {
" wireframed: set them all to zero to not try the speedup\n" " wireframed: set them all to zero to not try the speedup\n"
" (scrolling and selecting text will likely be slower).\n" " (scrolling and selecting text will likely be slower).\n"
"\n" "\n"
" \"mod\" specifies if a button down event in the\n"
" interior of the window with a modifier key (Alt, Shift,\n"
" etc.) down should indicate a wireframe opportunity.\n"
" It can be \"0\" or \"none\" to skip it, \"1\" or \"all\"\n"
" to apply it to any modifier, or \"Shift\", \"Alt\",\n"
" \"Control\", \"Meta\", \"Super\", or \"Hyper\" to only\n"
" apply for that type of modifier key.\n"
"\n"
" \"t1+t2+t3+t4\" specify four floating point times in\n" " \"t1+t2+t3+t4\" specify four floating point times in\n"
" seconds: t1 is how long to wait for the pointer to move,\n" " seconds: t1 is how long to wait for the pointer to move,\n"
" t2 is how long to wait for the window to start moving\n" " t2 is how long to wait for the window to start moving\n"
...@@ -28585,10 +29106,11 @@ static void print_help(int mode) { ...@@ -28585,10 +29106,11 @@ static void print_help(int mode) {
" region (this may look odd as the remaining pieces come\n" " region (this may look odd as the remaining pieces come\n"
" in, but helps on a slow link). Default: \"%s\"\n" " in, but helps on a slow link). Default: \"%s\"\n"
"\n" "\n"
" Note: there can be painting errors when using -scale\n" " Note: there can be painting errors or slow response\n"
" so CopyRect is skipped when scaling unless you specify\n" " when using -scale so you may want to disable CopyRect\n"
" \"-wirecopyrect always\" on the command line or by\n" " in this case \"-wirecopyrect never\" on the command\n"
" remote-control. Or you can also use \"-scale xxx:cr\"\n" " line or by remote-control. Or you can also use the\n"
" \"-scale xxx:nocr\" scale option.\n"
"\n" "\n"
"-debug_wireframe Turn on debugging info printout for the wireframe\n" "-debug_wireframe Turn on debugging info printout for the wireframe\n"
" heuristics. \"-dwf\" is an alias. Specify multiple\n" " heuristics. \"-dwf\" is an alias. Specify multiple\n"
...@@ -28630,16 +29152,24 @@ static void print_help(int mode) { ...@@ -28630,16 +29152,24 @@ static void print_help(int mode) {
" 4 Super_L's in a row: reset RECORD context,\n" " 4 Super_L's in a row: reset RECORD context,\n"
" 5 Super_L's in a row: try to push a black screen\n" " 5 Super_L's in a row: try to push a black screen\n"
"\n" "\n"
" note: Alt_L is the Left \"Alt\" key (a single key)\n"
" Super_L is the Left \"Super\" key (Windows flag).\n"
" Both of these are modifier keys, and so should not\n"
" generate characters when pressed by themselves. Also,\n"
" your VNC viewer may have its own refresh hot-key\n"
" or button.\n"
"\n"
" \"mode\" can be \"never\" (same as -noscrollcopyrect)\n" " \"mode\" can be \"never\" (same as -noscrollcopyrect)\n"
" to never try the copyrect, \"keys\" means to try it\n" " to never try the copyrect, \"keys\" means to try it\n"
" in response to keystrokes only, \"mouse\" means to\n" " in response to keystrokes only, \"mouse\" means to\n"
" try it in response to mouse events only, \"always\"\n" " try it in response to mouse events only, \"always\"\n"
" means to do both. Default: \"%s\"\n" " means to do both. Default: \"%s\"\n"
"\n" "\n"
" Note: there can be painting errors when using -scale\n" " Note: there can be painting errors or slow response\n"
" so CopyRect is skipped when scaling unless you specify\n" " when using -scale so you may want to disable CopyRect\n"
" \"-scrollcopyrect always\" on the command line or by\n" " in this case \"-scrollcopyrect never\" on the command\n"
" remote-control. You can also use \"-scale xxx:cr\"\n" " line or by remote-control. Or you can also use the\n"
" \"-scale xxx:nocr\" scale option.\n"
"\n" "\n"
"-scr_area n Set the minimum area in pixels for a rectangle\n" "-scr_area n Set the minimum area in pixels for a rectangle\n"
" to be considered for the -scrollcopyrect detection\n" " to be considered for the -scrollcopyrect detection\n"
...@@ -28785,22 +29315,22 @@ static void print_help(int mode) { ...@@ -28785,22 +29315,22 @@ static void print_help(int mode) {
" but it can be used for any scenario. This option\n" " but it can be used for any scenario. This option\n"
" periodically performs costly operations and so\n" " periodically performs costly operations and so\n"
" interactive response may be reduced when it is on.\n" " interactive response may be reduced when it is on.\n"
" The 3 Alt_L's in a row described under -scrollcopyrect\n" " The 3 Alt_L's (the Left \"Alt\" key) taps in a row\n"
" can be used instead to manually request a screen repaint\n" " described under -scrollcopyrect can be used instead to\n"
" when it is needed.\n" " manually request a screen repaint when it is needed.\n"
"\n" "\n"
" \"string\" is a comma separated list of one or more\n" " \"string\" is a comma separated list of one or more of\n"
" of the following: \"V=t\", \"C=t\", and \"X=t\".\n" " the following: \"V=t\", \"C=t\", and \"X=t\". In these\n"
" In these \"t\" stands for a time in seconds (it is\n" " \"t\" stands for a time in seconds (it is a floating\n"
" a floating point even though one should usually use\n" " point even though one should usually use values > 2 to\n"
" values > 2 to avoid wasting resources). V sets how\n" " avoid wasting resources). V sets how frequently the\n"
" frequently the entire screen should be sent to viewers\n" " entire screen should be sent to viewers (it is like the\n"
" (it is like the 3 Alt_L's). C sets how long after a\n" " 3 Alt_L's). C sets how long to wait after a CopyRect\n"
" CopyRect the full screen should be repainted. X sets\n" " to repaint the full screen. X sets how frequently\n"
" how frequently to reread the full X11 framebuffer from\n" " to reread the full X11 framebuffer from the X server\n"
" the X server and push it out to connected viewers.\n" " and push it out to connected viewers. Use of X should\n"
" Use of X should be rare. Examples: -fixscreen V=10\n" " be rare, please report a bug if you find you need it.\n"
" -fixscreen C=10\n" " Examples: -fixscreen V=10 -fixscreen C=10\n"
"\n" "\n"
"-debug_scroll Turn on debugging info printout for the scroll\n" "-debug_scroll Turn on debugging info printout for the scroll\n"
" heuristics. \"-ds\" is an alias. Specify it multiple\n" " heuristics. \"-ds\" is an alias. Specify it multiple\n"
...@@ -29258,6 +29788,7 @@ static void print_help(int mode) { ...@@ -29258,6 +29788,7 @@ static void print_help(int mode) {
" sel disable -nosel mode.\n" " sel disable -nosel mode.\n"
" noprimary enable -noprimary mode.\n" " noprimary enable -noprimary mode.\n"
" primary disable -noprimary mode.\n" " primary disable -noprimary mode.\n"
" seldir:str set -seldir to \"str\"\n"
" cursor:mode enable -cursor \"mode\".\n" " cursor:mode enable -cursor \"mode\".\n"
" show_cursor enable showing a cursor.\n" " show_cursor enable showing a cursor.\n"
" noshow_cursor disable showing a cursor. (same as\n" " noshow_cursor disable showing a cursor. (same as\n"
...@@ -29297,6 +29828,7 @@ static void print_help(int mode) { ...@@ -29297,6 +29828,7 @@ static void print_help(int mode) {
" fixscreen:str set -fixscreen to \"str\".\n" " fixscreen:str set -fixscreen to \"str\".\n"
" noxrecord disable all use of RECORD extension.\n" " noxrecord disable all use of RECORD extension.\n"
" xrecord enable use of RECORD extension.\n" " xrecord enable use of RECORD extension.\n"
" reset_record reset RECORD extension (if avail.).\n"
" pointer_mode:n set -pointer_mode to n. same as \"pm\"\n" " pointer_mode:n set -pointer_mode to n. same as \"pm\"\n"
" input_skip:n set -input_skip to n.\n" " input_skip:n set -input_skip to n.\n"
" speeds:str set -speeds to str.\n" " speeds:str set -speeds to str.\n"
...@@ -29386,14 +29918,6 @@ static void print_help(int mode) { ...@@ -29386,14 +29918,6 @@ static void print_help(int mode) {
" a query straight to the VNC_CONNECT property or connect\n" " a query straight to the VNC_CONNECT property or connect\n"
" file use \"qry=...\" instead of \"cmd=...\"\n" " file use \"qry=...\" instead of \"cmd=...\"\n"
"\n" "\n"
" Here is the current list of \"variables\" that can\n"
" be supplied to the -query command. This includes the\n"
" \"N/A\" ones that return no useful info. For variables\n"
" names that do not correspond to an x11vnc option or\n"
" remote command, we hope the name makes it obvious what\n"
" the returned value corresponds to (hint: the ext_*\n"
" variables correspond to the presence of X extensions):\n"
"\n"
" ans= stop quit exit shutdown ping blacken zero\n" " ans= stop quit exit shutdown ping blacken zero\n"
" refresh reset close disconnect id sid waitmapped\n" " refresh reset close disconnect id sid waitmapped\n"
" nowaitmapped clip flashcmap noflashcmap shiftcmap\n" " nowaitmapped clip flashcmap noflashcmap shiftcmap\n"
...@@ -29410,23 +29934,23 @@ static void print_help(int mode) { ...@@ -29410,23 +29934,23 @@ static void print_help(int mode) {
" modtweak nomodtweak xkb noxkb skip_keycodes skip_dups\n" " modtweak nomodtweak xkb noxkb skip_keycodes skip_dups\n"
" noskip_dups add_keysyms noadd_keysyms clear_mods\n" " noskip_dups add_keysyms noadd_keysyms clear_mods\n"
" noclear_mods clear_keys noclear_keys remap repeat\n" " noclear_mods clear_keys noclear_keys remap repeat\n"
" norepeat fb nofb bell nobell sel nosel primary noprimary\n" " norepeat fb nofb bell nobell sel nosel primary\n"
" cursorshape nocursorshape cursorpos nocursorpos cursor\n" " noprimary seldir cursorshape nocursorshape cursorpos\n"
" show_cursor noshow_cursor nocursor arrow xfixes\n" " nocursorpos cursor show_cursor noshow_cursor nocursor\n"
" noxfixes xdamage noxdamage xd_area xd_mem alphacut\n" " arrow xfixes noxfixes xdamage noxdamage xd_area xd_mem\n"
" alphafrac alpharemove noalpharemove alphablend\n" " alphacut alphafrac alpharemove noalpharemove alphablend\n"
" noalphablend xwarppointer xwarp noxwarppointer\n" " noalphablend xwarppointer xwarp noxwarppointer noxwarp\n"
" noxwarp buttonmap dragging nodragging wireframe_mode\n" " buttonmap dragging nodragging wireframe_mode wireframe\n"
" wireframe wf nowireframe nowf wirecopyrect wcr\n" " wf nowireframe nowf wirecopyrect wcr nowirecopyrect\n"
" nowirecopyrect nowcr scr_area scr_skip scr_inc scr_keys\n" " nowcr scr_area scr_skip scr_inc scr_keys scr_term\n"
" scr_term scr_keyrepeat scr_parms scrollcopyrect scr\n" " scr_keyrepeat scr_parms scrollcopyrect scr\n"
" noscrollcopyrect noscr fixscreen noxrecord xrecord\n" " noscrollcopyrect noscr fixscreen noxrecord xrecord\n"
" pointer_mode pm input_skip input client_input speeds\n" " reset_record pointer_mode pm input_skip input\n"
" debug_pointer dp nodebug_pointer nodp debug_keyboard\n" " client_input speeds debug_pointer dp nodebug_pointer\n"
" dk nodebug_keyboard nodk deferupdate defer wait_ui\n" " nodp debug_keyboard dk nodebug_keyboard nodk deferupdate\n"
" wait_bog nowait_bog wait readtimeout nap nonap sb\n" " defer wait_ui wait_bog nowait_bog wait readtimeout\n"
" screen_blank fs gaps grow fuzz snapfb nosnapfb\n" " nap nonap sb screen_blank fs gaps grow fuzz snapfb\n"
" rawfb progressive rfbport http nohttp httpport\n" " nosnapfb rawfb progressive rfbport http nohttp httpport\n"
" httpdir enablehttpproxy noenablehttpproxy alwaysshared\n" " httpdir enablehttpproxy noenablehttpproxy alwaysshared\n"
" noalwaysshared nevershared noalwaysshared dontdisconnect\n" " noalwaysshared nevershared noalwaysshared dontdisconnect\n"
" nodontdisconnect desktop debug_xevents nodebug_xevents\n" " nodontdisconnect desktop debug_xevents nodebug_xevents\n"
...@@ -29436,19 +29960,19 @@ static void print_help(int mode) { ...@@ -29436,19 +29960,19 @@ static void print_help(int mode) {
" debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg\n" " debug_tiles dbt nodebug_tiles nodbt debug_tiles dbg\n"
" nodbg noremote\n" " nodbg noremote\n"
"\n" "\n"
" aro= display vncdisplay desktopname http_url auth\n" " aro= display vncdisplay desktopname guess_desktop\n"
" users rootshift clipshift scale_str scaled_x scaled_y\n" " http_url auth users rootshift clipshift scale_str\n"
" scale_numer scale_denom scale_fac scaling_blend\n" " scaled_x scaled_y scale_numer scale_denom\n"
" scaling_nomult4 scaling_pad scaling_interpolate inetd\n" " scale_fac scaling_blend scaling_nomult4 scaling_pad\n"
" privremote unsafe safer nocmds passwdfile using_shm\n" " scaling_interpolate inetd privremote unsafe safer nocmds\n"
" logfile o flag rc norc h help V version lastmod bg\n" " passwdfile using_shm logfile o flag rc norc h help V\n"
" sigpipe threads readrate netrate netlatency pipeinput\n" " version lastmod bg sigpipe threads readrate netrate\n"
" clients client_count pid ext_xtest ext_xtrap ext_xrecord\n" " netlatency pipeinput clients client_count pid ext_xtest\n"
" ext_xkb ext_xshm ext_xinerama ext_overlay ext_xfixes\n" " ext_xtrap ext_xrecord ext_xkb ext_xshm ext_xinerama\n"
" ext_xdamage ext_xrandr rootwin num_buttons button_mask\n" " ext_overlay ext_xfixes ext_xdamage ext_xrandr rootwin\n"
" mouse_x mouse_y bpp depth indexed_color dpy_x dpy_y\n" " num_buttons button_mask mouse_x mouse_y bpp depth\n"
" wdpy_x wdpy_y off_x off_y cdpy_x cdpy_y coff_x coff_y\n" " indexed_color dpy_x dpy_y wdpy_x wdpy_y off_x off_y\n"
" rfbauth passwd\n" " cdpy_x cdpy_y coff_x coff_y rfbauth passwd\n"
"\n" "\n"
"-sync By default -remote commands are run asynchronously, that\n" "-sync By default -remote commands are run asynchronously, that\n"
" is, the request is posted and the program immediately\n" " is, the request is posted and the program immediately\n"
...@@ -29544,6 +30068,7 @@ static void print_help(int mode) { ...@@ -29544,6 +30068,7 @@ static void print_help(int mode) {
exit(1); exit(1);
} }
fprintf(stderr, help, lastmod, fprintf(stderr, help, lastmod,
scaling_copyrect ? ":cr":":nocr",
view_only ? "on":"off", view_only ? "on":"off",
shared ? "on":"off", shared ? "on":"off",
vnc_connect ? "-vncconnect":"-novncconnect", vnc_connect ? "-vncconnect":"-novncconnect",
...@@ -29978,7 +30503,7 @@ int main(int argc, char* argv[]) { ...@@ -29978,7 +30503,7 @@ int main(int argc, char* argv[]) {
for (i=1; i < argc; i++) { for (i=1; i < argc; i++) {
len += strlen(argv[i]) + 4 + 1; len += strlen(argv[i]) + 4 + 1;
} }
program_cmdline = (char *)malloc(len+1); program_cmdline = (char *) malloc(len+1);
program_cmdline[0] = '\0'; program_cmdline[0] = '\0';
for (i=1; i < argc; i++) { for (i=1; i < argc; i++) {
char *s = argv[i]; char *s = argv[i];
...@@ -30031,11 +30556,12 @@ int main(int argc, char* argv[]) { ...@@ -30031,11 +30556,12 @@ int main(int argc, char* argv[]) {
arg); arg);
exit(1); exit(1);
} else if (! pick_windowid(&subwin)) { } else if (! pick_windowid(&subwin)) {
fprintf(stderr, "bad %s pick\n", arg); fprintf(stderr, "invalid %s pick\n",
arg);
exit(1); exit(1);
} }
} else if (! scan_hexdec(argv[i], &subwin)) { } else if (! scan_hexdec(argv[i], &subwin)) {
fprintf(stderr, "bad %s arg: %s\n", arg, fprintf(stderr, "invalid %s arg: %s\n", arg,
argv[i]); argv[i]);
exit(1); exit(1);
} }
...@@ -30260,6 +30786,9 @@ int main(int argc, char* argv[]) { ...@@ -30260,6 +30786,9 @@ int main(int argc, char* argv[]) {
watch_primary = 0; watch_primary = 0;
} else if (!strcmp(arg, "-noprimary")) { } else if (!strcmp(arg, "-noprimary")) {
watch_primary = 0; watch_primary = 0;
} else if (!strcmp(arg, "-seldir")) {
CHECK_ARGC
sel_direction = strdup(argv[++i]);
} else if (!strcmp(arg, "-cursor")) { } else if (!strcmp(arg, "-cursor")) {
show_cursor = 1; show_cursor = 1;
if (i < argc-1) { if (i < argc-1) {
...@@ -30445,8 +30974,8 @@ int main(int argc, char* argv[]) { ...@@ -30445,8 +30974,8 @@ int main(int argc, char* argv[]) {
if (known_sigpipe_mode(argv[++i])) { if (known_sigpipe_mode(argv[++i])) {
sigpipe = strdup(argv[i]); sigpipe = strdup(argv[i]);
} else { } else {
fprintf(stderr, "bad -sigpipe arg: %s, must " fprintf(stderr, "invalid -sigpipe arg: %s, must"
"be \"ignore\" or \"exit\"\n", argv[i]); " be \"ignore\" or \"exit\"\n", argv[i]);
exit(1); exit(1);
} }
#if LIBVNCSERVER_HAVE_LIBPTHREAD #if LIBVNCSERVER_HAVE_LIBPTHREAD
...@@ -30925,6 +31454,8 @@ int main(int argc, char* argv[]) { ...@@ -30925,6 +31454,8 @@ int main(int argc, char* argv[]) {
fprintf(stderr, " watchbell: %d\n", watch_bell); fprintf(stderr, " watchbell: %d\n", watch_bell);
fprintf(stderr, " watchsel: %d\n", watch_selection); fprintf(stderr, " watchsel: %d\n", watch_selection);
fprintf(stderr, " watchprim: %d\n", watch_primary); fprintf(stderr, " watchprim: %d\n", watch_primary);
fprintf(stderr, " seldir: %s\n", sel_direction ?
sel_direction : "null");
fprintf(stderr, " cursor: %d\n", show_cursor); fprintf(stderr, " cursor: %d\n", show_cursor);
fprintf(stderr, " multicurs: %d\n", show_multiple_cursors); fprintf(stderr, " multicurs: %d\n", show_multiple_cursors);
fprintf(stderr, " curs_mode: %s\n", multiple_cursors_mode fprintf(stderr, " curs_mode: %s\n", multiple_cursors_mode
...@@ -31150,33 +31681,26 @@ int main(int argc, char* argv[]) { ...@@ -31150,33 +31681,26 @@ int main(int argc, char* argv[]) {
} }
if (! quiet && wireframe) { if (! quiet && wireframe) {
rfbLog("Wireframing: -wireframe mode is in effect for window moves.\n"); rfbLog("Wireframing: -wireframe mode is in effect for window "
rfbLog(" If this yields undesired behavior (poor response, painting\n"); "moves.\n");
rfbLog(" If this yields undesired behavior (poor response, "
"painting\n");
rfbLog(" errors, etc) it may be disabled:\n"); rfbLog(" errors, etc) it may be disabled:\n");
rfbLog(" - use '-nowf' to disable wireframing completely.\n"); rfbLog(" - use '-nowf' to disable wireframing completely.\n");
rfbLog(" - use '-nowcr' to disable the Copy Rectangle after the\n"); rfbLog(" - use '-nowcr' to disable the Copy Rectangle after "
"the\n");
rfbLog(" moved window is released in the new position.\n"); rfbLog(" moved window is released in the new position.\n");
rfbLog(" Also see the -help entry for tuning parameters.\n"); rfbLog(" Also see the -help entry for tuning parameters.\n");
} rfbLog(" You can press 3 Alt_L's (Left \"Alt\" key) in a row"
" to \n");
tmpi = 1; rfbLog(" repaint the screen, also see the -fixscreen option"
if (scroll_copyrect) { " for\n");
if (strstr(scroll_copyrect, "never")) { rfbLog(" periodic repaints.\n");
tmpi = 0; if (scale_str && !strstr(scale_str, "nocr")) {
} rfbLog(" Note: '-scale' is on and this can cause "
} else if (scroll_copyrect_default) { "more problems.\n");
if (strstr(scroll_copyrect_default, "never")) {
tmpi = 0;
} }
} }
if (! quiet && tmpi) {
rfbLog("Scroll Detection: -scrollcopyrect mode is in effect to\n");
rfbLog(" use RECORD extension to try to detect scrolling windows\n");
rfbLog(" (induced by either user keystroke or mouse input).\n");
rfbLog(" If this yields undesired behavior (poor response, painting\n");
rfbLog(" errors, etc) it may be disabled via: '-noscr'\n");
rfbLog(" Also see the -help entry for tuning parameters.\n");
}
overlay_present = 0; overlay_present = 0;
#ifdef SOLARIS_OVERLAY #ifdef SOLARIS_OVERLAY
...@@ -31315,6 +31839,43 @@ int main(int argc, char* argv[]) { ...@@ -31315,6 +31839,43 @@ int main(int argc, char* argv[]) {
initialize_xrecord(); initialize_xrecord();
tmpi = 1;
if (scroll_copyrect) {
if (strstr(scroll_copyrect, "never")) {
tmpi = 0;
}
} else if (scroll_copyrect_default) {
if (strstr(scroll_copyrect_default, "never")) {
tmpi = 0;
}
}
if (! xrecord_present) {
tmpi = 0;
}
#if !LIBVNCSERVER_HAVE_RECORD
tmpi = 0;
#endif
if (! quiet && tmpi) {
rfbLog("Scroll Detection: -scrollcopyrect mode is in effect "
"to\n");
rfbLog(" use RECORD extension to try to detect scrolling "
"windows\n");
rfbLog(" (induced by either user keystroke or mouse input).\n");
rfbLog(" If this yields undesired behavior (poor response, "
"painting\n");
rfbLog(" errors, etc) it may be disabled via: '-noscr'\n");
rfbLog(" Also see the -help entry for tuning parameters.\n");
rfbLog(" You can press 3 Alt_L's (Left \"Alt\" key) in a row"
" to \n");
rfbLog(" repaint the screen, also see the -fixscreen option"
" for\n");
rfbLog(" periodic repaints.\n");
if (scale_str && !strstr(scale_str, "nocr")) {
rfbLog(" Note: '-scale' is on and this can cause "
"more problems.\n");
}
}
/* check for OS with small shm limits */ /* check for OS with small shm limits */
if (using_shm && ! single_copytile) { if (using_shm && ! single_copytile) {
if (limit_shm()) { if (limit_shm()) {
...@@ -31436,6 +31997,7 @@ int main(int argc, char* argv[]) { ...@@ -31436,6 +31997,7 @@ int main(int argc, char* argv[]) {
if (! inetd) { if (! inetd) {
if (! screen->port || screen->listenSock < 0) { if (! screen->port || screen->listenSock < 0) {
rfbLogEnable(1);
rfbLog("Error: could not obtain listening port.\n"); rfbLog("Error: could not obtain listening port.\n");
clean_up_exit(1); clean_up_exit(1);
} }
...@@ -31452,11 +32014,13 @@ int main(int argc, char* argv[]) { ...@@ -31452,11 +32014,13 @@ int main(int argc, char* argv[]) {
if ((p = fork()) > 0) { if ((p = fork()) > 0) {
exit(0); exit(0);
} else if (p == -1) { } else if (p == -1) {
rfbLogEnable(1);
fprintf(stderr, "could not fork\n"); fprintf(stderr, "could not fork\n");
perror("fork"); perror("fork");
clean_up_exit(1); clean_up_exit(1);
} }
if (setsid() == -1) { if (setsid() == -1) {
rfbLogEnable(1);
fprintf(stderr, "setsid failed\n"); fprintf(stderr, "setsid failed\n");
perror("setsid"); perror("setsid");
clean_up_exit(1); clean_up_exit(1);
......
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