Commit 5993dd75 authored by runge's avatar runge

x11vnc: add -8to24 option for some multi-depth displays.

parent 60918e66
2006-01-14 Karl Runge <runge@karlrunge.com>
* x11vnc: add -8to24 option for some multi-depth displays.
2006-01-12 Karl Runge <runge@karlrunge.com> 2006-01-12 Karl Runge <runge@karlrunge.com>
* configure.ac: add switches for most X extensions. * configure.ac: add switches for most X extensions.
......
This diff is collapsed.
#ifndef _X11VNC_8TO24_H
#define _X11VNC_8TO24_H
/* -- 8to24.h -- */
extern int multivis_count;
extern void check_for_multivis(void);
extern void bpp8to24(int, int, int, int);
extern void mark_8bpp(void);
#endif /* _X11VNC_8TO24_H */
2006-01-14 Karl Runge <runge@karlrunge.com>
* x11vnc: add -8to24 option for some multi-depth displays (but use
of -overlay is preferred is supported).
2006-01-12 Karl Runge <runge@karlrunge.com> 2006-01-12 Karl Runge <runge@karlrunge.com>
* fix -DSMALL_FOOTPRINT=N builds. * fix -DSMALL_FOOTPRINT=N builds.
......
...@@ -13,7 +13,7 @@ endif ...@@ -13,7 +13,7 @@ endif
if HAVE_X if HAVE_X
bin_PROGRAMS=x11vnc bin_PROGRAMS=x11vnc
x11vnc_SOURCES = cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c options.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c user.c userinput.c util.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h options.h params.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h tkx11vnc.h user.h userinput.h util.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h x11vnc_SOURCES = 8to24.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c options.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c user.c userinput.c util.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h options.h params.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h tkx11vnc.h user.h userinput.h util.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h
INCLUDES=@X_CFLAGS@ INCLUDES=@X_CFLAGS@
x11vnc_LDADD=@X_LIBS@ $(LD_CYGIPC) $(LDADD) x11vnc_LDADD=@X_LIBS@ $(LD_CYGIPC) $(LDADD)
endif endif
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1512,7 +1512,7 @@ void check_connect_inputs(void) { ...@@ -1512,7 +1512,7 @@ void check_connect_inputs(void) {
} }
void check_gui_inputs(void) { void check_gui_inputs(void) {
int i, nmax = 0, n = 0, nfds; int i, gnmax = 0, n = 0, nfds;
int socks[ICON_MODE_SOCKS]; int socks[ICON_MODE_SOCKS];
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
...@@ -1522,8 +1522,8 @@ void check_gui_inputs(void) { ...@@ -1522,8 +1522,8 @@ void check_gui_inputs(void) {
for (i=0; i<ICON_MODE_SOCKS; i++) { for (i=0; i<ICON_MODE_SOCKS; i++) {
if (icon_mode_socks[i] >= 0) { if (icon_mode_socks[i] >= 0) {
socks[n++] = i; socks[n++] = i;
if (icon_mode_socks[i] > nmax) { if (icon_mode_socks[i] > gnmax) {
nmax = icon_mode_socks[i]; gnmax = icon_mode_socks[i];
} }
} }
} }
...@@ -1539,7 +1539,7 @@ void check_gui_inputs(void) { ...@@ -1539,7 +1539,7 @@ void check_gui_inputs(void) {
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
nfds = select(nmax+1, &fds, NULL, NULL, &tv); nfds = select(gnmax+1, &fds, NULL, NULL, &tv);
if (nfds <= 0) { if (nfds <= 0) {
return; return;
} }
......
...@@ -1783,4 +1783,3 @@ int check_x11_pointer(void) { ...@@ -1783,4 +1783,3 @@ int check_x11_pointer(void) {
return set_cursor(x, y, get_which_cursor()); return set_cursor(x, y, get_which_cursor());
} }
...@@ -147,6 +147,38 @@ void print_help(int mode) { ...@@ -147,6 +147,38 @@ void print_help(int mode) {
"-overlay_nocursor Sets -overlay, but does not try to draw the exact mouse\n" "-overlay_nocursor Sets -overlay, but does not try to draw the exact mouse\n"
" cursor shape using the overlay mechanism.\n" " cursor shape using the overlay mechanism.\n"
"\n" "\n"
"-8to24 If -overlay is not supported on your OS, and you have a\n"
" legacy 8bpp app that you want to view on a multi-depth\n"
" display with default depth 24 (and is 32 bpp), try\n"
" this option. This option may not work on all X servers\n"
" and hardware (tested on XFree86/Xorg mga driver).\n"
"\n"
" It enables a hack where x11vnc monitors windows within 3\n"
" levels from the root window. If it finds any that are\n"
" 8bpp it will apply a transformation for pixel data in\n"
" these regions where it extracts the 8bpp index color\n"
" value from bits 25-32 and maps them on to TrueColor\n"
" values and inserts them into bits 1-24 (i.e. overwrites\n"
" bits 1-24). This method appears to work, but may still\n"
" have bugs and note that it does hog resources. If there\n"
" are multiple 8bpp windows using different colormaps,\n"
" one may have to iconify all but one for the colors to\n"
" be correct.\n"
"\n"
" There may also be painting errors for clipping\n"
" and switching between windows of depths 8 and 24.\n"
" Heuristics are applied to try to minimize the painting\n"
" errors. One can also press 3 Alt_L's in a row to\n"
" refresh the screen if the error does not repair itself.\n"
" Also the option, say, -fixscreen V=3.0 may be use\n"
" to periodically refresh the screen (at the cost of\n"
" bandwidth).\n"
"\n"
" Note that -8to24 does not work on displays with 8bpp\n"
" default visual with depth 24 applications. The Xserver\n"
" -cc option can be used to switch the default depth on\n"
" multidepth setups.\n"
"\n"
"-scale fraction Scale the framebuffer by factor \"fraction\". Values\n" "-scale fraction Scale the framebuffer by factor \"fraction\". Values\n"
" less than 1 shrink the fb, larger ones expand it. Note:\n" " less than 1 shrink the fb, larger ones expand it. Note:\n"
" image may not be sharp and response may be slower.\n" " image may not be sharp and response may be slower.\n"
...@@ -1590,6 +1622,8 @@ void print_help(int mode) { ...@@ -1590,6 +1622,8 @@ void print_help(int mode) {
" overlay_cursor in -overlay mode, enable cursor drawing.\n" " overlay_cursor in -overlay mode, enable cursor drawing.\n"
" overlay_nocursor disable cursor drawing. same as\n" " overlay_nocursor disable cursor drawing. same as\n"
" nooverlay_cursor.\n" " nooverlay_cursor.\n"
" 8to24 enable -8to24 mode (if applicable).\n"
" no8to24 disable -8to24 mode.\n"
" visual:vis set -visual to \"vis\"\n" " visual:vis set -visual to \"vis\"\n"
" scale:frac set -scale to \"frac\"\n" " scale:frac set -scale to \"frac\"\n"
" scale_cursor:f set -scale_cursor to \"f\"\n" " scale_cursor:f set -scale_cursor to \"f\"\n"
...@@ -1849,10 +1883,10 @@ void print_help(int mode) { ...@@ -1849,10 +1883,10 @@ void print_help(int mode) {
" nowaitmapped clip flashcmap noflashcmap shiftcmap\n" " nowaitmapped clip flashcmap noflashcmap shiftcmap\n"
" truecolor notruecolor overlay nooverlay overlay_cursor\n" " truecolor notruecolor overlay nooverlay overlay_cursor\n"
" overlay_yescursor nooverlay_nocursor nooverlay_cursor\n" " overlay_yescursor nooverlay_nocursor nooverlay_cursor\n"
" nooverlay_yescursor overlay_nocursor visual scale\n" " nooverlay_yescursor overlay_nocursor 8to24 no8to24\n"
" scale_cursor viewonly noviewonly shared noshared\n" " visual scale scale_cursor viewonly noviewonly shared\n"
" forever noforever once timeout filexfer deny lock\n" " noshared forever noforever once timeout filexfer deny\n"
" nodeny unlock connect allowonce allow localhost\n" " lock nodeny unlock connect allowonce allow localhost\n"
" nolocalhost listen lookup nolookup accept afteraccept\n" " nolocalhost listen lookup nolookup accept afteraccept\n"
" gone shm noshm flipbyteorder noflipbyteorder onetile\n" " gone shm noshm flipbyteorder noflipbyteorder onetile\n"
" noonetile solid_color solid nosolid blackout xinerama\n" " noonetile solid_color solid nosolid blackout xinerama\n"
......
...@@ -88,6 +88,7 @@ int first_conn_timeout = 0; /* -timeout */ ...@@ -88,6 +88,7 @@ int first_conn_timeout = 0; /* -timeout */
int flash_cmap = 0; /* follow installed colormaps */ int flash_cmap = 0; /* follow installed colormaps */
int shift_cmap = 0; /* ncells < 256 and needs shift of pixel values */ int shift_cmap = 0; /* ncells < 256 and needs shift of pixel values */
int force_indexed_color = 0; /* whether to force indexed color for 8bpp */ int force_indexed_color = 0; /* whether to force indexed color for 8bpp */
int cmap8to24 = 0; /* -8to24 */
int launch_gui = 0; /* -gui */ int launch_gui = 0; /* -gui */
int use_modifier_tweak = 1; /* use the shift/altgr modifier tweak */ int use_modifier_tweak = 1; /* use the shift/altgr modifier tweak */
......
...@@ -63,6 +63,7 @@ extern int first_conn_timeout; ...@@ -63,6 +63,7 @@ extern int first_conn_timeout;
extern int flash_cmap; extern int flash_cmap;
extern int shift_cmap; extern int shift_cmap;
extern int force_indexed_color; extern int force_indexed_color;
extern int cmap8to24;
extern int launch_gui; extern int launch_gui;
extern int use_modifier_tweak; extern int use_modifier_tweak;
......
...@@ -979,6 +979,24 @@ char *process_remote_cmd(char *cmd, int stringonly) { ...@@ -979,6 +979,24 @@ char *process_remote_cmd(char *cmd, int stringonly) {
rfbLog(" -R cursor:... to re-enable any cursors.\n"); rfbLog(" -R cursor:... to re-enable any cursors.\n");
} }
} else if (!strcmp(p, "8to24")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, cmap8to24);
goto qry;
}
rfbLog("remote_cmd: turning on -8to24 mode.\n");
cmap8to24 = 1;
do_new_fb(0);
} else if (!strcmp(p, "no8to24")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !cmap8to24);
goto qry;
}
rfbLog("remote_cmd: turning off -8to24 mode.\n");
cmap8to24 = 0;
do_new_fb(0);
} else if (strstr(p, "visual") == p) { } else if (strstr(p, "visual") == p) {
COLON_CHECK("visual:") COLON_CHECK("visual:")
if (query) { if (query) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "xdamage.h" #include "xdamage.h"
#include "xrandr.h" #include "xrandr.h"
#include "win_utils.h" #include "win_utils.h"
#include "8to24.h"
#include "screen.h" #include "screen.h"
#include "pointer.h" #include "pointer.h"
#include "cleanup.h" #include "cleanup.h"
...@@ -1158,6 +1159,7 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp, ...@@ -1158,6 +1159,7 @@ void scale_rect(double factor, int blend, int interpolate, int Bpp,
} }
void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) { void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) {
char *src_fb = main_fb;
if (!screen || !rfb_fb || !main_fb) { if (!screen || !rfb_fb || !main_fb) {
return; return;
...@@ -1181,8 +1183,12 @@ void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) { ...@@ -1181,8 +1183,12 @@ void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) {
} }
} }
if (cmap8to24 && cmap8to24_fb) {
src_fb = cmap8to24_fb;
}
scale_rect(scale_fac, scaling_blend, scaling_interpolate, bpp/8, scale_rect(scale_fac, scaling_blend, scaling_interpolate, bpp/8,
main_fb, main_bytes_per_line, rfb_fb, rfb_bytes_per_line, src_fb, main_bytes_per_line, rfb_fb, rfb_bytes_per_line,
dpy_x, dpy_y, scaled_x, scaled_y, X1, Y1, X2, Y2, 1); dpy_x, dpy_y, scaled_x, scaled_y, X1, Y1, X2, Y2, 1);
} }
...@@ -1212,8 +1218,17 @@ void mark_rect_as_modified(int x1, int y1, int x2, int y2, int force) { ...@@ -1212,8 +1218,17 @@ void mark_rect_as_modified(int x1, int y1, int x2, int y2, int force) {
if (rfb_fb == main_fb || force) { if (rfb_fb == main_fb || force) {
rfbMarkRectAsModified(screen, x1, y1, x2, y2); rfbMarkRectAsModified(screen, x1, y1, x2, y2);
} else if (scaling) { return;
}
if (cmap8to24) {
bpp8to24(x1, y1, x2, y2);
}
if (scaling) {
scale_and_mark_rect(x1, y1, x2, y2); scale_and_mark_rect(x1, y1, x2, y2);
} else {
rfbMarkRectAsModified(screen, x1, y1, x2, y2);
} }
} }
...@@ -2416,6 +2431,9 @@ int scan_for_updates(int count_only) { ...@@ -2416,6 +2431,9 @@ int scan_for_updates(int count_only) {
/* check for changed colormap */ /* check for changed colormap */
set_colormap(0); set_colormap(0);
} }
if (cmap8to24 && scan_count % 4 == 0) {
check_for_multivis();
}
if (use_xdamage) { if (use_xdamage) {
/* first pass collecting DAMAGE events: */ /* first pass collecting DAMAGE events: */
collect_xdamage(scan_count, 0); collect_xdamage(scan_count, 0);
......
...@@ -544,8 +544,9 @@ static void nofb_hook(rfbClientPtr cl) { ...@@ -544,8 +544,9 @@ static void nofb_hook(rfbClientPtr cl) {
void do_new_fb(int reset_mem) { void do_new_fb(int reset_mem) {
XImage *fb; XImage *fb;
char *old_main = main_fb; char *old_main = main_fb;
char *old_rfb = rfb_fb; char *old_rfb = rfb_fb;
char *old_8to24 = cmap8to24_fb;
/* for threaded we really should lock libvncserver out. */ /* for threaded we really should lock libvncserver out. */
if (use_threads) { if (use_threads) {
...@@ -569,12 +570,15 @@ void do_new_fb(int reset_mem) { ...@@ -569,12 +570,15 @@ void do_new_fb(int reset_mem) {
initialize_polling_images(); initialize_polling_images();
} }
if (old_main != old_rfb && old_main) { if (old_main) {
free(old_main); free(old_main);
} }
if (old_rfb) { if (old_rfb && old_rfb != old_main) {
free(old_rfb); free(old_rfb);
} }
if (old_8to24 && old_8to24 != old_main && old_8to24 != old_rfb) {
free(old_8to24);
}
fb0 = fb; fb0 = fb;
} }
...@@ -1754,12 +1758,31 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -1754,12 +1758,31 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (nofb) { if (nofb) {
main_fb = NULL; main_fb = NULL;
rfb_fb = main_fb; rfb_fb = main_fb;
cmap8to24_fb = NULL;
screen->displayHook = nofb_hook; screen->displayHook = nofb_hook;
} else { } else {
main_fb = fb->data; main_fb = fb->data;
rfb_fb = NULL;
cmap8to24_fb = NULL;
if (cmap8to24) {
if (screen->serverFormat.bitsPerPixel != 32 ||
screen->serverFormat.depth != 24) {
if (!quiet) rfbLog("disabling -8to24 mode:"
" bpp != 32 or depth != 24\n");
cmap8to24 = 0;
}
}
if (cmap8to24) {
int n = main_bytes_per_line * fb->height;
cmap8to24_fb = (char *) malloc(n);
memset(cmap8to24_fb, 0, n);
}
if (scaling) { if (scaling) {
rfb_fb = (char *) malloc(rfb_bytes_per_line * height); rfb_fb = (char *) malloc(rfb_bytes_per_line * height);
memset(rfb_fb, 0, rfb_bytes_per_line * height); memset(rfb_fb, 0, rfb_bytes_per_line * height);
} else if (cmap8to24) {
rfb_fb = cmap8to24_fb;
} else { } else {
rfb_fb = main_fb; rfb_fb = main_fb;
} }
...@@ -1768,6 +1791,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -1768,6 +1791,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (!quiet) { if (!quiet) {
fprintf(stderr, " main_fb: %p\n", main_fb); fprintf(stderr, " main_fb: %p\n", main_fb);
fprintf(stderr, " rfb_fb: %p\n", rfb_fb); fprintf(stderr, " rfb_fb: %p\n", rfb_fb);
fprintf(stderr, " 8to24_fb: %p\n", cmap8to24_fb);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
...@@ -1780,7 +1804,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -1780,7 +1804,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
setup_cursors_and_push(); setup_cursors_and_push();
if (scaling) { if (scaling || cmap8to24) {
mark_rect_as_modified(0, 0, dpy_x, dpy_y, 0); mark_rect_as_modified(0, 0, dpy_x, dpy_y, 0);
} }
......
...@@ -121,6 +121,7 @@ Screen ...@@ -121,6 +121,7 @@ Screen
=GAL OverlayVisuals:: =GAL OverlayVisuals::
overlay overlay
overlay_nocursor overlay_nocursor
8to24
=GAL LOFF =GAL LOFF
=GAL 8-Bit-Color:: =GAL 8-Bit-Color::
flashcmap flashcmap
...@@ -1446,7 +1447,7 @@ proc parse_help {} { ...@@ -1446,7 +1447,7 @@ proc parse_help {} {
if {! $sawopts} { if {! $sawopts} {
continue; continue;
} }
if {[regexp {^-([A-z_][A-z_]*)} $line match name]} { if {[regexp {^-([0-9A-z_][0-9A-z_]*)} $line match name]} {
set allnames($name) 1; set allnames($name) 1;
if {"$curropt" != "no$name" && "no$curropt" != "$name"} { if {"$curropt" != "no$name" && "no$curropt" != "$name"} {
set curropt $name; set curropt $name;
...@@ -1525,7 +1526,7 @@ proc parse_remote_help {} { ...@@ -1525,7 +1526,7 @@ proc parse_remote_help {} {
if {! $sawopts} { if {! $sawopts} {
continue; continue;
} }
if {[regexp {^([A-z_][A-z_:]*)} $line match name]} { if {[regexp {^([0-9A-z_][0-9A-z_:]*)} $line match name]} {
regsub {:.*$} $name "" popt regsub {:.*$} $name "" popt
lappend possopts $popt lappend possopts $popt
if {"$curropt" != "no$name" && "no$curropt" != "$name"} { if {"$curropt" != "no$name" && "no$curropt" != "$name"} {
......
...@@ -132,6 +132,7 @@ char gui_code[] = ""; ...@@ -132,6 +132,7 @@ char gui_code[] = "";
" =GAL OverlayVisuals::\n" " =GAL OverlayVisuals::\n"
" overlay\n" " overlay\n"
" overlay_nocursor\n" " overlay_nocursor\n"
" 8to24\n"
" =GAL LOFF\n" " =GAL LOFF\n"
" =GAL 8-Bit-Color::\n" " =GAL 8-Bit-Color::\n"
" flashcmap\n" " flashcmap\n"
...@@ -1457,7 +1458,7 @@ char gui_code[] = ""; ...@@ -1457,7 +1458,7 @@ char gui_code[] = "";
" if {! $sawopts} {\n" " if {! $sawopts} {\n"
" continue;\n" " continue;\n"
" }\n" " }\n"
" if {[regexp {^-([A-z_][A-z_]*)} $line match name]} {\n" " if {[regexp {^-([0-9A-z_][0-9A-z_]*)} $line match name]} {\n"
" set allnames($name) 1;\n" " set allnames($name) 1;\n"
" if {\"$curropt\" != \"no$name\" && \"no$curropt\" != \"$name\"} {\n" " if {\"$curropt\" != \"no$name\" && \"no$curropt\" != \"$name\"} {\n"
" set curropt $name;\n" " set curropt $name;\n"
...@@ -1536,7 +1537,7 @@ char gui_code[] = ""; ...@@ -1536,7 +1537,7 @@ char gui_code[] = "";
" if {! $sawopts} {\n" " if {! $sawopts} {\n"
" continue;\n" " continue;\n"
" }\n" " }\n"
" if {[regexp {^([A-z_][A-z_:]*)} $line match name]} {\n" " if {[regexp {^([0-9A-z_][0-9A-z_:]*)} $line match name]} {\n"
" regsub {:.*$} $name \"\" popt\n" " regsub {:.*$} $name \"\" popt\n"
" lappend possopts $popt\n" " lappend possopts $popt\n"
" if {\"$curropt\" != \"no$name\" && \"no$curropt\" != \"$name\"} {\n" " if {\"$curropt\" != \"no$name\" && \"no$curropt\" != \"$name\"} {\n"
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "keyboard.h" #include "keyboard.h"
#include "solid.h" #include "solid.h"
#include "xrandr.h" #include "xrandr.h"
#include "8to24.h"
/* /*
* user input handling heuristics * user input handling heuristics
...@@ -241,7 +242,7 @@ WIREFRAME_PARMS "0xff,2,0,30+6+6+6,Alt,0.05+0.3+2.0,8" ...@@ -241,7 +242,7 @@ WIREFRAME_PARMS "0xff,2,0,30+6+6+6,Alt,0.05+0.3+2.0,8"
shade,linewidth,percent,T+B+L+R,mods,t1+t2+t3+t4 shade,linewidth,percent,T+B+L+R,mods,t1+t2+t3+t4
*/ */
#define LW_MAX 8 #define LW_MAX 8
static unsigned long wireframe_shade; static unsigned long wireframe_shade = 0xff;
static int wireframe_lw; static int wireframe_lw;
static double wireframe_frac; static double wireframe_frac;
static int wireframe_top, wireframe_bot, wireframe_left, wireframe_right; static int wireframe_top, wireframe_bot, wireframe_left, wireframe_right;
...@@ -3694,6 +3695,25 @@ if (db) fprintf(stderr, "send_copyrect: %d\n", sent_copyrect); ...@@ -3694,6 +3695,25 @@ if (db) fprintf(stderr, "send_copyrect: %d\n", sent_copyrect);
/* final push (for -nowirecopyrect) */ /* final push (for -nowirecopyrect) */
rfbPE(1000); rfbPE(1000);
wireframe_in_progress = 0; wireframe_in_progress = 0;
if (frame_changed && cmap8to24 && multivis_count) {
/* handle -8to24 tweak, mark area and check 8bpp... */
int x1, x2, y1, y2, f = 16;
x1 = nmin(box_x, orig_x) - f;
y1 = nmin(box_y, orig_y) - f;
x2 = nmax(box_x + box_w, orig_x + orig_w) + f;
y2 = nmax(box_y + box_h, orig_y + orig_h) + f;
x1 = nfix(x1, dpy_x);
x2 = nfix(x2, dpy_x);
y1 = nfix(y1, dpy_y);
y2 = nfix(y2, dpy_y);
if (0) fprintf(stderr, "wireframe_in_progress over: %d %d %d %d\n", x1, y1, x2, y2);
check_for_multivis();
if (1) mark_rect_as_modified(x1, y1, x2, y2, 0);
if (0) mark_rect_as_modified(0, 0, dpy_x, dpy_y, 0);
if (0) rfbPE(-1);
}
urgent_update = 1; urgent_update = 1;
if (use_xdamage) { if (use_xdamage) {
/* DAMAGE can queue ~1000 rectangles for a move */ /* DAMAGE can queue ~1000 rectangles for a move */
......
...@@ -14,6 +14,8 @@ MUTEX(scrollMutex); ...@@ -14,6 +14,8 @@ MUTEX(scrollMutex);
#endif #endif
int nfix(int i, int n); int nfix(int i, int n);
int nmin(int n, int m);
int nmax(int n, int m);
int nabs(int n); int nabs(int n);
double dabs(double x); double dabs(double x);
void lowercase(char *str); void lowercase(char *str);
...@@ -42,6 +44,9 @@ double rfac(void); ...@@ -42,6 +44,9 @@ double rfac(void);
void rfbPE(long usec); void rfbPE(long usec);
void rfbCFD(long usec); void rfbCFD(long usec);
double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
int X2, int Y2);
/* /*
* routine to keep 0 <= i < n, should use in more places... * routine to keep 0 <= i < n, should use in more places...
...@@ -55,6 +60,22 @@ int nfix(int i, int n) { ...@@ -55,6 +60,22 @@ int nfix(int i, int n) {
return i; return i;
} }
int nmin(int n, int m) {
if (n < m) {
return n;
} else {
return m;
}
}
int nmax(int n, int m) {
if (n > m) {
return n;
} else {
return m;
}
}
int nabs(int n) { int nabs(int n) {
if (n < 0) { if (n < 0) {
return -n; return -n;
...@@ -394,4 +415,39 @@ void rfbCFD(long usec) { ...@@ -394,4 +415,39 @@ void rfbCFD(long usec) {
} }
} }
double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
int X2, int Y2) {
double a, A, o;
sraRegionPtr r, R, overlap;
sraRectangleIterator *iter;
sraRect rt;
a = nabs((x2 - x1) * (y2 - y1));
A = nabs((X2 - X1) * (Y2 - Y1));
r = sraRgnCreateRect(x1, y1, x2, y2);
R = sraRgnCreateRect(X1, Y1, X2, Y2);
overlap = sraRgnCreateRect(x1, y1, x2, y2);
sraRgnAnd(overlap, R);
o = 0.0;
iter = sraRgnGetIterator(overlap);
while (sraRgnIteratorNext(iter, &rt)) {
o += nabs( (rt.x2 - rt.x1) * (rt.y2 - rt.y1) );
}
sraRgnReleaseIterator(iter);
sraRgnDestroy(r);
sraRgnDestroy(R);
sraRgnDestroy(overlap);
if (a < A) {
o = o/a;
} else {
o = o/A;
}
return o;
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
/* -- util.h -- */ /* -- util.h -- */
extern int nfix(int i, int n); extern int nfix(int i, int n);
extern int nmin(int n, int m);
extern int nmax(int n, int m);
extern int nabs(int n); extern int nabs(int n);
extern double dabs(double x); extern double dabs(double x);
extern void lowercase(char *str); extern void lowercase(char *str);
...@@ -31,6 +33,8 @@ extern double rfac(void); ...@@ -31,6 +33,8 @@ extern double rfac(void);
extern void rfbPE(long usec); extern void rfbPE(long usec);
extern void rfbCFD(long usec); extern void rfbCFD(long usec);
extern double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
int X2, int Y2);
#define NONUL(x) ((x) ? (x) : "") #define NONUL(x) ((x) ? (x) : "")
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "January 2006" "x11vnc " "User Commands" .TH X11VNC "1" "January 2006" "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.8, lastmod: 2006-01-11 version: 0.8, lastmod: 2006-01-14
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -177,6 +177,40 @@ visual (e.g. some apps have \fB-use24\fR or \fB-visual\fR options). ...@@ -177,6 +177,40 @@ visual (e.g. some apps have \fB-use24\fR or \fB-visual\fR options).
Sets \fB-overlay,\fR but does not try to draw the exact mouse Sets \fB-overlay,\fR but does not try to draw the exact mouse
cursor shape using the overlay mechanism. cursor shape using the overlay mechanism.
.PP .PP
\fB-8to24\fR
.IP
If \fB-overlay\fR is not supported on your OS, and you have a
legacy 8bpp app that you want to view on a multi-depth
display with default depth 24 (and is 32 bpp), try
this option. This option may not work on all X servers
and hardware (tested on XFree86/Xorg mga driver).
.IP
It enables a hack where x11vnc monitors windows within 3
levels from the root window. If it finds any that are
8bpp it will apply a transformation for pixel data in
these regions where it extracts the 8bpp index color
value from bits 25-32 and maps them on to TrueColor
values and inserts them into bits 1-24 (i.e. overwrites
bits 1-24). This method appears to work, but may still
have bugs and note that it does hog resources. If there
are multiple 8bpp windows using different colormaps,
one may have to iconify all but one for the colors to
be correct.
.IP
There may also be painting errors for clipping
and switching between windows of depths 8 and 24.
Heuristics are applied to try to minimize the painting
errors. One can also press 3 Alt_L's in a row to
refresh the screen if the error does not repair itself.
Also the option, say, \fB-fixscreen\fR V=3.0 may be use
to periodically refresh the screen (at the cost of
bandwidth).
.IP
Note that \fB-8to24\fR does not work on displays with 8bpp
default visual with depth 24 applications. The Xserver
\fB-cc\fR option can be used to switch the default depth on
multidepth setups.
.PP
\fB-scale\fR \fIfraction\fR \fB-scale\fR \fIfraction\fR
.IP .IP
Scale the framebuffer by factor \fIfraction\fR. Values Scale the framebuffer by factor \fIfraction\fR. Values
...@@ -1979,6 +2013,10 @@ overlay_cursor in \fB-overlay\fR mode, enable cursor drawing. ...@@ -1979,6 +2013,10 @@ overlay_cursor in \fB-overlay\fR mode, enable cursor drawing.
overlay_nocursor disable cursor drawing. same as overlay_nocursor disable cursor drawing. same as
nooverlay_cursor. nooverlay_cursor.
.IP .IP
8to24 enable \fB-8to24\fR mode (if applicable).
.IP
no8to24 disable \fB-8to24\fR mode.
.IP
visual:vis set \fB-visual\fR to "vis" visual:vis set \fB-visual\fR to "vis"
.IP .IP
scale:frac set \fB-scale\fR to "frac" scale:frac set \fB-scale\fR to "frac"
...@@ -2417,10 +2455,10 @@ refresh reset close disconnect id sid waitmapped ...@@ -2417,10 +2455,10 @@ refresh reset close disconnect id sid waitmapped
nowaitmapped clip flashcmap noflashcmap shiftcmap nowaitmapped clip flashcmap noflashcmap shiftcmap
truecolor notruecolor overlay nooverlay overlay_cursor truecolor notruecolor overlay nooverlay overlay_cursor
overlay_yescursor nooverlay_nocursor nooverlay_cursor overlay_yescursor nooverlay_nocursor nooverlay_cursor
nooverlay_yescursor overlay_nocursor visual scale nooverlay_yescursor overlay_nocursor 8to24 no8to24
scale_cursor viewonly noviewonly shared noshared visual scale scale_cursor viewonly noviewonly shared
forever noforever once timeout filexfer deny lock noshared forever noforever once timeout filexfer deny
nodeny unlock connect allowonce allow localhost lock nodeny unlock connect allowonce allow localhost
nolocalhost listen lookup nolookup accept afteraccept nolocalhost listen lookup nolookup accept afteraccept
gone shm noshm flipbyteorder noflipbyteorder onetile gone shm noshm flipbyteorder noflipbyteorder onetile
noonetile solid_color solid nosolid blackout xinerama noonetile solid_color solid nosolid blackout xinerama
......
...@@ -907,6 +907,7 @@ static void print_settings(int try_http, int bg, char *gui_str) { ...@@ -907,6 +907,7 @@ static void print_settings(int try_http, int bg, char *gui_str) {
fprintf(stderr, " flashcmap: %d\n", flash_cmap); fprintf(stderr, " flashcmap: %d\n", flash_cmap);
fprintf(stderr, " shiftcmap: %d\n", shift_cmap); fprintf(stderr, " shiftcmap: %d\n", shift_cmap);
fprintf(stderr, " force_idx: %d\n", force_indexed_color); fprintf(stderr, " force_idx: %d\n", force_indexed_color);
fprintf(stderr, " cmap8to24: %d\n", cmap8to24);
fprintf(stderr, " visual: %s\n", visual_str ? visual_str fprintf(stderr, " visual: %s\n", visual_str ? visual_str
: "null"); : "null");
fprintf(stderr, " overlay: %d\n", overlay); fprintf(stderr, " overlay: %d\n", overlay);
...@@ -1270,6 +1271,8 @@ int main(int argc, char* argv[]) { ...@@ -1270,6 +1271,8 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-overlay_yescursor")) { } else if (!strcmp(arg, "-overlay_yescursor")) {
overlay = 1; overlay = 1;
overlay_cursor = 2; overlay_cursor = 2;
} else if (!strcmp(arg, "-8to24")) {
cmap8to24 = 1;
} else if (!strcmp(arg, "-visual")) { } else if (!strcmp(arg, "-visual")) {
CHECK_ARGC CHECK_ARGC
visual_str = strdup(argv[++i]); visual_str = strdup(argv[++i]);
......
...@@ -315,6 +315,7 @@ extern char *main_fb; /* our copy of the X11 fb */ ...@@ -315,6 +315,7 @@ extern char *main_fb; /* our copy of the X11 fb */
extern char *rfb_fb; /* same as main_fb unless transformation */ extern char *rfb_fb; /* same as main_fb unless transformation */
extern char *fake_fb; /* used under -padgeom */ extern char *fake_fb; /* used under -padgeom */
extern char *snap_fb; /* used under -snapfb */ extern char *snap_fb; /* used under -snapfb */
extern char *cmap8to24_fb; /* used under -8to24 */
extern char *raw_fb; extern char *raw_fb;
extern char *raw_fb_addr; extern char *raw_fb_addr;
extern int raw_fb_offset; extern int raw_fb_offset;
......
...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; ...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8 lastmod: 2006-01-11"; char lastmod[] = "0.8 lastmod: 2006-01-14";
/* X display info */ /* X display info */
...@@ -57,6 +57,7 @@ char *main_fb = NULL; /* our copy of the X11 fb */ ...@@ -57,6 +57,7 @@ char *main_fb = NULL; /* our copy of the X11 fb */
char *rfb_fb = NULL; /* same as main_fb unless transformation */ char *rfb_fb = NULL; /* same as main_fb unless transformation */
char *fake_fb = NULL; /* used under -padgeom */ char *fake_fb = NULL; /* used under -padgeom */
char *snap_fb = NULL; /* used under -snapfb */ char *snap_fb = NULL; /* used under -snapfb */
char *cmap8to24_fb = NULL; /* used under -8to24 */
char *raw_fb = NULL; char *raw_fb = NULL;
char *raw_fb_addr = NULL; char *raw_fb_addr = NULL;
int raw_fb_offset = 0; int raw_fb_offset = 0;
......
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