From d77d118d99da0ce0b99f67a9d5a0050a6456a358 Mon Sep 17 00:00:00 2001 From: runge Date: Sun, 15 Aug 2004 19:59:01 +0000 Subject: [PATCH] x11vnc: -overlay to fix colors with Sun 8+24 overlay visuals. -sid option. --- ChangeLog | 4 + x11vnc/ChangeLog | 9 + x11vnc/README | 674 +++++++++++++++++++++++++++-------------------- x11vnc/x11vnc.1 | 37 ++- x11vnc/x11vnc.c | 349 +++++++++++++++++++----- 5 files changed, 716 insertions(+), 357 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51953ec..461bf74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-08-15 Karl Runge + * x11vnc: -overlay to fix colors with Sun 8+24 overlay visuals. + * -sid option. + 2004-08-03 Karl Runge * x11vnc: manpage and README * fix XKBlib.h detection on *BSD diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index 4a34668..8789a40 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,12 @@ +2004-08-15 Karl Runge + * -overlay option to fix color problems on Sun machines with 8+24 + and 24+8 overlay visuals, uses Solaris XReadScreen(). + * expose -sid option (shifted -id windowid) to allow explicit + wrapping of XGetImage, etc for -overlay + * fix misc bugs: missing var types, hardwired blackouts sizes, + subwin desktop name crash. + + 2004-08-03 Karl Runge * add man page x11vnc.1 autogenerated from x11vnc -help; tweak help output a little bit. Adjust autoconf to pick up manpage. diff --git a/x11vnc/README b/x11vnc/README index 1f58f24..c64985d 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Tue Aug 3 21:54:01 EDT 2004 +x11vnc README file Date: Sun Aug 15 16:30:33 EDT 2004 The following information is taken from these URLs: @@ -301,12 +301,29 @@ vncviewer -via $host localhost:0 # must be TightVNC vncviewer. You can now run it via typing "x11vnc", "x11vnc -help", "x11vnc -nap -display :0", etc. + Note: Currently gcc is required to build libvncserver. In some cases + it will build with non-gcc compilers, but the resulting binary often + fails to run properly. + Building on Solaris: Depending on your version of Solaris (or other Unix OS), the jpeg and/or zlib libraries may be in non-standard places - (e.g. /usr/local). Note: if configure cannot find these two libraries - then TightVNC support will be disabled, and you don't want that! Here - is a build script that indicates one way to pass this information to - the libvncserver configuration: + (e.g. /usr/local, /usr/sfw, /opt/sfw, etc). + + Note: If configure cannot find these two libraries then TightVNC + support will be disabled, and you don't want that! (the TightVNC + encoding gives very good compression and performance, even makes a + difference over a LAN) + + libjpeg is included in Solaris 9 and later (/usr/sfw/include and + /usr/sfw/lib), and zlib in Solaris 8 and later (/usr/include and + /usr/lib). To get the source for these libraries: libjpeg is available + at [19]ftp://ftp.uu.net/graphics/jpeg/ and zlib at + [20]http://www.gzip.org/zlib/. See also + [21]http://www.sunfreeware.com/ for Solaris binary packages of these + libraries. + + Here is a build script that indicates one way to pass the library + locations information to the libvncserver configuration: #!/bin/sh # Build script for Solaris, etc, with, gcc, libjpeg and libz in @@ -356,8 +373,8 @@ ls -l ./x11vnc/x11vnc referring to LIBVNCSERVER_HAVE_XKEYBOARD in rfb/rfbconfig.h after configure has been run. Alternatively, one could put #undef LIBVNCSERVER_HAVE_XKEYBOARD after the rfb/rfb.h include in the - x11vnc/x11vnc.c file. We are working to fix this in the configure - script. + x11vnc/x11vnc.c file. (This problem has been fixed as of x11vnc 0.6.2 + (Aug/2004)) _________________________________________________________________ Some Notes: @@ -370,7 +387,7 @@ ls -l ./x11vnc/x11vnc suggest using xsetroot, dtstyle or similar utility to set a solid background while using x11vnc. - I also find the [19]tightvnc encoding gives the best response for my + I also find the [22]tightvnc encoding gives the best response for my usage (Unix <-> Unix over cable modem). One needs a tightvnc-aware vncviewer to take advantage of this encoding. @@ -386,10 +403,10 @@ ls -l ./x11vnc/x11vnc option. Options: x11vnc has (far too) many features that may be activated - via its [20]command line options. Useful options are -nap to use fewer + via its [23]command line options. Useful options are -nap to use fewer resources (it sleeps more between polls when activity is low) and -rfbauth passwd-file to use VNC password protection (the vncpasswd or - storepasswd programs, or the x11vnc [21]-storepasswd option can be + storepasswd programs, or the x11vnc [24]-storepasswd option can be used to create the password file). Algorithm: How does x11vnc do it? Rather brute-forcedly: it @@ -419,7 +436,7 @@ ls -l ./x11vnc/x11vnc display the viewer on a different machine! SunRay notes: You can run x11vnc on your (connected or disconnected) - [22]SunRay session (Please remember to use -nap and maybe -wait 200 to + [25]SunRay session (Please remember to use -nap and maybe -wait 200 to avoid being a resource hog! It also helps a bit to have a solid background color). You have to know the name of the machine your SunRay session X server is running on. You also need to know the X11 @@ -476,7 +493,9 @@ ls -l ./x11vnc/x11vnc * Somewhat surprisingly, the X11 mouse (cursor) shape is write-only and cannot be queried from the X server. So in x11vnc the cursor shape stays fixed at an arrow. (see the -mouseX option, however, - for a partial hack for the root window). + for a partial hack for the root window). Also, on Solaris using + the SUN_OVL overlay extension, x11vnc can show the correct mouse + cursor when the -overlay is also supplied. * Audio from applications is of course not redirected (separate redirectors do exist, e.g. esd). The XBell() "beeps" will work if the X server supports the XKEYBOARD extension. (Note that on @@ -486,190 +505,191 @@ ls -l ./x11vnc/x11vnc Evidently a timing related bug and difficult to reproduce... * Using -threads can expose some bugs in libvncserver. - Please feel free to [23]contact me if you have any questions, + Please feel free to [26]contact me if you have any questions, problems, or comments about x11vnc, etc. _________________________________________________________________ x11vnc FAQ: - [24]Q-1: I can't get x11vnc to start up. It says "XOpenDisplay failed + [27]Q-1: I can't get x11vnc to start up. It says "XOpenDisplay failed ((null))" or "Xlib: connection to ":0.0" refused by server". What do I need to do? - [25]Q-2: I can't get x11vnc and/or libvncserver to compile. + [28]Q-2: I can't get x11vnc and/or libvncserver to compile. - [26]Q-3: Where can I get a precompiled x11vnc binary for my Operating + [29]Q-3: Where can I get a precompiled x11vnc binary for my Operating System? - [27]Q-4: How can I see all of x11vnc's command line options and + [30]Q-4: How can I see all of x11vnc's command line options and documentation on how to use them? - [28]Q-5: I don't like typing arcane command line options every time I + [31]Q-5: I don't like typing arcane command line options every time I start x11vnc. What can I do? Is there a config file? - [29]Q-6: Why does x11vnc exit as soon as the VNC viewer disconnects? + [32]Q-6: Why does x11vnc exit as soon as the VNC viewer disconnects? And why doesn't it allow more than one VNC viewer to connect at the same time? - [30]Q-7: I have two separate machine displays in front of me, one + [33]Q-7: I have two separate machine displays in front of me, one Windows the other X11: can I use x11vnc in combination with Win2VNC in dual-screen mode to pass the keystrokes and mouse motions to the X11 display? - [31]Q-8: I am running Win2VNC on my windows machine and trying to + [34]Q-8: I am running Win2VNC on my windows machine and trying to create a dual-screen mode with my second display by running x11vnc -nofb. Whenever I initiate the connection Win2VNC quickly disconnects and x11vnc says something like: rfbProcessClientNormalMessage: read: Connection reset by peer - [32]Q-9: The X display I run x11vnc on is only 8bpp PseudoColor (only - 256 distinct colors). x11vnc starts out OK, but after a while the - colors are incorrect in certain windows. + [35]Q-9: The X display I run x11vnc on is only 8 bits per pixel (bpp) + PseudoColor (i.e. only 256 distinct colors). The x11vnc colors may + start out OK, but after a while the colors are incorrect in certain + windows. - [33]Q-10: Color problems: I have an X display that has nice - "overlay-like" visuals of multiple color depths. E.g. there are both - depth 8 and 24 visuals available. Why are some of the colors messed up - in x11vnc? + [36]Q-10: Color problems: Why are the colors for some of the windows + messed up in x11vnc? BTW, I have an X display that has nice overlay + visuals of multiple color depths. E.g. there are both depth 8 and 24 + visuals available at the same time. - [34]Q-11: How do I figure out the window id to supply to the -id + [37]Q-11: How do I figure out the window id to supply to the -id windowid option? - [35]Q-12: Why don't menus or other transient windows come up when I am + [38]Q-12: Why don't menus or other transient windows come up when I am using the -id windowid option to view a single application window? - [36]Q-13: Can I use x11vnc to view and interact with an Xterminal + [39]Q-13: Can I use x11vnc to view and interact with an Xterminal (e.g. NCD) that is not running UNIX and so x11vnc cannot be run on it directly? - [37]Q-14: Can I make x11vnc more quiet and also go into the background + [40]Q-14: Can I make x11vnc more quiet and also go into the background after starting up? - [38]Q-15: Can I limit which machines incoming VNC clients can connect + [41]Q-15: Can I limit which machines incoming VNC clients can connect from? - [39]Q-16: How do I build x11vnc/libvncserver with libwrap + [42]Q-16: How do I build x11vnc/libvncserver with libwrap (tcp_wrappers) support? - [40]Q-17: Can I prompt the user at the local X display whether the + [43]Q-17: Can I prompt the user at the local X display whether the incoming VNC client should be accepted or not? Can I decide to make some clients view-only? How about running an arbitrary program to make the decisions? - [41]Q-18: How do I create a VNC password for use with x11vnc? + [44]Q-18: How do I create a VNC password for use with x11vnc? - [42]Q-19: How can I tunnel my connection to x11vnc via an encrypted + [45]Q-19: How can I tunnel my connection to x11vnc via an encrypted SSH channel between two Unix machines? - [43]Q-20: How can I tunnel my connection to x11vnc via an encrypted + [46]Q-20: How can I tunnel my connection to x11vnc via an encrypted SSH channel from Windows using an SSH client like Putty? - [44]Q-21: Does x11vnc support Unix usernames and passwords? Can I + [47]Q-21: Does x11vnc support Unix usernames and passwords? Can I further limit the set of Unix usernames who can connect to the VNC desktop? - [45]Q-22: Can I have two passwords for VNC viewers, one for full + [48]Q-22: Can I have two passwords for VNC viewers, one for full access and the other for view-only access to the display? - [46]Q-23: I use a screen-lock when I leave my workstation (e.g. + [49]Q-23: I use a screen-lock when I leave my workstation (e.g. xscreensaver or xlock). When I remotely access my workstation desktop via x11vnc I can unlock the desktop fine, but I am worried people will see my activities on the physical monitor. What can I do to prevent this, or at least make it more difficult? - [47]Q-24: Can I have x11vnc automatically lock the screen when I + [50]Q-24: Can I have x11vnc automatically lock the screen when I disconnect the VNC viewer? - [48]Q-25: Are reverse connections (i.e. the VNC server connecting to + [51]Q-25: Are reverse connections (i.e. the VNC server connecting to the VNC viewer) using "vncviewer -listen" and vncconnect(1) supported? - [49]Q-26: Sometimes when a VNC viewer dies abruptly, x11vnc also dies + [52]Q-26: Sometimes when a VNC viewer dies abruptly, x11vnc also dies with the error message like: "Broken pipe". I'm using the -forever mode and I want x11vnc to keep running. - [50]Q-27: How can I use x11vnc to connect to an X login screen like - xdm, GNOME gdmgreeter, KDE kdm, or CDE dtlogin? + [53]Q-27: How can I use x11vnc to connect to an X login screen like + xdm, GNOME gdm, KDE kdm, or CDE dtlogin? - [51]Q-28: Can I run x11vnc out of inetd(1)? + [54]Q-28: Can I run x11vnc out of inetd(1)? - [52]Q-29: How do I make x11vnc work with the Java VNC viewer applet in + [55]Q-29: How do I make x11vnc work with the Java VNC viewer applet in a web browser? - [53]Q-30: Why isn't the mouse cursor shape (the little icon shape + [56]Q-30: Why isn't the mouse cursor shape (the little icon shape where the mouse pointer is) correct as I move from window to window? - [54]Q-31: Why does the mouse arrow just stay in one corner in my + [57]Q-31: Why does the mouse arrow just stay in one corner in my vncviewer, whereas my cursor (that does move) is just a dot? - [55]Q-32: Can I take advantage of the TightVNC extension to the VNC + [58]Q-32: Can I take advantage of the TightVNC extension to the VNC protocol where Cursor Positions Updates are sent back to all connected clients (i.e. passive viewers can see the mouse cursor being moved around by another viewer)? - [56]Q-33: Is it possible to swap the mouse buttons (e.g. left-handed + [59]Q-33: Is it possible to swap the mouse buttons (e.g. left-handed operation), or arbitrarily remap them? How about mapping button clicks to keystrokes, e.g. to partially emulate Mouse wheel scrolling? - [57]Q-34: When I drag windows around with the mouse or scroll up and + [60]Q-34: When I drag windows around with the mouse or scroll up and down things really bog down (unless I do the drag in a single, quick motion). Is there anything to do to improve things? - [58]Q-35: I have lots of memory, but why does x11vnc fail with + [61]Q-35: I have lots of memory, but why does x11vnc fail with shmget: No space left on device or Minor opcode of failed request: 1 (X_ShmAttach)? - [59]Q-36: How can I make x11vnc use less system resources? + [62]Q-36: How can I make x11vnc use less system resources? - [60]Q-37: How can I make x11vnc use MORE system resources? + [63]Q-37: How can I make x11vnc use MORE system resources? - [61]Q-38: I use x11vnc over a slow link with high latency (i.e. dialup + [64]Q-38: I use x11vnc over a slow link with high latency (e.g. dialup modem), is there anything I can do to speed things up? - [62]Q-39: How can I get my AltGr and Shift modifiers to work between + [65]Q-39: How can I get my AltGr and Shift modifiers to work between keyboards for different languages? - [63]Q-40: When I try to type a "<" (i.e. less than) instead I get ">" + [66]Q-40: When I try to type a "<" (i.e. less than) instead I get ">" (i.e. greater than)! Strangely, typing ">" works OK!! - [64]Q-41: I'm using an "international" keyboard (e.g. German "de", or + [67]Q-41: I'm using an "international" keyboard (e.g. German "de", or Danish "dk") and the -modtweak mode works well if the VNC viewer is run on a Unix/Linux machine with a similar keyboard. But if I run the VNC viewer on Unix/Linux with a different keyboard (e.g. "us") or Windows with any keyboard, I can't type some keys like: "@", "$", "<", ">", etc. How can I fix this? - [65]Q-42: When typing I sometimes get double, triple, or more of my + [68]Q-42: When typing I sometimes get double, triple, or more of my keystrokes repeated. I'm sure I only typed them once, what can I do? - [66]Q-43: The machine where I run x11vnc has an AltGr key, but the + [69]Q-43: The machine where I run x11vnc has an AltGr key, but the local machine where I run the VNC viewer does not. Is there a way I can map a local unused key to send an AltGr? How about a Compose key as well? - [67]Q-44: I have a Sun machine I run x11vnc on. Its Sun keyboard has + [70]Q-44: I have a Sun machine I run x11vnc on. Its Sun keyboard has just one Alt key labelled "Alt" and two Meta keys labelled with little diamonds. The machine where I run the VNC viewer only has Alt keys. How can I send a Meta keypress? (e.g. emacs needs this) - [68]Q-45: Can I map a keystroke to a mouse button click on the remote + [71]Q-45: Can I map a keystroke to a mouse button click on the remote machine? - [69]Q-46: The remote display is larger (in number of pixels) than the + [72]Q-46: The remote display is larger (in number of pixels) than the local display I am running the vncviewer on. I don't like the vncviewer scrollbars, what I can do? - [70]Q-47: Does x11vnc support server-side framebuffer scaling? (E.g. + [73]Q-47: Does x11vnc support server-side framebuffer scaling? (E.g. to make the desktop smaller). - [71]Q-48: Does x11vnc work with Xinerama? (i.e. multiple monitors + [74]Q-48: Does x11vnc work with Xinerama? (i.e. multiple monitors joined together to form one big, single screen). - [72]Q-49: Can I use x11vnc on a multi-headed display that is not + [75]Q-49: Can I use x11vnc on a multi-headed display that is not Xinerama (i.e. separate screens :0.0, :0.1, ... for each monitor)? - [73]Q-50: Why is the view in my VNC viewer completely black? Or why is + [76]Q-50: Why is the view in my VNC viewer completely black? Or why is everything flashing around randomly? - [74]Q-51: I use Linux Virtual Consoles (VC's) to implement 'Fast User + [77]Q-51: I use Linux Virtual Consoles (VC's) to implement 'Fast User Switching' between users' sessions (e.g. Betty is on Ctrl-Alt-F7, Bobby is on Ctrl-Alt-F8, and Sid is on Ctrl-Alt-F1: they use those keystrokes to switch between their sessions). How come the view in a @@ -677,13 +697,13 @@ ls -l ./x11vnc/x11vnc otherwise all messed up unless the X session x11vnc is attached to is in the active VC? - [75]Q-52: Does the Clipboard/Selection get transferred between the + [78]Q-52: Does the Clipboard/Selection get transferred between the vncviewer and the X display? - [76]Q-53: Why don't I hear the "Beeps" in my X session (e.g. when + [79]Q-53: Why don't I hear the "Beeps" in my X session (e.g. when typing tput bel in an xterm)? - [77]Q-54: I am using x11vnc where my local machine has "popup/hidden + [80]Q-54: I am using x11vnc where my local machine has "popup/hidden taskbars" (e.g. GNOME or MacOS X) and the remote display where x11vnc runs also has "popup/hidden taskbars" (e.g. GNOME). When I move the mouse to the edge of the screen where the popups happen, the taskbars @@ -700,7 +720,7 @@ ls -l ./x11vnc/x11vnc specify it. Nearly always the correct value will be ":0" For the latter error, you need to set up the X11 permissions. See the - xauth(1), Xsecurity(1), and xhost(1) man pages. For example, you may + xauth(1), Xsecurity(7), and xhost(1) man pages. For example, you may need to set your XAUTHORITY environment variable to point to the correct cookie file (e.g. /home/joe/.Xauthority or /var/lib/xdm/authdir/authfiles/A:0-nRySEi), or simply be sure you run @@ -774,18 +794,18 @@ ls -l ./x11vnc/x11vnc Q-3: Where can I get a precompiled x11vnc binary for my Operating System? - Hopefully the [78]build steps above and [79]FAQ provide enough info + Hopefully the [81]build steps above and [82]FAQ provide enough info for a painless compile for most environments. Please report problems with the x11vnc configure, make, etc. on your system (if your system is known to compile other GNU packages successfully). There are precompiled x11vnc binaries made by other groups available at the following locations: - Debian: [80]http://packages.debian.org/x11vnc + Debian: (.deb) [83]http://packages.debian.org/x11vnc - Slackware: [81]http://www.linuxpackages.net/ Redhat/Fedora: - [82]http://dag.wieers.com/packages/x11vnc/ wwexptools: - [83]http://www.bell-labs.com/project/wwexptools/packages.html The last + Slackware: (.tgz) [84]http://www.linuxpackages.net/ Redhat/Fedora: + (.rpm) [85]http://dag.wieers.com/packages/x11vnc/ wwexptools: (.tgz) + [86]http://www.bell-labs.com/project/wwexptools/packages.html The last one, wwexptools, provides a variety of Unix binaries (Linux, Solaris, HP-UX, Irix, ...) with the intent of being compatible on a wide range of OS releases. Find x11vnc at that link and select 'download info'. @@ -808,7 +828,7 @@ ls -l ./x11vnc/x11vnc Q-4: How can I see all of x11vnc's command line options and documentation on how to use them? - Run: x11vnc -help The output is listed [84]here as well. + Run: x11vnc -help The output is listed [87]here as well. Q-5: I don't like typing arcane command line options every time I start x11vnc. What can I do? Is there a config file? @@ -849,7 +869,7 @@ display :0 Recommended additional safety measures include using ssh (see above) or a VPN to authenticate and encrypt the viewer connections or to at - least use the -rfbauth passwd-file [85]option to use VNC password + least use the -rfbauth passwd-file [88]option to use VNC password protection. Q-7: I have two separate machine displays in front of me, one Windows @@ -862,16 +882,16 @@ display :0 secondary display (X11). Then start up Win2VNC on the primary display (Windows) referring it to the secondary display. - This will also work X11 to X11 using [86]x2vnc, however you would + This will also work X11 to X11 using [89]x2vnc, however you would probably just want to avoid VNC and use x2x for that. For reference, here are some links to Win2VNC-like programs for multiple monitor setups: - * [87]Original Win2VNC - * [88]Enhanced Win2VNC and [89]sourceforge link - * [90]x2vnc - * [91]x2x also [92]here - * [93]zvnc (MorphOS) + * [90]Original Win2VNC + * [91]Enhanced Win2VNC and [92]sourceforge link + * [93]x2vnc + * [94]x2x also [95]here + * [96]zvnc (MorphOS) All of them (except x2x) will work with x11vnc. @@ -882,81 +902,114 @@ display :0 Connection reset by peer Is the default visual of the X display you run x11vnc on low color - (e.g. 8bpp PseudoColor)? (you can run xdpyinfo to check). There seems - to be a bug in Win2VNC in that it cannot deal correctly with colormaps - (PseudoColor is the most common example of a visual with a colormap). + (e.g. 8 bit per pixel PseudoColor)? (you can run xdpyinfo to check). + There seems to be a bug in Win2VNC in that it cannot deal correctly + with colormaps (PseudoColor is the most common example of a visual + with a colormap). If so, there are a couple options. 1) Can you set the default visual on your display to be depth 24 TrueColor? Sun machines often have 8+24 overlay visuals, and you can make the default visual depth 24 TrueColor (see fbconfig(1) and Xsun(1)). 2) As of Feb/2004, in the libvncserver CVS, x11vnc has the -visual option to allow you to force - the framebuffer visual to whatever you want. This option provides a - convenient workaround for the Win2VNC bug: + the framebuffer visual to whatever you want (this usually messes up + the colors unless you are very careful). In this case, the option + provides a convenient workaround for the Win2VNC bug: x11vnc -nofb -visual TrueColor -display :0 ... So the visual will be set to 8bpp TrueColor and Win2VNC can handle - this. Since Win2VNC does not use the framebuffer there should be no - problems in doing this. - - Q-9: The X display I run x11vnc on is only 8bpp PseudoColor (only 256 - distinct colors). x11vnc starts out OK, but after a while the colors - are incorrect in certain windows. + this. Since Win2VNC does not use the framebuffer data there should be + no problems in doing this. + + Q-9: The X display I run x11vnc on is only 8 bits per pixel (bpp) + PseudoColor (i.e. only 256 distinct colors). The x11vnc colors may + start out OK, but after a while the colors are incorrect in certain + windows. + + Use the -flashcmap option to have x11vnc watch for changes in the + colormap, and propagate those changes back to connected clients. This + can be slow (since the whole screen must be updated over the network + whenever the colormap changes). This flashing colormap behavior often + happens if an application installs its own private colormap when the + mouse is in its window. "netscape -install" is a well-known historical + example of this. Consider reconfiguring the system to 16 bpp or depth + 24 TrueColor if at all possible. + + Also note that in some rare cases the -notruecolor option has + corrected colors on 8bpp displays. The red, green, and blue masks were + non-zero in 8bpp PseudoColor on an obscure setup, and this option + corrected the problems. + + Q-10: Color problems: Why are the colors for some of the windows + messed up in x11vnc? BTW, I have an X display that has nice overlay + visuals of multiple color depths. E.g. there are both depth 8 and 24 + visuals available at the same time. - Use the -flashcmap to have x11vnc watch for changes in the colormap, - and propagate those changes back to connected clients. This can be - slow. The incorrect colors often happens if an application installs - its own private colormap when the mouse is in its window. netscape - -install is a well-known historical example of this. + You may want to review the [97]previous question regarding 8 bpp + PseudoColor. - Q-10: Color problems: I have an X display that has nice "overlay-like" - visuals of multiple color depths. E.g. there are both depth 8 and 24 - visuals available. Why are some of the colors messed up in x11vnc? - - First off, try the (rather slow) -flashcmap option just to be sure - your color problem isn't simply due to x11vnc not following the - changing 256 element colormap. The -notruecolor option has also been - known to resolve some color problems on 8bpp displays. - - If that doesn't help, run xdpyinfo to see what the default visual is. - Does it have a depth of 8? If it does, can you possibly re-configure - your X server to make the depth 24 visual the default? If you can do - it, this will save you a lot of grief WRT colors and x11vnc (and for - general usage too). I do this on an old Sparcstation 20 with SX - graphics + If that isn't the problem, run xdpyinfo to see what the default visual + is. Does it have a depth of 8? If it does, can you possibly + re-configure your X server to make the depth 24 visual the default? If + you can do it, this will save you a lot of grief WRT colors and x11vnc + (and for general usage too!). Here is how I do this on an old + Sparcstation 20 running Solaris 9 with SX graphics xinit -- -dev /dev/fb defclass TrueColor defdepth 24 - and it works nicely (to log into console from the dtlogin window, - select "Options -> Command Line Login", then login and enter the above - command). A more permanent and convenient option is to put a line - like: -:0 Local local_uid@console root /usr/openwin/bin/Xsun -dev /dev/fb defclass Tr -ueColor defdepth 24 + and it works nicely (note: to log into console from the dtlogin + window, select "Options -> Command Line Login", then login and enter + the above command). If you have root permission, a more permanent and + convenient option is to put a line like: + :0 Local local_uid@console root /usr/openwin/bin/Xsun -dev /dev/fb defclass +TrueColor defdepth 24 in /etc/dt/config/Xservers (see /usr/dt/config/Xservers). + Another option is if the system with overlay visuals is a Sun system + running Solaris you can use the -overlay x11vnc option (Aug/2004) to + have x11vnc use the Solaris XReadScreen(3X11) function to poll the + "true view" of the whole screen at depth 24 TrueColor. This is useful + for Legacy applications (older versions of Cadence CAD apps are + mentioned by x11vnc users) that require the default depth be 8bpp, or + will use a 8bpp visual even if depth 24 visuals are available, and so + the default depth workaround described in the previous paragraph is + not sufficient. + + Misc. notes on -overlay mode: An amusing by-product of -overlay mode + is that mouse cursor shape (e.g. use -X or -mouse options) is correct. + The -overlay mode may be somewhat slower than normal mode due to the + extra framebuffer manipulations that must be performed. Also, there is + a bug in that for some popup menus, the windows they overlap will have + painting problems while the popup is up (a workaround is to disable + SaveUnders by passing -su to Xsun, e.g. in your + /etc/dt/config/Xservers file). + Still not working? Run xwininfo on the application with the messed up colors to verify that the depth of its visual is different from the default visual depth (gotten from xdpyinfo). One possible workaround in this case is to use the -id option to point x11vnc at the - application window itself. If the application is complicated this may - not be acceptable, and may even crash x11vnc (but not the - application). + application window itself. If the application is complicated (lots of + toplevel windows and popup menus) this may not be acceptable, and may + even crash x11vnc (but not the application). - It is theoretically possible to solve this problem (see xwd(1) for - example), but it does not seem trivial or sufficiently fast for x11vnc - to be able to do. + It is theoretically possible to solve this problem in general (see + xwd(1) for example), but it does not seem trivial or sufficiently fast + for x11vnc to be able to do so in real time. Fortunately the -overlay + option works for Solaris machines with overlay visuals where most of + this problem occurs. Q-11: How do I figure out the window id to supply to the -id windowid option? Run the xwininfo program in a terminal. It will ask you to click on the desired application window. After clicking, it will print out much - information, including the window id. + information, including the window id. Also, the visual and depth of + the window printed out is often useful in debugging x11vnc + [98]problems. - Note that some VNC viewers will have problems rendering screens that - have a width that is not a multiple of 4. Try to manually adjust the - window width before starting x11vnc -id .... + When using -id windowid, note that some VNC viewers will have problems + rendering screens that have a width that is not a multiple of 4. Try + to manually adjust the window width before starting x11vnc -id .... Q-12: Why don't menus or other transient windows come up when I am using the -id windowid option to view a single application window? @@ -968,10 +1021,10 @@ ueColor defdepth 24 clipping or obscuring it. See the XGetImage man page for more details. If things are not working and you still want to do the single window - polling, feel free to ask for a version of x11vnc that has an - experimental -sid windowid option ("shifted" windowid). x11vnc is - known to crash under both -id and -sid, so both modes are still - experimental. + polling, try the -sid windowid option ("shifted" windowid). + + x11vnc is known to crash under both -id and -sid, so both modes are + still experimental. Q-13: Can I use x11vnc to view and interact with an Xterminal (e.g. NCD) that is not running UNIX and so x11vnc cannot be run on it @@ -1029,7 +1082,7 @@ ueColor defdepth 24 is "vnc", e.g.: vnc: 192.168.100.3 .example.com - Note that if you run x11vnc out of [94]inetd you do not need to build + Note that if you run x11vnc out of [99]inetd you do not need to build x11vnc with libwrap support because the /usr/sbin/tcpd reference in /etc/inetd.conf handles the tcp_wrappers stuff. @@ -1073,7 +1126,7 @@ ueColor defdepth 24 program to prompt the user whether the client should be accepted or not. This requires that you have xmessage installed and available via PATH. In case it is not already on your system, the xmessage program - is available at [95]ftp://ftp.x.org/ + is available at [100]ftp://ftp.x.org/ To include view-only decisions for the external commands, prefix the command something like this: "yes:0,no:*,view:3 mycommand ..." This @@ -1112,7 +1165,7 @@ elif [ $rc = 4 ]; then fi exit 1 - Stefan Radman has written a nice dtksh script [96]dtVncPopup for use + Stefan Radman has written a nice dtksh script [101]dtVncPopup for use in CDE environments to do the same sort of thing. Information on how to use it is found at the top of the file. He encourages you to provide feedback to him to help improve the script. @@ -1147,13 +1200,14 @@ exit 1 out for the command winding up in your shell's history file (history -c is often a way to clear it). - x11vnc also has the [97]-passwdfile and -passwd/-viewpasswd plain text - (i.e. not obscured like the -rfbauth VNC passwords) password options. + x11vnc also has the [102]-passwdfile and -passwd/-viewpasswd plain + text (i.e. not obscured like the -rfbauth VNC passwords) password + options. Q-19: How can I tunnel my connection to x11vnc via an encrypted SSH channel between two Unix machines? - See the description earlier on this page on [98]how to tunnel VNC via + See the description earlier on this page on [103]how to tunnel VNC via SSH from Unix to Unix. A number of ways are described along with some issues you may encounter. @@ -1162,8 +1216,8 @@ exit 1 Q-20: How can I tunnel my connection to x11vnc via an encrypted SSH channel from Windows using an SSH client like Putty? - [99]Above we described how to tunnel VNC via SSH from Unix to Unix. To - do this from Windows using Putty it would go something like this: + [104]Above we described how to tunnel VNC via SSH from Unix to Unix. + To do this from Windows using Putty it would go something like this: * In the Putty dialog window under 'Session' enter the hostname or IP number of the Unix machine with display to be viewed. * Make sure the SSH protocol is selected and the server port is @@ -1194,7 +1248,7 @@ exit 1 you'll need to do a second login (ssh or rsh) to the workstation machine 'otherhost' and then start up x11vnc on it. - As discussed [100]above another option is to first start the VNC + As discussed [105]above another option is to first start the VNC viewer in "listen" mode, and then launch x11vnc with the "-connection localhost" option to establish the reverse connection. In this case a Remote port redirection (not Local) is needed for port 5500 instead of @@ -1215,7 +1269,7 @@ exit 1 connection to make it appear to emanate from the local machine. As discussed above, ssh is useful for this: ssh -l username -L 5900:localhost:5900 hostname ... See the ssh wrapper scripts mentioned - [101]elsewhere on this page. Of course a malicious user could allow + [106]elsewhere on this page. Of course a malicious user could allow other users to get in through his channel, but that is a problem with every method. Another thing to watch out for is a malicious user on the viewer side (where ssh is running) trying to sneak in through the @@ -1291,7 +1345,7 @@ exit 1 # reject it In any event, as of Jun/2004 there is an experimental utility to make it more difficult for nosey people to see your x11vnc activities. The - source for it is [102]blockdpy.c The idea behind it is simple (but + source for it is [107]blockdpy.c The idea behind it is simple (but obviously not bulletproof): when a VNC client attaches to x11vnc put the display monitor in the DPMS "off" state, if the DPMS state ever changes immediately start up the screen-lock program. The x11vnc user @@ -1360,11 +1414,11 @@ xprop -root -f VNC_CONNECT 8s -set VNC_CONNECT "$1" Currently (Apr/2004) the above fix only works for BSD signal systems (Linux, FreeBSD, ...) For SYSV systems there is a workaround in my - [103]x11vnc.c file. It also has an option -sigpipe exit to have x11vnc + [108]x11vnc.c file. It also has an option -sigpipe exit to have x11vnc clean up and exit upon receiving SIGPIPE. Q-27: How can I use x11vnc to connect to an X login screen like xdm, - GNOME gdmgreeter, KDE kdm, or CDE dtlogin? + GNOME gdm, KDE kdm, or CDE dtlogin? One time only. If the X login screen is running and you just want to connect to it once: @@ -1428,7 +1482,7 @@ xprop -root -f VNC_CONNECT 8s -set VNC_CONNECT "$1" If you do not want to deal with the display manager startup scripts, here is a kludgey script that can be run manually or out of a boot - file like rc.local. [104]x11vnc_loop It will need some local + file like rc.local. [109]x11vnc_loop It will need some local customization before running. Because the XAUTHORITY auth file must be guessed by this script, use of the display manager script above is preferred. @@ -1545,11 +1599,16 @@ mp/x11vnc_sh.log build up a table of cursors for the windows it sees, perhaps using a user supplied hints file, but that has not been explored yet. + Also note that as of Aug/2004 in the libvncserver CVS, on Solaris + using the SUN_OVL overlay extension, x11vnc can show the correct mouse + cursor when the -overlay is also supplied. (-overlay has some other + problems however, and can be slower). + Q-31: Why does the mouse arrow just stay in one corner in my vncviewer, whereas my cursor (that does move) is just a dot? - This default takes advantage of a [105]tightvnc extension that allows - specifying a cursor shape for the local VNC viewer. You may disable it + This default takes advantage of a [110]tightvnc extension that allows + specifying a cursor image for the local VNC viewer. You may disable it with the -nocursor option to x11vnc if your viewer does not have this extension. @@ -1645,7 +1704,7 @@ mp/x11vnc_sh.log 19/03/2004 10:10:58 error creating tile-row shm for len=4 19/03/2004 10:10:58 reverting to single_copytile mode - Here is a shell script [106]shm_clear to list and prompt for removal + Here is a shell script [111]shm_clear to list and prompt for removal of your unattached shm segments (attached ones are skipped). I use it while debugging x11vnc (I use shm_clear -y to assume "yes" for each prompt). If x11vnc is regularly not cleaning up its shm segments, @@ -1683,7 +1742,7 @@ ied) -fs 1.0 knocks it down to 2). If you are having much trouble with shm segments, consider disabling shm completely via the -noshm option. Performance will be somewhat degraded but when done over local machine - sockets it should be acceptable (see an [107]earlier question + sockets it should be acceptable (see an [112]earlier question discussing -noshm). Q-36: How can I make x11vnc use less system resources? @@ -1707,7 +1766,7 @@ ied) the x11vnc -id option) can be streamed over a LAN or wireless at a reasonable frame rate. - Q-38: I use x11vnc over a slow link with high latency (i.e. dialup + Q-38: I use x11vnc over a slow link with high latency (e.g. dialup modem), is there anything I can do to speed things up? Some things you might want to experiment with (most of which will help @@ -1731,7 +1790,7 @@ ied) worth it, but could be of use in some situations. VNC viewer parameters: - * Use a [108]TightVNC enabled viewer! + * Use a [113]TightVNC enabled viewer! * Make sure the tight encoding is being used (look at vncviewer and x11vnc outputs) * Request 8 bits per pixel using -bgr233 (up to 4X speedup over @@ -1779,12 +1838,12 @@ ied) default (use -nomodtweak to get the old behavior). This was done because it was noticed on newer XFree86 setups even on bland "us" keyboards like "pc104 us" XFree86 included a "ghost" key with both "<" - and ">" it. This key does not exist on the keyboard (see [109]this FAQ + and ">" it. This key does not exist on the keyboard (see [114]this FAQ for more info). Without -modtweak there was then an ambiguity in the reverse map keysym => keycode, making it so the "<" symbol could not be typed. - Also see the [110]FAQ about the -xkb option for a more powerful method + Also see the [115]FAQ about the -xkb option for a more powerful method of modifier tweaking for use on X servers with the XKEYBOARD extension. @@ -1845,7 +1904,7 @@ ied) the keysym comma when it comes in from a client (so when Shift is down the comma press will yield "<"). - See also the [111]FAQ about the -xkb option as a possible workaround + See also the [116]FAQ about the -xkb option as a possible workaround using the XKEYBOARD extension. Note that of Jul/2004 in the libvncserver CVS the -modtweak option is now that default. @@ -1906,15 +1965,16 @@ ied) be obsolete) in the mapping as well. Both of these keysyms were bound to Mod5 and x11vnc was unfortunately choosing Mode_switch. From the x11vnc -xkb -dk -dk output it was noted that Mode_switch - was attached to keycode 93 while ISO_Level3_Shift was attached to - keycode 113. The keycode skipping option was used to disable the - ghost key: -skip_keycodes 93 - * In implementing -xkb we noticed that some keys were still not - getting through, e.g. "~" and "^". This is not really an XKEYBOARD - problem. What was happening was the VNC viewer was sending the - keysyms asciitilde and asciicircum to x11vnc, but on the X server - with the international keyboard those keysyms were not mapped to - any keys. So x11vnc had to skip them. + was attached to keycode 93 (no physical key generates this + keycode) while ISO_Level3_Shift was attached to keycode 113. The + keycode skipping option was used to disable the ghost key: + -skip_keycodes 93 + * In implementing -xkb we noticed that some characters were still + not getting through, e.g. "~" and "^". This is not really an + XKEYBOARD problem. What was happening was the VNC viewer was + sending the keysyms asciitilde and asciicircum to x11vnc, but on + the X server with the international keyboard those keysyms were + not mapped to any keys. So x11vnc had to skip them. The way these characters are typically entered on international keyboards is by "dead" (aka "mute") keys. E.g. to enter "~" at the physical display the keysym dead_tilde is pressed and released @@ -2048,7 +2108,7 @@ ied) There may also be scaling viewers out there (e.g. TightVNC on Windows) that automatically shrink or expand the remote framebuffer to fit the - local display. Especially for hand-held devices. See also [112]this + local display. Especially for hand-held devices. See also [117]this FAQ Q-47: Does x11vnc support server-side framebuffer scaling? (E.g. to @@ -2061,16 +2121,14 @@ ied) the alternative m/n fraction notation (e.g. -scale 2/3). The current implementation is experimental in that it still needs to - be optimized and there are some painting errors (evidently only with - fraction > 1; which is probably the less interesting case). Extra - resources (CPU, memory I/O, and memory) are required to do the - scaling. If the machine is slow where x11vnc is run with scaling - enabled, the interactive response can be unacceptable. OTOH, if run - with scaling on a fast machine the performance degradation is usually - not a big issue or even noticeable. - - If you just want a quick, rough "thumbnail" of the display you can - append ":nb" to the fraction to turn on "no blending" mode. E.g.: + be optimized. Extra resources (CPU, memory I/O, and memory) are + required to do the scaling. If the machine is slow where x11vnc is run + with scaling enabled, the interactive response can be unacceptable. + OTOH, if run with scaling on a fast machine the performance + degradation is usually not a big issue or even noticeable. + + Also, if you just want a quick, rough "thumbnail" of the display you + can append ":nb" to the fraction to turn on "no blending" mode. E.g.: "-scale 1/3:nb" Fonts will be difficult to read, but the larger features will be recognizable. BTW, "no blending" mode is forced on when scaling 8bpp PseudoColor displays (because blending an indexed @@ -2145,7 +2203,7 @@ ied) Note: if you are running on Solaris 8 or earlier you can easily hit up against the maximum of 6 shm segments per process (for Xsun in this case) from running multiple x11vnc processes. You should modify - /etc/system as mentioned in another [113]FAQ to increase the limit. It + /etc/system as mentioned in another [118]FAQ to increase the limit. It is probably also a good idea to run with the -onetile option in this case (to limit each x11vnc to 3 shm segments), or even -noshm to use no shm segments. @@ -2180,7 +2238,7 @@ ied) If no one is sitting at the workstation and you just want to remotely switch the VC over to the one associated with your X session (so x11vnc can poll it), one can use the switchto(1) command, e.g. - switchto 7 for VC #7. + "switchto 7" for VC #7. Q-52: Does the Clipboard/Selection get transferred between the vncviewer and the X display? @@ -2233,101 +2291,106 @@ References 16. http://www.karlrunge.com/x11vnc/index.html#binaries 17. http://www.karlrunge.com/x11vnc/rx11vnc 18. http://www.karlrunge.com/x11vnc/rx11vnc.pl - 19. http://www.tightvnc.com/ - 20. http://www.karlrunge.com/x11vnc/x11vnc_opts.html - 21. http://www.karlrunge.com/x11vnc/index.html#passwd - 22. http://wwws.sun.com/sunray/index.html - 23. mailto:xvml@karlrunge.com - 24. http://www.karlrunge.com/x11vnc/index.html#FAQ-1 - 25. http://www.karlrunge.com/x11vnc/index.html#FAQ-2 - 26. http://www.karlrunge.com/x11vnc/index.html#FAQ-3 - 27. http://www.karlrunge.com/x11vnc/index.html#FAQ-4 - 28. http://www.karlrunge.com/x11vnc/index.html#FAQ-5 - 29. http://www.karlrunge.com/x11vnc/index.html#FAQ-6 - 30. http://www.karlrunge.com/x11vnc/index.html#FAQ-7 - 31. http://www.karlrunge.com/x11vnc/index.html#FAQ-8 - 32. http://www.karlrunge.com/x11vnc/index.html#FAQ-9 - 33. http://www.karlrunge.com/x11vnc/index.html#FAQ-10 - 34. http://www.karlrunge.com/x11vnc/index.html#FAQ-11 - 35. http://www.karlrunge.com/x11vnc/index.html#FAQ-12 - 36. http://www.karlrunge.com/x11vnc/index.html#FAQ-13 - 37. http://www.karlrunge.com/x11vnc/index.html#FAQ-14 - 38. http://www.karlrunge.com/x11vnc/index.html#FAQ-15 - 39. http://www.karlrunge.com/x11vnc/index.html#FAQ-16 - 40. http://www.karlrunge.com/x11vnc/index.html#FAQ-17 - 41. http://www.karlrunge.com/x11vnc/index.html#FAQ-18 - 42. http://www.karlrunge.com/x11vnc/index.html#FAQ-19 - 43. http://www.karlrunge.com/x11vnc/index.html#FAQ-20 - 44. http://www.karlrunge.com/x11vnc/index.html#FAQ-21 - 45. http://www.karlrunge.com/x11vnc/index.html#FAQ-22 - 46. http://www.karlrunge.com/x11vnc/index.html#FAQ-23 - 47. http://www.karlrunge.com/x11vnc/index.html#FAQ-24 - 48. http://www.karlrunge.com/x11vnc/index.html#FAQ-25 - 49. http://www.karlrunge.com/x11vnc/index.html#FAQ-26 - 50. http://www.karlrunge.com/x11vnc/index.html#FAQ-27 - 51. http://www.karlrunge.com/x11vnc/index.html#FAQ-28 - 52. http://www.karlrunge.com/x11vnc/index.html#FAQ-29 - 53. http://www.karlrunge.com/x11vnc/index.html#FAQ-30 - 54. http://www.karlrunge.com/x11vnc/index.html#FAQ-31 - 55. http://www.karlrunge.com/x11vnc/index.html#FAQ-32 - 56. http://www.karlrunge.com/x11vnc/index.html#FAQ-33 - 57. http://www.karlrunge.com/x11vnc/index.html#FAQ-34 - 58. http://www.karlrunge.com/x11vnc/index.html#FAQ-35 - 59. http://www.karlrunge.com/x11vnc/index.html#FAQ-36 - 60. http://www.karlrunge.com/x11vnc/index.html#FAQ-37 - 61. http://www.karlrunge.com/x11vnc/index.html#FAQ-38 - 62. http://www.karlrunge.com/x11vnc/index.html#FAQ-39 - 63. http://www.karlrunge.com/x11vnc/index.html#FAQ-40 - 64. http://www.karlrunge.com/x11vnc/index.html#FAQ-41 - 65. http://www.karlrunge.com/x11vnc/index.html#FAQ-42 - 66. http://www.karlrunge.com/x11vnc/index.html#FAQ-43 - 67. http://www.karlrunge.com/x11vnc/index.html#FAQ-44 - 68. http://www.karlrunge.com/x11vnc/index.html#FAQ-45 - 69. http://www.karlrunge.com/x11vnc/index.html#FAQ-46 - 70. http://www.karlrunge.com/x11vnc/index.html#FAQ-47 - 71. http://www.karlrunge.com/x11vnc/index.html#FAQ-48 - 72. http://www.karlrunge.com/x11vnc/index.html#FAQ-49 - 73. http://www.karlrunge.com/x11vnc/index.html#FAQ-50 - 74. http://www.karlrunge.com/x11vnc/index.html#FAQ-51 - 75. http://www.karlrunge.com/x11vnc/index.html#FAQ-52 - 76. http://www.karlrunge.com/x11vnc/index.html#FAQ-53 - 77. http://www.karlrunge.com/x11vnc/index.html#FAQ-54 - 78. http://www.karlrunge.com/x11vnc/index.html#building - 79. http://www.karlrunge.com/x11vnc/index.html#buildfaq - 80. http://packages.debian.org/x11vnc - 81. http://www.linuxpackages.net/search_view.php?by=name&name=x11vnc - 82. http://dag.wieers.com/packages/x11vnc/ - 83. http://www.bell-labs.com/project/wwexptools/packages.html - 84. http://www.karlrunge.com/x11vnc/x11vnc_opts.html - 85. http://www.karlrunge.com/x11vnc/index.html#passwd - 86. http://fredrik.hubbe.net/x2vnc.html - 87. http://www.hubbe.net/~hubbe/win2vnc.html - 88. http://www.deboer.gmxhome.de/ - 89. http://sourceforge.net/projects/win2vnc/ - 90. http://fredrik.hubbe.net/x2vnc.html - 91. http://freshmeat.net/projects/x2x/ - 92. http://ftp.digital.com/pub/Digital/SRC/x2x/ - 93. http://zapek.com/software/zvnc/ - 94. http://www.karlrunge.com/x11vnc/index.html#inetd - 95. ftp://ftp.x.org/ - 96. http://www.karlrunge.com/x11vnc/dtVncPopup - 97. http://www.karlrunge.com/x11vnc/index.html#passwdfile - 98. http://www.karlrunge.com/x11vnc/index.html#tunnelling - 99. http://www.karlrunge.com/x11vnc/index.html#tunnelling - 100. http://www.karlrunge.com/x11vnc/index.html#tunnelling - 101. http://www.karlrunge.com/x11vnc/index.html#tunnelling - 102. http://www.karlrunge.com/x11vnc/blockdpy.c - 103. http://www.karlrunge.com/x11vnc/x11vnc.c - 104. http://www.karlrunge.com/x11vnc/x11vnc_loop - 105. http://www.tightvnc.com/ - 106. http://www.karlrunge.com/x11vnc/shm_clear - 107. http://www.karlrunge.com/x11vnc/index.html#noshm - 108. http://www.tightvnc.com/ - 109. http://www.karlrunge.com/x11vnc/index.html#greaterless - 110. http://www.karlrunge.com/x11vnc/index.html#xkbmodtweak - 111. http://www.karlrunge.com/x11vnc/index.html#xkbmodtweak - 112. http://www.karlrunge.com/x11vnc/index.html#scaling - 113. http://www.karlrunge.com/x11vnc/index.html#solshm + 19. ftp://ftp.uu.net/graphics/jpeg/ + 20. http://www.gzip.org/zlib/ + 21. http://www.sunfreeware.com/ + 22. http://www.tightvnc.com/ + 23. http://www.karlrunge.com/x11vnc/x11vnc_opts.html + 24. http://www.karlrunge.com/x11vnc/index.html#passwd + 25. http://wwws.sun.com/sunray/index.html + 26. mailto:xvml@karlrunge.com + 27. http://www.karlrunge.com/x11vnc/index.html#FAQ-1 + 28. http://www.karlrunge.com/x11vnc/index.html#FAQ-2 + 29. http://www.karlrunge.com/x11vnc/index.html#FAQ-3 + 30. http://www.karlrunge.com/x11vnc/index.html#FAQ-4 + 31. http://www.karlrunge.com/x11vnc/index.html#FAQ-5 + 32. http://www.karlrunge.com/x11vnc/index.html#FAQ-6 + 33. http://www.karlrunge.com/x11vnc/index.html#FAQ-7 + 34. http://www.karlrunge.com/x11vnc/index.html#FAQ-8 + 35. http://www.karlrunge.com/x11vnc/index.html#FAQ-9 + 36. http://www.karlrunge.com/x11vnc/index.html#FAQ-10 + 37. http://www.karlrunge.com/x11vnc/index.html#FAQ-11 + 38. http://www.karlrunge.com/x11vnc/index.html#FAQ-12 + 39. http://www.karlrunge.com/x11vnc/index.html#FAQ-13 + 40. http://www.karlrunge.com/x11vnc/index.html#FAQ-14 + 41. http://www.karlrunge.com/x11vnc/index.html#FAQ-15 + 42. http://www.karlrunge.com/x11vnc/index.html#FAQ-16 + 43. http://www.karlrunge.com/x11vnc/index.html#FAQ-17 + 44. http://www.karlrunge.com/x11vnc/index.html#FAQ-18 + 45. http://www.karlrunge.com/x11vnc/index.html#FAQ-19 + 46. http://www.karlrunge.com/x11vnc/index.html#FAQ-20 + 47. http://www.karlrunge.com/x11vnc/index.html#FAQ-21 + 48. http://www.karlrunge.com/x11vnc/index.html#FAQ-22 + 49. http://www.karlrunge.com/x11vnc/index.html#FAQ-23 + 50. http://www.karlrunge.com/x11vnc/index.html#FAQ-24 + 51. http://www.karlrunge.com/x11vnc/index.html#FAQ-25 + 52. http://www.karlrunge.com/x11vnc/index.html#FAQ-26 + 53. http://www.karlrunge.com/x11vnc/index.html#FAQ-27 + 54. http://www.karlrunge.com/x11vnc/index.html#FAQ-28 + 55. http://www.karlrunge.com/x11vnc/index.html#FAQ-29 + 56. http://www.karlrunge.com/x11vnc/index.html#FAQ-30 + 57. http://www.karlrunge.com/x11vnc/index.html#FAQ-31 + 58. http://www.karlrunge.com/x11vnc/index.html#FAQ-32 + 59. http://www.karlrunge.com/x11vnc/index.html#FAQ-33 + 60. http://www.karlrunge.com/x11vnc/index.html#FAQ-34 + 61. http://www.karlrunge.com/x11vnc/index.html#FAQ-35 + 62. http://www.karlrunge.com/x11vnc/index.html#FAQ-36 + 63. http://www.karlrunge.com/x11vnc/index.html#FAQ-37 + 64. http://www.karlrunge.com/x11vnc/index.html#FAQ-38 + 65. http://www.karlrunge.com/x11vnc/index.html#FAQ-39 + 66. http://www.karlrunge.com/x11vnc/index.html#FAQ-40 + 67. http://www.karlrunge.com/x11vnc/index.html#FAQ-41 + 68. http://www.karlrunge.com/x11vnc/index.html#FAQ-42 + 69. http://www.karlrunge.com/x11vnc/index.html#FAQ-43 + 70. http://www.karlrunge.com/x11vnc/index.html#FAQ-44 + 71. http://www.karlrunge.com/x11vnc/index.html#FAQ-45 + 72. http://www.karlrunge.com/x11vnc/index.html#FAQ-46 + 73. http://www.karlrunge.com/x11vnc/index.html#FAQ-47 + 74. http://www.karlrunge.com/x11vnc/index.html#FAQ-48 + 75. http://www.karlrunge.com/x11vnc/index.html#FAQ-49 + 76. http://www.karlrunge.com/x11vnc/index.html#FAQ-50 + 77. http://www.karlrunge.com/x11vnc/index.html#FAQ-51 + 78. http://www.karlrunge.com/x11vnc/index.html#FAQ-52 + 79. http://www.karlrunge.com/x11vnc/index.html#FAQ-53 + 80. http://www.karlrunge.com/x11vnc/index.html#FAQ-54 + 81. http://www.karlrunge.com/x11vnc/index.html#building + 82. http://www.karlrunge.com/x11vnc/index.html#buildfaq + 83. http://packages.debian.org/x11vnc + 84. http://www.linuxpackages.net/search_view.php?by=name&name=x11vnc + 85. http://dag.wieers.com/packages/x11vnc/ + 86. http://www.bell-labs.com/project/wwexptools/packages.html + 87. http://www.karlrunge.com/x11vnc/x11vnc_opts.html + 88. http://www.karlrunge.com/x11vnc/index.html#passwd + 89. http://fredrik.hubbe.net/x2vnc.html + 90. http://www.hubbe.net/~hubbe/win2vnc.html + 91. http://www.deboer.gmxhome.de/ + 92. http://sourceforge.net/projects/win2vnc/ + 93. http://fredrik.hubbe.net/x2vnc.html + 94. http://freshmeat.net/projects/x2x/ + 95. http://ftp.digital.com/pub/Digital/SRC/x2x/ + 96. http://zapek.com/software/zvnc/ + 97. http://www.karlrunge.com/x11vnc/index.html#8bpp + 98. http://www.karlrunge.com/x11vnc/overlays + 99. http://www.karlrunge.com/x11vnc/index.html#inetd + 100. ftp://ftp.x.org/ + 101. http://www.karlrunge.com/x11vnc/dtVncPopup + 102. http://www.karlrunge.com/x11vnc/index.html#passwdfile + 103. http://www.karlrunge.com/x11vnc/index.html#tunnelling + 104. http://www.karlrunge.com/x11vnc/index.html#tunnelling + 105. http://www.karlrunge.com/x11vnc/index.html#tunnelling + 106. http://www.karlrunge.com/x11vnc/index.html#tunnelling + 107. http://www.karlrunge.com/x11vnc/blockdpy.c + 108. http://www.karlrunge.com/x11vnc/x11vnc.c + 109. http://www.karlrunge.com/x11vnc/x11vnc_loop + 110. http://www.tightvnc.com/ + 111. http://www.karlrunge.com/x11vnc/shm_clear + 112. http://www.karlrunge.com/x11vnc/index.html#noshm + 113. http://www.tightvnc.com/ + 114. http://www.karlrunge.com/x11vnc/index.html#greaterless + 115. http://www.karlrunge.com/x11vnc/index.html#xkbmodtweak + 116. http://www.karlrunge.com/x11vnc/index.html#xkbmodtweak + 117. http://www.karlrunge.com/x11vnc/index.html#scaling + 118. http://www.karlrunge.com/x11vnc/index.html#solshm ======================================================================= @@ -2340,7 +2403,8 @@ x11vnc: a VNC server for real X displays Here are all of x11vnc command line options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.6.2 lastmod: 2004-07-31 +x11vnc: allow VNC connections to real X11 displays. 0.6.3pre lastmod: 2004-08-1 +5 Typical usage is: @@ -2386,12 +2450,39 @@ Options: setting the XAUTHORITY environment varirable to "file" before startup. See Xsecurity(7), xauth(1) man pages. --id windowid Show the window corresponding to not the +-id windowid Show the window corresponding to "windowid" not the entire display. Warning: bugs! new toplevels missed!... +-sid windowid As -id, but instead of using the window directly it + shifts a root view to it: shows saveUnders menus, etc, + although they will be clipped if they extend beyond + the window. -flashcmap In 8bpp indexed color, let the installed colormap flash as the pointer moves from window to window (slow). --notruecolor Force 8bpp indexed color even if it looks like TrueColor -. +-notruecolor For 8bpp displays, force indexed color (i.e. a colormap) + even if it looks like 8bpp TrueColor. (rare problem) +-overlay Handle multiple depth visuals on one screen, e.g. 8+24 + and 24+8 overlay visuals (the 32 bits per pixel are + packed with 8 for PseudoColor and 24 for TrueColor). + + Currently -overlay only works on Solaris (it uses + XReadScreen(3X11)). There are still some problems with + surrounding-region painting for popup menus (but not + for the popup menu itself); a workaround is to disable + SaveUnders (pass -su to Xsun). Amusingly, if -overlay + is used with -mouse, the mouse cursor shape is correct. + + Use -overlay as a workaround for situations like these: + Some legacy applications require the default visual + be 8bpp (8+24), or they will use 8bpp PseudoColor even + when the default visual is depth 24 TrueColor (24+8). + In these cases colors in some windows will be messed + up in x11vnc unless -overlay is used. + + Under -overlay, performance will be somewhat degraded + due to the extra image transformations required. + For optimal performance do not use -overlay, but rather + configure the X server so that the default visual is + depth 24 TrueColor and have all apps use that visual. -visual n Experimental option: probably does not do what you think. It simply *forces* the visual used for the framebuffer; this may be a bad thing... It is useful for @@ -2406,10 +2497,10 @@ Options: and response may be slower. If "fraction" contains a decimal point "." it is taken as a floating point number, alternatively the notation "m/n" may be used - to denote fractions, e.g. -scale 2/3. + to denote fractions exactly, e.g. -scale 2/3. - Scaling Options: can be added after fraction via ":", - to supply multiple ":" options use commas. + Scaling Options: can be added after "fraction" via + ":", to supply multiple ":" options use commas. If you just want a quick, rough scaling without blending, append ":nb" to "fraction" (e.g. -scale 1/3:nb). For compatibility with vncviewers the scaled @@ -2426,9 +2517,9 @@ Options: -forever Keep listening for more connections rather than exiting as soon as the first client(s) disconnect. Same as -many -connect string For use with "vncviewer -listen" reverse connections. - If string has the form "host" or "host:port" + If "string" has the form "host" or "host:port" the connection is made once at startup. Use commas - for a list of host's and host:port's. If string + for a list of host's and host:port's. If "string" contains "/" it is instead interpreted as a file to periodically check for new hosts. The first line is read and then the file is truncated. @@ -2514,8 +2605,8 @@ Options: responses. All 3 of the popup keywords can be followed by +N+M to supply a position for the popup window. The default is to center the popup window. --gone string As -accept string, except to run a user supplied command - when a client goes away (disconnects). Unlike -accept, +-gone string As -accept, except to run a user supplied command when + a client goes away (disconnects). Unlike -accept, the command return code is not interpreted by x11vnc. -noshm Do not use the MIT-SHM extension for the polling. @@ -2529,8 +2620,9 @@ Options: just use 1 shm tile for polling. Same as -old_copytile. Limits shm segments used to 3. --blackout string Black out rectangles on the screen. string is a comma - separated list of WxH+X+Y type geometries for each rect. +-blackout string Black out rectangles on the screen. "string" is a + comma separated list of WxH+X+Y type geometries for + each rectangle. -xinerama If your screen is composed of multiple monitors glued together via XINERAMA, and that screen is non-rectangular this option will try to guess the areas diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index f88ae22..976104a 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -2,7 +2,7 @@ .TH X11VNC "1" "August 2004" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.6.2, lastmod: 2004-07-31 + version: 0.6.3pre, lastmod: 2004-08-15 .SH SYNOPSIS .B x11vnc [OPTION]... @@ -69,7 +69,9 @@ entire display. Warning: bugs! new toplevels missed!... \fB-sid\fR \fIwindowid\fR .IP As \fB-id,\fR but instead of using the window directly it -shifts a root view to it: shows saveUnders menus, etc. +shifts a root view to it: shows saveUnders menus, etc, +although they will be clipped if they extend beyond +the window. .PP \fB-flashcmap\fR .IP @@ -78,7 +80,34 @@ as the pointer moves from window to window (slow). .PP \fB-notruecolor\fR .IP -Force 8bpp indexed color even if it looks like TrueColor. +For 8bpp displays, force indexed color (i.e. a colormap) +even if it looks like 8bpp TrueColor. (rare problem) +.PP +\fB-overlay\fR +.IP +Handle multiple depth visuals on one screen, e.g. 8+24 +and 24+8 overlay visuals (the 32 bits per pixel are +packed with 8 for PseudoColor and 24 for TrueColor). +.IP +Currently \fB-overlay\fR only works on Solaris (it uses +XReadScreen(3X11)). There are still some problems with +surrounding-region painting for popup menus (but not +for the popup menu itself); a workaround is to disable +SaveUnders (pass \fB-su\fR to Xsun). Amusingly, if \fB-overlay\fR +is used with \fB-mouse,\fR the mouse cursor shape is correct. +.IP +Use \fB-overlay\fR as a workaround for situations like these: +Some legacy applications require the default visual +be 8bpp (8+24), or they will use 8bpp PseudoColor even +when the default visual is depth 24 TrueColor (24+8). +In these cases colors in some windows will be messed +up in x11vnc unless \fB-overlay\fR is used. +.IP +Under \fB-overlay,\fR performance will be somewhat degraded +due to the extra image transformations required. +For optimal performance do not use \fB-overlay,\fR but rather +configure the X server so that the default visual is +depth 24 TrueColor and have all apps use that visual. .PP \fB-visual\fR \fIn\fR .IP @@ -100,7 +129,7 @@ less than 1 shrink the fb. Note: image may not be sharp and response may be slower. If \fIfraction\fR contains a decimal point "." it is taken as a floating point number, alternatively the notation "m/n" may be used -to denote fractions, e.g. \fB-scale\fR 2/3. +to denote fractions exactly, e.g. \fB-scale\fR 2/3. .IP Scaling Options: can be added after \fIfraction\fR via ":", to supply multiple ":" options use commas. diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index fbb315e..436d5a1 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -79,6 +79,7 @@ * -flashcmap option to have colormap flashing as the pointer moves * windows with private colormaps (slow). Displays with mixed depth 8 and * 24 visuals will incorrectly display windows using the non-default one. + * On Sun hardware we try to work around this with -overlay. * * Feature -id can be picky: it can crash for things like the * window not sufficiently mapped into server memory, use of -mouse, etc. @@ -141,6 +142,11 @@ #include #endif +#if defined (__SVR4) && defined (__sun) +#define SOLARIS +#include +#endif + /* * Temporary kludge: to run with -xinerama define the following * macro (uncomment) and be sure to link with -lXinerama @@ -156,18 +162,19 @@ #endif /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.6.3pre lastmod: 2004-08-03"; +char lastmod[] = "0.6.3pre lastmod: 2004-08-15"; /* X display info */ -Display *dpy = 0; -Visual *visual; -Window window, rootwin; + +Display *dpy = 0; /* the single display screen we connect to */ int scr; +Window window, rootwin; /* polled window, root window (usu. same) */ +Visual *default_visual; /* the default visual (unless -visual) */ int bpp, depth; -int button_mask = 0; -int dpy_x, dpy_y; -int off_x, off_y; int indexed_colour = 0; +int dpy_x, dpy_y; /* size of display */ +int off_x, off_y; /* offsets for -sid */ +int button_mask = 0; /* button state and info */ int num_buttons = -1; /* image structures */ @@ -209,17 +216,19 @@ int ntiles, ntiles_x, ntiles_y; /* arrays that indicate changed or checked tiles. */ unsigned char *tile_has_diff, *tile_tried; -/* blacked-out region things */ +/* blacked-out region (-blackout, -xinerama) */ typedef struct bout { int x1, y1, x2, y2; } blackout_t; +#define BO_MAX 16 typedef struct tbout { - blackout_t bo[16]; /* hardwired max rectangles. */ + blackout_t bo[BO_MAX]; /* hardwired max rectangles. */ int cover; int count; } tile_blackout_t; -blackout_t blackr[100]; /* hardwired max blackouts */ +#define BLACKR_MAX 100 +blackout_t blackr[BLACKR_MAX]; /* hardwired max blackouts */ int blackouts = 0; tile_blackout_t *tile_blackout; @@ -245,6 +254,7 @@ int shut_down = 0; char vnc_connect_str[VNC_CONNECT_MAX+1]; Atom vnc_connect_prop = None; + /* function prototypes (see filename comment above) */ int all_clients_initialized(void); @@ -378,9 +388,11 @@ int watch_primary = 1; /* more dicey, poll for changes in PRIMARY */ int sigpipe = 1; /* 0=skip, 1=ignore, 2=exit */ -/* for -visual override */ +/* visual stuff for -visual override or -overlay */ VisualID visual_id = (VisualID) 0; int visual_depth = 0; +int overlay = 0; +int overlay_mouse = 0; /* tile heuristics: */ double fs_frac = 0.75; /* threshold tile fraction to do fullscreen updates. */ @@ -394,6 +406,7 @@ int debug_keyboard = 0; int quiet = 0; +/* info about command line opts */ int got_rfbport = 0; int got_alwaysshared = 0; int got_nevershared = 0; @@ -454,6 +467,102 @@ int nfix(int i, int n) { return i; } +/* + * Kludge to interpose image gets and limit to a subset rectangle of + * the rootwin. This is the -sid option trying to work around invisible + * saveUnders menu, etc, windows. + */ +int rootshift = 0; + +#define ADJUST_ROOTSHIFT \ + if (rootshift && subwin) { \ + d = rootwin; \ + x += off_x; \ + y += off_y; \ + } + +/* Wrappers for Image related X calls */ +Status XShmGetImage_wr(Display *disp, Drawable d, XImage *image, int x, int y, + unsigned long mask) { + + ADJUST_ROOTSHIFT + + /* The Solaris overlay stuff is all non-shm (using_shm = 0) */ + + return XShmGetImage(disp, d, image, x, y, mask); +} + +XImage *XGetSubImage_wr(Display *disp, Drawable d, int x, int y, + unsigned int width, unsigned int height, unsigned long plane_mask, + int format, XImage *dest_image, int dest_x, int dest_y) { + + ADJUST_ROOTSHIFT + +#ifdef SOLARIS + if (overlay && dest_x == 0 && dest_y == 0) { + size_t size = dest_image->height * dest_image->bytes_per_line; + XImage *xi = XReadScreen(disp, d, x, y, width, height, + (Bool) overlay_mouse); + + /* + * There is extra overhead from memcpy and free... + * this is not like the real XGetSubImage(). We hope + * this significant overhead is still small compared to + * the time to retrieve the fb data. + */ + memcpy(dest_image->data, xi->data, size); + + XDestroyImage(xi); + return (dest_image); + } +#endif + return XGetSubImage(disp, d, x, y, width, height, plane_mask, + format, dest_image, dest_x, dest_y); +} + +XImage *XGetImage_wr(Display *disp, Drawable d, int x, int y, + unsigned int width, unsigned int height, unsigned long plane_mask, + int format) { + + ADJUST_ROOTSHIFT + +#ifdef SOLARIS + if (overlay) { + return XReadScreen(disp, d, x, y, width, height, + (Bool) overlay_mouse); + } +#endif + return XGetImage(disp, d, x, y, width, height, plane_mask, format); +} + +XImage *XCreateImage_wr(Display *disp, Visual *visual, unsigned int depth, + int format, int offset, char *data, unsigned int width, + unsigned int height, int bitmap_pad, int bytes_per_line) { +/* + * This is a kludge to get a created XImage to exactly match what + * XReadScreen returns: we noticed the rgb masks are different from + * XCreateImage with the high color visual (red mask <-> blue mask). + * Note we read from the root window(!) then free the data. + */ +#ifdef SOLARIS + if (overlay) { + XImage *xi; + xi = XReadScreen(disp, window, 0, 0, width, height, False); + if (xi == NULL) { + return xi; + } + if (xi->data != NULL) { + free(xi->data); + } + xi->data = data; + return xi; + } +#endif + + return XCreateImage(disp, visual, depth, format, offset, data, + width, height, bitmap_pad, bytes_per_line); +} + /* -- cleanup.c -- */ /* @@ -4329,7 +4438,7 @@ static int tree_descend_cursor(void) { /* * This is for mouse patch drawing under -xinerama or -blackout */ -static void blackout_nearby_tiles(x, y, dt) { +static void blackout_nearby_tiles(int x, int y, int dt) { int sx, sy, n, b; int tx = x/tile_x; int ty = y/tile_y; @@ -4676,7 +4785,7 @@ void set_colormap(void) { cmap = DefaultColormap(dpy, scr); ncells = CellsOfScreen(ScreenOfDisplay(dpy, scr)); - vis = visual; + vis = default_visual; if (subwin) { XWindowAttributes attr; @@ -4727,7 +4836,7 @@ void set_colormap(void) { /* * Kludge to make 8bpp TrueColor & DirectColor be like * the StaticColor map. The ncells = 8 is "8 per subfield" - * mentioned in xdpyinfo. Looks OK... likely fortuitously. + * mentioned in xdpyinfo. Looks OK... perhaps fortuitously. */ if (ncells == 8) { ncells = NCOLOR; @@ -4768,25 +4877,31 @@ void set_colormap(void) { /* * Experimental mode to force the visual of the window instead of querying - * it. Currently just used for testing or overriding some rare cases. - * Input string can be a decimal or 0x hex or something like TrueColor - * or TrueColor:24 to force a depth as well. + * it. Used for testing, overriding some rare cases (win2vnc), and for + * -overlay . Input string can be a decimal or 0x hex or something like + * TrueColor or TrueColor:24 to force a depth as well. + * + * visual_id and possibly visual_depth are set. */ -void set_visual(char *vstring) { - int vis, defdepth = DefaultDepth(dpy, scr); +void set_visual(char *str) { + int vis, vdepth, defdepth = DefaultDepth(dpy, scr); XVisualInfo vinfo; - char *p; + char *p, *vstring = strdup(str); if (! quiet) { fprintf(stderr, "set_visual: %s\n", vstring); } + /* set visual depth */ if ((p = strchr(vstring, ':')) != NULL) { visual_depth = atoi(p+1); *p = '\0'; + vdepth = visual_depth; } else { - visual_depth = defdepth; + vdepth = defdepth; } + + /* set visual id number */ if (strcmp(vstring, "StaticGray") == 0) { vis = StaticGray; } else if (strcmp(vstring, "GrayScale") == 0) { @@ -4810,8 +4925,10 @@ void set_visual(char *vstring) { exit(1); } visual_id = (VisualID) v_in; + free(vstring); return; } + if (XMatchVisualInfo(dpy, scr, visual_depth, vis, &vinfo)) { ; } else if (XMatchVisualInfo(dpy, scr, defdepth, vis, &vinfo)) { @@ -4820,6 +4937,9 @@ void set_visual(char *vstring) { fprintf(stderr, "could not find visual: %s\n", vstring); exit(1); } + free(vstring); + + /* set numerical visual id. */ visual_id = vinfo.visualid; } @@ -4837,7 +4957,7 @@ void nofb_hook(rfbClientPtr cl) { return; } rfbLog("framebuffer requested in -nofb mode by client %s\n", cl->host); - fb = XGetImage(dpy, window, 0, 0, dpy_x, dpy_y, AllPlanes, ZPixmap); + fb = XGetImage_wr(dpy, window, 0, 0, dpy_x, dpy_y, AllPlanes, ZPixmap); main_fb = fb->data; rfb_fb = main_fb; screen->frameBuffer = rfb_fb; @@ -5147,7 +5267,7 @@ void initialize_blackout (char *list) { blackr[blackouts].x2 = X; blackr[blackouts].y2 = Y; blackouts++; - if (blackouts >= 100) { + if (blackouts >= BLACKR_MAX) { rfbLog("too many blackouts: %d\n", blackouts); break; } @@ -5209,8 +5329,8 @@ void blackout_tiles(void) { /* union of blackouts */ for (b=0; b < blackouts; b++) { sraRegionPtr tmp_reg = (sraRegionPtr) - sraRgnCreateRect(blackr[b].x1, blackr[b].y1, - blackr[b].x2, blackr[b].y2); + sraRgnCreateRect(blackr[b].x1, + blackr[b].y1, blackr[b].x2, blackr[b].y2); sraRgnOr(black_reg, tmp_reg); sraRgnDestroy(tmp_reg); @@ -5260,7 +5380,7 @@ void blackout_tiles(void) { tile_blackout[n].cover = 1; } - if (++cnt >= 10) { + if (++cnt >= BO_MAX) { rfbLog("too many blackout rectangles " "for tile %d=%d,%d.\n", n, tx, ty); break; @@ -5376,7 +5496,7 @@ void initialize_xinerama (void) { /* * Fill the framebuffer with zero for the prescribed rectangle */ -void zero_fb(x1, y1, x2, y2) { +void zero_fb(int x1, int y1, int x2, int y2) { int pixelsize = bpp >> 3; int line, fill = 0; char *dst; @@ -5485,7 +5605,7 @@ static void set_fs_factor(int max) { } /* - * set up an XShm image + * set up an XShm image, or if not using shm just create the XImage. */ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, char *name) { @@ -5504,8 +5624,8 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, if (! using_shm) { /* we only need the XImage created */ - xim = XCreateImage(dpy, visual, depth, ZPixmap, 0, NULL, w, h, - BitmapPad(dpy), 0); + xim = XCreateImage_wr(dpy, default_visual, depth, ZPixmap, + 0, NULL, w, h, BitmapPad(dpy), 0); X_UNLOCK; @@ -5541,7 +5661,8 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h, return 1; } - xim = XShmCreateImage(dpy, visual, depth, ZPixmap, NULL, shm, w, h); + xim = XShmCreateImage(dpy, default_visual, depth, ZPixmap, NULL, + shm, w, h); if (xim == NULL) { rfbErr("XShmCreateImage(%s) failed.\n", name); @@ -6393,13 +6514,13 @@ static void copy_tiles(int tx, int ty, int nt) { /* read in the whole tile run at once: */ if ( using_shm && size_x == tile_x * nt && size_y == tile_y ) { /* general case: */ - XShmGetImage(dpy, window, tile_row[nt], x, y, AllPlanes); + XShmGetImage_wr(dpy, window, tile_row[nt], x, y, AllPlanes); } else { /* * No shm or near bottom/rhs edge case: * (but only if tile size does not divide screen size) */ - XGetSubImage(dpy, window, x, y, size_x, size_y, AllPlanes, + XGetSubImage_wr(dpy, window, x, y, size_x, size_y, AllPlanes, ZPixmap, tile_row[nt], 0, 0); } X_UNLOCK; @@ -6991,9 +7112,10 @@ void copy_screen(void) { /* screen may be too big for 1 shm area, so broken into fs_factor */ for (i=0; i < fs_factor; i++) { if (using_shm) { - XShmGetImage(dpy, window, fullscreen, 0, y, AllPlanes); + XShmGetImage_wr(dpy, window, fullscreen, 0, y, + AllPlanes); } else { - XGetSubImage(dpy, window, 0, y, fullscreen->width, + XGetSubImage_wr(dpy, window, 0, y, fullscreen->width, fullscreen->height, AllPlanes, ZPixmap, fullscreen, 0, 0); } @@ -7254,9 +7376,9 @@ static int scan_display(int ystart, int rescan) { /* grab the horizontal scanline from the display: */ X_LOCK; if (using_shm) { - XShmGetImage(dpy, window, scanline, 0, y, AllPlanes); + XShmGetImage_wr(dpy, window, scanline, 0, y, AllPlanes); } else { - XGetSubImage(dpy, window, 0, y, scanline->width, + XGetSubImage_wr(dpy, window, 0, y, scanline->width, scanline->height, AllPlanes, ZPixmap, scanline, 0, 0); } @@ -7816,9 +7938,37 @@ static void print_help(void) { "\n" "-id windowid Show the window corresponding to \"windowid\" not the\n" " entire display. Warning: bugs! new toplevels missed!...\n" +"-sid windowid As -id, but instead of using the window directly it\n" +" shifts a root view to it: shows saveUnders menus, etc,\n" +" although they will be clipped if they extend beyond\n" +" the window.\n" "-flashcmap In 8bpp indexed color, let the installed colormap flash\n" " as the pointer moves from window to window (slow).\n" -"-notruecolor Force 8bpp indexed color even if it looks like TrueColor.\n" +"-notruecolor For 8bpp displays, force indexed color (i.e. a colormap)\n" +" even if it looks like 8bpp TrueColor. (rare problem)\n" +"-overlay Handle multiple depth visuals on one screen, e.g. 8+24\n" +" and 24+8 overlay visuals (the 32 bits per pixel are\n" +" packed with 8 for PseudoColor and 24 for TrueColor).\n" +"\n" +" Currently -overlay only works on Solaris (it uses\n" +" XReadScreen(3X11)). There are still some problems with\n" +" surrounding-region painting for popup menus (but not\n" +" for the popup menu itself); a workaround is to disable\n" +" SaveUnders (pass -su to Xsun). Amusingly, if -overlay\n" +" is used with -mouse, the mouse cursor shape is correct.\n" +"\n" +" Use -overlay as a workaround for situations like these:\n" +" Some legacy applications require the default visual\n" +" be 8bpp (8+24), or they will use 8bpp PseudoColor even\n" +" when the default visual is depth 24 TrueColor (24+8).\n" +" In these cases colors in some windows will be messed\n" +" up in x11vnc unless -overlay is used.\n" +"\n" +" Under -overlay, performance will be somewhat degraded\n" +" due to the extra image transformations required.\n" +" For optimal performance do not use -overlay, but rather\n" +" configure the X server so that the default visual is\n" +" depth 24 TrueColor and have all apps use that visual.\n" "-visual n Experimental option: probably does not do what you\n" " think. It simply *forces* the visual used for the\n" " framebuffer; this may be a bad thing... It is useful for\n" @@ -7833,7 +7983,7 @@ static void print_help(void) { " and response may be slower. If \"fraction\" contains\n" " a decimal point \".\" it is taken as a floating point\n" " number, alternatively the notation \"m/n\" may be used\n" -" to denote fractions, e.g. -scale 2/3.\n" +" to denote fractions exactly, e.g. -scale 2/3.\n" "\n" " Scaling Options: can be added after \"fraction\" via\n" " \":\", to supply multiple \":\" options use commas.\n" @@ -8189,7 +8339,7 @@ static char *choose_title(char *display) { strncat(title, display, MAXN - strlen(title)); if (subwin) { char *name; - if (XFetchName(dpy, window, &name)) { + if (XFetchName(dpy, subwin, &name)) { strncat(title, " ", MAXN - strlen(title)); strncat(title, name, MAXN - strlen(title)); } @@ -8436,6 +8586,16 @@ int main(int argc, char* argv[]) { exit(1); } } + } else if (!strcmp(arg, "-sid")) { + rootshift = 1; + CHECK_ARGC + if (sscanf(argv[++i], "0x%x", &subwin) != 1) { + if (sscanf(argv[i], "%d", &subwin) != 1) { + fprintf(stderr, "bad -id arg: %s\n", + argv[i]); + exit(1); + } + } } else if (!strcmp(arg, "-scale")) { int m, n; char *p; @@ -8500,6 +8660,8 @@ int main(int argc, char* argv[]) { } else if (!strcmp(arg, "-visual")) { CHECK_ARGC visual_str = argv[++i]; + } else if (!strcmp(arg, "-overlay")) { + overlay = 1; } else if (!strcmp(arg, "-flashcmap")) { flash_cmap = 1; } else if (!strcmp(arg, "-notruecolor")) { @@ -8866,6 +9028,28 @@ int main(int argc, char* argv[]) { argv_vnc[argc_vnc++] = "604800000"; /* one week... */ } + if (overlay) { +#ifdef SOLARIS + using_shm = 0; + + if (flash_cmap && ! quiet) { + fprintf(stderr, "warning: -flashcmap may be " + "incompatible with -overlay\n"); + } + + if (show_mouse) { + show_mouse = 0; + overlay_mouse = 1; + } +#else + if (! quiet) { + fprintf(stderr, "disabling -overlay: currently only " + "available on Solaris Xsun.\n"); + } + overlay = 0; +#endif + } + /* check for OS with small shm limits */ if (using_shm && ! single_copytile) { if (limit_shm()) { @@ -8903,6 +9087,8 @@ int main(int argc, char* argv[]) { fprintf(stderr, "scaling: %d %.5f\n", scaling, scale_fac); fprintf(stderr, "visual: %s\n", visual_str ? visual_str : "null"); + fprintf(stderr, "overlay: %d\n", overlay); + fprintf(stderr, "ovl_mouse: %d\n", overlay_mouse); fprintf(stderr, "viewonly: %d\n", view_only); fprintf(stderr, "shared: %d\n", shared); fprintf(stderr, "conn_once: %d\n", connect_once); @@ -9025,14 +9211,15 @@ int main(int argc, char* argv[]) { } else { if (! quiet) fprintf(stderr, "Using default X display.\n"); } + + scr = DefaultScreen(dpy); + rootwin = RootWindow(dpy, scr); + if (! dt) { static char str[] = "-desktop"; argv_vnc[argc_vnc++] = str; argv_vnc[argc_vnc++] = choose_title(use_dpy); } - scr = DefaultScreen(dpy); - rootwin = RootWindow(dpy, scr); - /* check for XTEST */ if (! XTestQueryExtension(dpy, &ev, &er, &maj, &min)) { @@ -9060,9 +9247,38 @@ int main(int argc, char* argv[]) { } } + if (overlay) { + /* + * ideally we'd like to not have to cook up the visual variables + * but rather let it all come out of XReadScreen(), however + * there is no way to get a default visual out of it, so we + * pretend -visual TrueColor:NN was supplied with NN usually 24. + */ +#ifdef SOLARIS + char str[16]; + XImage *xi; + Window twin = subwin ? subwin : rootwin; + + xi = XReadScreen(dpy, twin, 0, 0, 8, 8, False); + + sprintf(str, "TrueColor:%d", xi->depth); + if (xi->depth != 24 && ! quiet) { + fprintf(stderr, "warning XReadScreen() image has " + "depth %d instead of 24.\n", xi->depth); + } + XDestroyImage(xi); + if (visual_str != NULL && ! quiet) { + fprintf(stderr, "warning: replacing '-visual %s' by " + "'%s' for use with -overlay\n", visual_str, str); + } + visual_str = strdup(str); +#endif + } + if (visual_str != NULL) { set_visual(visual_str); } + #ifdef LIBVNCSERVER_HAVE_XKEYBOARD /* check for XKEYBOARD */ if (use_xkb) { @@ -9083,7 +9299,8 @@ int main(int argc, char* argv[]) { dpy_y = DisplayHeight(dpy, scr); off_x = 0; off_y = 0; - visual = DefaultVisual(dpy, scr); + /* this may be overridden via visual_id below */ + default_visual = DefaultVisual(dpy, scr); } else { /* experiment to share just one window */ XWindowAttributes attr; @@ -9095,7 +9312,9 @@ int main(int argc, char* argv[]) { } dpy_x = attr.width; dpy_y = attr.height; - visual = attr.visual; + + /* this may be overridden via visual_id below */ + default_visual = attr.visual; /* show_mouse has some segv crashes as well */ if (show_root_cursor) { @@ -9108,17 +9327,18 @@ int main(int argc, char* argv[]) { set_offset(); } - /* initialize depth to reasonable value */ + /* initialize depth to reasonable value, visual_id may override */ depth = DefaultDepth(dpy, scr); - /* - * User asked for non-default visual, this is not working well but it - * does some useful things... What should it do in general? - */ if (visual_id) { - XVisualInfo vinfo_tmpl, *vinfo; int n; - + XVisualInfo vinfo_tmpl, *vinfo; + + /* + * we are in here from -visual or -overlay options + * visual_id and visual_depth were set in set_visual(). + */ + vinfo_tmpl.visualid = visual_id; vinfo = XGetVisualInfo(dpy, VisualIDMask, &vinfo_tmpl, &n); if (vinfo == NULL || n == 0) { @@ -9126,10 +9346,11 @@ int main(int argc, char* argv[]) { (int) visual_id); exit(1); } - visual = vinfo->visual; + default_visual = vinfo->visual; depth = vinfo->depth; if (visual_depth) { - depth = visual_depth; /* force it */ + /* force it from -visual FooColor:NN */ + depth = visual_depth; } if (! quiet) { fprintf(stderr, "vis id: 0x%x\n", @@ -9148,19 +9369,23 @@ int main(int argc, char* argv[]) { } - if (nofb || visual_id) { - fb = XCreateImage(dpy, visual, depth, ZPixmap, 0, NULL, - dpy_x, dpy_y, BitmapPad(dpy), 0); + if (nofb) { /* * For -nofb we do not allocate the framebuffer, so we * can save a few MB of memory. */ - if (! nofb) { - fb->data = (char *) malloc(fb->bytes_per_line * - fb->height); - } + fb = XCreateImage_wr(dpy, default_visual, depth, ZPixmap, + 0, NULL, dpy_x, dpy_y, BitmapPad(dpy), 0); + + } else if (visual_id) { + /* + * we need to call XCreateImage to supply the visual + */ + fb = XCreateImage_wr(dpy, default_visual, depth, ZPixmap, + 0, NULL, dpy_x, dpy_y, BitmapPad(dpy), 0); + fb->data = (char *) malloc(fb->bytes_per_line * fb->height); } else { - fb = XGetImage(dpy, window, 0, 0, dpy_x, dpy_y, AllPlanes, + fb = XGetImage_wr(dpy, window, 0, 0, dpy_x, dpy_y, AllPlanes, ZPixmap); if (! quiet) { fprintf(stderr, "Read initial data from X display into"