x11vnc: -8to24 opts, use XGetSubImage. fix -threads deadlocks and -rawfb crash

pull/1/head
runge 19 years ago
parent 17e6b6a2bf
commit 1967913e95

@ -14,6 +14,7 @@ void mark_8bpp(void);
static void set_root_cmap(void); static void set_root_cmap(void);
static void check_pointer_in_depth24(void); static void check_pointer_in_depth24(void);
static void parse_cmap8to24(void);
static int check_depth(Window win, Window top, int doall); static int check_depth(Window win, Window top, int doall);
static int check_depth_win(Window win, Window top, XWindowAttributes attr); static int check_depth_win(Window win, Window top, XWindowAttributes attr);
static int get_8pp_region(sraRegionPtr region8bpp, sraRegionPtr rect, static int get_8pp_region(sraRegionPtr region8bpp, sraRegionPtr rect,
@ -44,10 +45,12 @@ static void set_root_cmap(void) {
root_cmap = 0; root_cmap = 0;
} }
if (! root_cmap) { if (! root_cmap) {
X_LOCK;
if (valid_window(window, &attr, 1)) { if (valid_window(window, &attr, 1)) {
last_set = now; last_set = now;
root_cmap = attr.colormap; root_cmap = attr.colormap;
} }
X_UNLOCK;
} }
} }
@ -58,6 +61,7 @@ static window8bpp_t windows_8bpp[MAX_8BPP_WINDOWS];
static int db24 = 0; static int db24 = 0;
static int xgetimage_8to24 = 0; static int xgetimage_8to24 = 0;
static int do_hibits = 0; static int do_hibits = 0;
static double poll_8to24_delay = 0.0;
static void check_pointer_in_depth24(void) { static void check_pointer_in_depth24(void) {
int tries = 0, in_24 = 0; int tries = 0, in_24 = 0;
@ -98,13 +102,50 @@ if (db24 > 1) fprintf(stderr, "check_pointer_in_depth24 %d %d %d %d\n", x1, y1,
} }
} }
static void parse_cmap8to24(void) {
if (cmap8to24_str) {
char *p, *str = strdup(cmap8to24_str);
p = strtok(str, ",");
db24 = 0;
xgetimage_8to24 = 0;
do_hibits = 0;
while (p) {
if (strstr(p, "dbg=") == p) {
db24 = atoi(p + strlen("dbg="));
} else if (!strcmp(p, "highbits")) {
do_hibits = 1;
} else if (!strcmp(p, "getimage")) {
xgetimage_8to24 = 1;
}
p = strtok(NULL, ",");
}
free(str);
} else {
if (getenv("DEBUG_8TO24") != NULL) {
db24 = atoi(getenv("DEBUG_8TO24"));
}
if (getenv("XGETIMAGE_8TO24") != NULL) {
xgetimage_8to24 = 1;
}
if (getenv("HIGHBITS_8TO24") != NULL) {
do_hibits = 1;
}
}
}
void poll_8bpp(void) {
}
void check_for_multivis(void) { void check_for_multivis(void) {
XWindowAttributes attr; XWindowAttributes attr;
int doall = 0; int doall = 0;
int k, i, cnt, diff; int k, i, cnt, diff;
static int first = 1; static int first = 1;
static double last_parse = 0.0;
static double last_update = 0.0; static double last_update = 0.0;
static double last_clear = 0.0; static double last_clear = 0.0;
static double last_poll = 0.0;
double now = dnow(); double now = dnow();
static Window *stack_old = NULL; static Window *stack_old = NULL;
static int stack_old_len = 0; static int stack_old_len = 0;
@ -119,18 +160,15 @@ void check_for_multivis(void) {
windows_8bpp[i].cmap = (Colormap) 0; windows_8bpp[i].cmap = (Colormap) 0;
windows_8bpp[i].fetched = 0; windows_8bpp[i].fetched = 0;
} }
if (getenv("DEBUG_8TO24") != NULL) {
db24 = atoi(getenv("DEBUG_8TO24"));
}
if (getenv("XGETIMAGE_8TO24") != NULL) {
xgetimage_8to24 = 1;
}
if (getenv("HIGHBITS_8TO24") != NULL) {
do_hibits = 1;
}
first = 0; first = 0;
doall = 1; /* fetch everything first time */ doall = 1; /* fetch everything first time */
} }
if (now > last_parse + 0.75) {
last_parse = now;
parse_cmap8to24();
}
set_root_cmap(); set_root_cmap();
/* /*
@ -178,6 +216,10 @@ void check_for_multivis(void) {
} }
} }
if (poll_8to24_delay > 0.0 && now > last_poll + poll_8to24_delay) {
last_poll = now;
}
/* /*
* if there are 8bpp visible and a stacking order change * if there are 8bpp visible and a stacking order change
* refresh vnc with coverage of the 8bpp regions: * refresh vnc with coverage of the 8bpp regions:
@ -410,7 +452,9 @@ if (db24 > 1) fprintf(stderr, "multivis: STORE 0x%lx j: %3d ms: %d dep=%d\n", wi
windows_8bpp[j].h = attr.height; windows_8bpp[j].h = attr.height;
/* translate x y to be WRT the root window (not parent) */ /* translate x y to be WRT the root window (not parent) */
X_LOCK;
xtranslate(win, window, 0, 0, &x, &y, &w, 1); xtranslate(win, window, 0, 0, &x, &y, &w, 1);
X_UNLOCK;
windows_8bpp[j].x = x; windows_8bpp[j].x = x;
windows_8bpp[j].y = y; windows_8bpp[j].y = y;
@ -670,7 +714,7 @@ static void do_8bpp_region(sraRect rect) {
int ps, pixelsize = bpp/8; int ps, pixelsize = bpp/8;
int do_getimage = xgetimage_8to24; int do_getimage = xgetimage_8to24;
int line, n_off, j, h, w; int line, n_off, j, h, w, vw;
unsigned int hi, idx; unsigned int hi, idx;
XWindowAttributes attr; XWindowAttributes attr;
XErrorHandler old_handler = NULL; XErrorHandler old_handler = NULL;
@ -770,9 +814,18 @@ if (db24 > 1) fprintf(stderr, "transform %d %d %d %d\n", rect.x1, rect.y1, rect.
} }
} }
if (do_getimage && valid_window(best_win, &attr, 1)) { if (do_getimage) {
XImage *xi; X_LOCK;
vw = valid_window(best_win, &attr, 1);
X_UNLOCK;
}
if (do_getimage && vw) {
static XImage *xi_8 = NULL;
static XImage *xi_24 = NULL;
XImage *xi = NULL;
Window c; Window c;
char *d;
unsigned int wu, hu; unsigned int wu, hu;
int xo, yo; int xo, yo;
@ -792,11 +845,44 @@ if (db24 > 1) fprintf(stderr, "skipping due to potential bad match...\n");
return; return;
} }
#define GETSUBIMAGE
#ifdef GETSUBIMAGE
if (best_depth == 8) {
if (xi_8 == NULL || xi_8->width != dpy_x || xi_8->height != dpy_y) {
if (xi_8) {
XDestroyImage(xi_8);
}
d = (char *) malloc(dpy_x * dpy_y * attr.depth/8);
xi_8 = XCreateImage(dpy, attr.visual, attr.depth,
ZPixmap, 0, d, dpy_x, dpy_y, 8, 0);
if (db24) fprintf(stderr, "xi_8: %p\n", (void *) xi_8);
}
xi = xi_8;
} else if (best_depth == 24) {
if (xi_24 == NULL || xi_24->width != dpy_x || xi_24->height != dpy_y) {
if (xi_24) {
XDestroyImage(xi_24);
}
d = (char *) malloc(dpy_x * dpy_y * attr.depth/8);
xi_24 = XCreateImage(dpy, attr.visual, attr.depth,
ZPixmap, 0, d, dpy_x, dpy_y, 8, 0);
if (db24) fprintf(stderr, "xi_24: %p\n", (void *) xi_24);
}
xi = xi_24;
}
#endif
trapped_xerror = 0; trapped_xerror = 0;
old_handler = XSetErrorHandler(trap_xerror); old_handler = XSetErrorHandler(trap_xerror);
/* FIXME: XGetSubImage? */ /* FIXME: XGetSubImage? */
#ifndef GETSUBIMAGE
xi = XGetImage(dpy, best_win, xo, yo, wu, hu, xi = XGetImage(dpy, best_win, xo, yo, wu, hu,
AllPlanes, ZPixmap); AllPlanes, ZPixmap);
#else
XGetSubImage(dpy, best_win, xo, yo, wu, hu, AllPlanes,
ZPixmap, xi, 0, 0);
#endif
XSetErrorHandler(old_handler); XSetErrorHandler(old_handler);
X_UNLOCK; X_UNLOCK;
@ -810,9 +896,11 @@ if (db24 > 1) fprintf(stderr, "xi: 0x%p %d %d %d %d -- %d %d\n", (void *)xi, xo
trapped_xerror = 0; trapped_xerror = 0;
if (xi->depth != 8 && xi->depth != 24) { if (xi->depth != 8 && xi->depth != 24) {
#ifndef GETSUBIMAGE
X_LOCK; X_LOCK;
XDestroyImage(xi); XDestroyImage(xi);
X_UNLOCK; X_UNLOCK;
#endif
if (db24) fprintf(stderr, "xi: wrong depth: %d\n", xi->depth); if (db24) fprintf(stderr, "xi: wrong depth: %d\n", xi->depth);
return; return;
} }
@ -835,9 +923,9 @@ if (db24) fprintf(stderr, "xi: wrong depth: %d\n", xi->depth);
/* line by line ... */ /* line by line ... */
for (line = 0; line < xi->height; line++) { for (line = 0; line < h; line++) {
/* pixel by pixel... */ /* pixel by pixel... */
for (j = 0; j < xi->width; j++) { for (j = 0; j < w; j++) {
uc = (unsigned char *) (src + ps1 * j); uc = (unsigned char *) (src + ps1 * j);
ui = (unsigned int *) (dst + ps2 * j); ui = (unsigned int *) (dst + ps2 * j);
@ -861,16 +949,18 @@ if (db24) fprintf(stderr, "xi: wrong depth: %d\n", xi->depth);
src = xi->data; src = xi->data;
dst = cmap8to24_fb + fac * n_off; dst = cmap8to24_fb + fac * n_off;
for (line = 0; line < xi->height; line++) { for (line = 0; line < h; line++) {
memcpy(dst, src, w * ps1); memcpy(dst, src, w * ps1);
src += xi->bytes_per_line; src += xi->bytes_per_line;
dst += main_bytes_per_line * fac; dst += main_bytes_per_line * fac;
} }
} }
#ifndef GETSUBIMAGE
X_LOCK; X_LOCK;
XDestroyImage(xi); XDestroyImage(xi);
X_UNLOCK; X_UNLOCK;
#endif
} else if (! do_getimage) { } else if (! do_getimage) {
/* normal mode. */ /* normal mode. */

@ -1,3 +1,7 @@
2006-01-21 Karl Runge <runge@karlrunge.com>
* x11vnc: -8to24 opts, use XGetSubImage. fix -threads deadlocks and
-rawfb crash.
2006-01-18 Karl Runge <runge@karlrunge.com> 2006-01-18 Karl Runge <runge@karlrunge.com>
* x11vnc: -8to24 now works on default depth 8 screens. * x11vnc: -8to24 now works on default depth 8 screens.

@ -1,5 +1,5 @@
x11vnc README file Date: Wed Jan 18 22:06:12 EST 2006 x11vnc README file Date: Sat Jan 21 20:25:28 EST 2006
The following information is taken from these URLs: The following information is taken from these URLs:
@ -4898,7 +4898,7 @@ x11vnc: a VNC server for real X displays
Here are all of x11vnc command line options: Here are all of x11vnc command line options:
% x11vnc -opts (see below for -help long descriptions) % x11vnc -opts (see below for -help long descriptions)
x11vnc: allow VNC connections to real X11 displays. 0.8 lastmod: 2006-01-18 x11vnc: allow VNC connections to real X11 displays. 0.8 lastmod: 2006-01-21
x11vnc options: x11vnc options:
-display disp -auth file -display disp -auth file
@ -4906,7 +4906,7 @@ x11vnc options:
-clip WxH+X+Y -flashcmap -clip WxH+X+Y -flashcmap
-shiftcmap n -notruecolor -shiftcmap n -notruecolor
-visual n -overlay -visual n -overlay
-overlay_nocursor -8to24 -overlay_nocursor -8to24 [opts]
-scale fraction -scale_cursor frac -scale fraction -scale_cursor frac
-viewonly -shared -viewonly -shared
-once -forever -once -forever
@ -5009,7 +5009,7 @@ libvncserver-tight-extension options:
% x11vnc -help % x11vnc -help
x11vnc: allow VNC connections to real X11 displays. 0.8 lastmod: 2006-01-18 x11vnc: allow VNC connections to real X11 displays. 0.8 lastmod: 2006-01-21
Typical usage is: Typical usage is:
@ -5140,25 +5140,24 @@ Options:
-overlay_nocursor Sets -overlay, but does not try to draw the exact mouse -overlay_nocursor Sets -overlay, but does not try to draw the exact mouse
cursor shape using the overlay mechanism. cursor shape using the overlay mechanism.
-8to24 If -overlay is not supported on your OS, and you have a -8to24 [opts] Try this option if -overlay is not supported on your
legacy 8bpp app that you want to view on a multi-depth OS, and you have a legacy 8bpp app that you want to
display with default depth 24 (and is 32 bpp), try view on a multi-depth display with default depth 24
this option. It will also work for a default depth 8 (and is 32 bpp) or have default depth 8 display with
display with depth 24 overlay windows. This option depth 24 overlay windows for some apps. This option
may not work on all X servers and hardware (tested on may not work on all X servers and hardware (tested on
XFree86/Xorg mga driver). XFree86/Xorg mga driver). The "opts" string is not
required and is described below.
It enables a hack where x11vnc monitors windows within 3
levels from the root window. If it finds any that are This mode enables a hack where x11vnc monitors windows
8bpp it will apply a transformation for pixel data in within 3 levels from the root window. If it finds
these regions where it extracts the 8bpp index color any that are 8bpp it will apply a transformation for
value from bits 25-32 and maps them on to TrueColor pixel data in these regions where it extracts the 8bpp
values and inserts them into bits 1-24 (i.e. overwrites index color value from bits 25-32 and maps them on
bits 1-24). to TrueColor values and inserts them into bits 1-24
(i.e. overwrites bits 1-24). Whereas for default
For default depth 8 displays, everything is tranformed depth 8 displays, everything is tranformed to 32bpp
to 32bpp (and is potentially a improvement over (and is potentially a improvement over -flashcmap).
-flashcmap).
These schemes appear to work, but may still have These schemes appear to work, but may still have
bugs and note that they do hog resources. If there bugs and note that they do hog resources. If there
@ -5175,17 +5174,24 @@ Options:
to periodically refresh the screen (at the cost of to periodically refresh the screen (at the cost of
bandwidth). bandwidth).
Debugging for this mode can be enabled by setting the The [opts] string can contain the following settings.
environment variable DEBUG_8TO24 to 1, 2, or 3. Multiple settings are separated by commas.
For when there are still color problems, enable an even
more experimental mode via the option "getimage".
This enables a scheme were XGetImage() is used to
retrieve the 8bpp data instead of assuming that data
is in bits 25-32. This mode is significantly slower
than the above mode. For the default depth 8 case,
XGetImage() is always used to access depth 24 pixel
data.
For default depth 8 displays, setting option
"highbits" may give a speedup for transforming 8bpp
pixel data.
If there are problems, to enable an even more Debugging for this mode can be enabled by setting
experimental mode, set the environment variable "dbg=1", "dbg=2", or "dbg=3"
XGETIMAGE_8TO24=1 before starting x11vnc. This enables
a scheme were XGetImage() is used to retrieve the 8bpp
data instead of assuming that data is in bits 25-32.
This mode is significantly slower than the above mode.
For the default depth 8 case, XGetImage() is always
used to access depth 24 pixel data.
-scale fraction Scale the framebuffer by factor "fraction". Values -scale fraction Scale the framebuffer by factor "fraction". Values
less than 1 shrink the fb, larger ones expand it. Note: less than 1 shrink the fb, larger ones expand it. Note:
@ -6623,6 +6629,7 @@ n
nooverlay_cursor. nooverlay_cursor.
8to24 enable -8to24 mode (if applicable). 8to24 enable -8to24 mode (if applicable).
no8to24 disable -8to24 mode. no8to24 disable -8to24 mode.
8to24_opts:str set the -8to24 opts to "str".
visual:vis set -visual to "vis" visual:vis set -visual to "vis"
scale:frac set -scale to "frac" scale:frac set -scale to "frac"
scale_cursor:f set -scale_cursor to "f" scale_cursor:f set -scale_cursor to "f"
@ -6877,22 +6884,22 @@ n
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 8to24 no8to24 nooverlay_yescursor overlay_nocursor 8to24 no8to24
visual scale scale_cursor viewonly noviewonly shared 8to24_opts visual scale scale_cursor viewonly
noshared forever noforever once timeout filexfer deny noviewonly shared noshared forever noforever once
lock nodeny unlock connect allowonce allow localhost timeout filexfer deny lock nodeny unlock connect
nolocalhost listen lookup nolookup accept afteraccept allowonce allow localhost nolocalhost listen lookup
gone shm noshm flipbyteorder noflipbyteorder onetile nolookup accept afteraccept gone shm noshm flipbyteorder
noonetile solid_color solid nosolid blackout xinerama noflipbyteorder onetile noonetile solid_color solid
noxinerama xtrap noxtrap xrandr noxrandr xrandr_mode nosolid blackout xinerama noxinerama xtrap noxtrap
padgeom quiet q noquiet modtweak nomodtweak xkb xrandr noxrandr xrandr_mode padgeom quiet q noquiet
noxkb skip_keycodes sloppy_keys nosloppy_keys modtweak nomodtweak xkb noxkb skip_keycodes sloppy_keys
skip_dups noskip_dups add_keysyms noadd_keysyms nosloppy_keys skip_dups noskip_dups add_keysyms
clear_mods noclear_mods clear_keys noclear_keys noadd_keysyms clear_mods noclear_mods clear_keys
remap repeat norepeat fb nofb bell nobell sel nosel noclear_keys remap repeat norepeat fb nofb bell
primary noprimary seldir cursorshape nocursorshape nobell sel nosel primary noprimary seldir cursorshape
cursorpos nocursorpos cursor show_cursor noshow_cursor nocursorshape cursorpos nocursorpos cursor show_cursor
nocursor arrow xfixes noxfixes xdamage noxdamage noshow_cursor nocursor arrow xfixes noxfixes xdamage
xd_area xd_mem alphacut alphafrac alpharemove noxdamage xd_area xd_mem alphacut alphafrac alpharemove
noalpharemove alphablend noalphablend xwarppointer noalpharemove alphablend noalphablend xwarppointer
xwarp noxwarppointer noxwarp buttonmap dragging xwarp noxwarppointer noxwarp buttonmap dragging
nodragging wireframe_mode wireframe wf nowireframe nodragging wireframe_mode wireframe wf nowireframe

@ -148,27 +148,24 @@ 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" "-8to24 [opts] Try this option if -overlay is not supported on your\n"
" legacy 8bpp app that you want to view on a multi-depth\n" " OS, and you have a legacy 8bpp app that you want to\n"
" display with default depth 24 (and is 32 bpp), try\n" " view on a multi-depth display with default depth 24\n"
" this option. It will also work for a default depth 8\n" " (and is 32 bpp) or have default depth 8 display with\n"
" display with depth 24 overlay windows. This option\n" " depth 24 overlay windows for some apps. This option\n"
" may not work on all X servers and hardware (tested on\n" " may not work on all X servers and hardware (tested on\n"
" XFree86/Xorg mga driver).\n" " XFree86/Xorg mga driver). The \"opts\" string is not\n"
"\n" " required and is described below.\n"
" It enables a hack where x11vnc monitors windows within 3\n" "\n"
" levels from the root window. If it finds any that are\n" " This mode enables a hack where x11vnc monitors windows\n"
" 8bpp it will apply a transformation for pixel data in\n" " within 3 levels from the root window. If it finds\n"
" these regions where it extracts the 8bpp index color\n" " any that are 8bpp it will apply a transformation for\n"
" value from bits 25-32 and maps them on to TrueColor\n" " pixel data in these regions where it extracts the 8bpp\n"
" values and inserts them into bits 1-24 (i.e. overwrites\n" " index color value from bits 25-32 and maps them on\n"
" bits 1-24).\n" " to TrueColor values and inserts them into bits 1-24\n"
"\n" " (i.e. overwrites bits 1-24). Whereas for default\n"
" For default depth 8 displays, everything is tranformed\n" " depth 8 displays, everything is tranformed to 32bpp\n"
" to 32bpp (and is potentially a improvement over\n" " (and is potentially a improvement over -flashcmap).\n"
" -flashcmap). Also for default depth 8 displays, setting\n"
" the env. var. HIGHBITS_8TO24 may give a speedup for\n"
" transforming 8bpp pixel data.\n"
"\n" "\n"
" These schemes appear to work, but may still have\n" " These schemes appear to work, but may still have\n"
" bugs and note that they do hog resources. If there\n" " bugs and note that they do hog resources. If there\n"
@ -185,17 +182,24 @@ void print_help(int mode) {
" to periodically refresh the screen (at the cost of\n" " to periodically refresh the screen (at the cost of\n"
" bandwidth).\n" " bandwidth).\n"
"\n" "\n"
" Debugging for this mode can be enabled by setting the\n" " The [opts] string can contain the following settings.\n"
" environment variable DEBUG_8TO24 to 1, 2, or 3.\n" " Multiple settings are separated by commas.\n"
"\n" "\n"
" If there are problems, to enable an even more\n" " For when there are still color problems, enable an even\n"
" experimental mode, set the environment variable\n" " more experimental mode via the option \"getimage\".\n"
" XGETIMAGE_8TO24=1 before starting x11vnc. This enables\n" " This enables a scheme were XGetImage() is used to\n"
" a scheme were XGetImage() is used to retrieve the 8bpp\n" " retrieve the 8bpp data instead of assuming that data\n"
" data instead of assuming that data is in bits 25-32.\n" " is in bits 25-32. This mode is significantly slower\n"
" This mode is significantly slower than the above mode.\n" " than the above mode. For the default depth 8 case,\n"
" For the default depth 8 case, XGetImage() is always\n" " XGetImage() is always used to access depth 24 pixel\n"
" used to access depth 24 pixel data.\n" " data.\n"
"\n"
" For default depth 8 displays, setting option\n"
" \"highbits\" may give a speedup for transforming 8bpp\n"
" pixel data.\n"
"\n"
" Debugging for this mode can be enabled by setting \n"
" \"dbg=1\", \"dbg=2\", or \"dbg=3\"\n"
"\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"
@ -1642,6 +1646,7 @@ void print_help(int mode) {
" nooverlay_cursor.\n" " nooverlay_cursor.\n"
" 8to24 enable -8to24 mode (if applicable).\n" " 8to24 enable -8to24 mode (if applicable).\n"
" no8to24 disable -8to24 mode.\n" " no8to24 disable -8to24 mode.\n"
" 8to24_opts:str set the -8to24 opts to \"str\".\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"
@ -1902,22 +1907,22 @@ void print_help(int mode) {
" 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 8to24 no8to24\n" " nooverlay_yescursor overlay_nocursor 8to24 no8to24\n"
" visual scale scale_cursor viewonly noviewonly shared\n" " 8to24_opts visual scale scale_cursor viewonly\n"
" noshared forever noforever once timeout filexfer deny\n" " noviewonly shared noshared forever noforever once\n"
" lock nodeny unlock connect allowonce allow localhost\n" " timeout filexfer deny lock nodeny unlock connect\n"
" nolocalhost listen lookup nolookup accept afteraccept\n" " allowonce allow localhost nolocalhost listen lookup\n"
" gone shm noshm flipbyteorder noflipbyteorder onetile\n" " nolookup accept afteraccept gone shm noshm flipbyteorder\n"
" noonetile solid_color solid nosolid blackout xinerama\n" " noflipbyteorder onetile noonetile solid_color solid\n"
" noxinerama xtrap noxtrap xrandr noxrandr xrandr_mode\n" " nosolid blackout xinerama noxinerama xtrap noxtrap\n"
" padgeom quiet q noquiet modtweak nomodtweak xkb\n" " xrandr noxrandr xrandr_mode padgeom quiet q noquiet\n"
" noxkb skip_keycodes sloppy_keys nosloppy_keys\n" " modtweak nomodtweak xkb noxkb skip_keycodes sloppy_keys\n"
" skip_dups noskip_dups add_keysyms noadd_keysyms\n" " nosloppy_keys skip_dups noskip_dups add_keysyms\n"
" clear_mods noclear_mods clear_keys noclear_keys\n" " noadd_keysyms clear_mods noclear_mods clear_keys\n"
" remap repeat norepeat fb nofb bell nobell sel nosel\n" " noclear_keys remap repeat norepeat fb nofb bell\n"
" primary noprimary seldir cursorshape nocursorshape\n" " nobell sel nosel primary noprimary seldir cursorshape\n"
" cursorpos nocursorpos cursor show_cursor noshow_cursor\n" " nocursorshape cursorpos nocursorpos cursor show_cursor\n"
" nocursor arrow xfixes noxfixes xdamage noxdamage\n" " noshow_cursor nocursor arrow xfixes noxfixes xdamage\n"
" xd_area xd_mem alphacut alphafrac alpharemove\n" " noxdamage xd_area xd_mem alphacut alphafrac alpharemove\n"
" noalpharemove alphablend noalphablend xwarppointer\n" " noalpharemove alphablend noalphablend xwarppointer\n"
" xwarp noxwarppointer noxwarp buttonmap dragging\n" " xwarp noxwarppointer noxwarp buttonmap dragging\n"
" nodragging wireframe_mode wireframe wf nowireframe\n" " nodragging wireframe_mode wireframe wf nowireframe\n"

@ -89,6 +89,7 @@ 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 cmap8to24 = 0; /* -8to24 */
char *cmap8to24_str = NULL;
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 */

@ -64,6 +64,7 @@ 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 cmap8to24;
extern char *cmap8to24_str;
extern int launch_gui; extern int launch_gui;
extern int use_modifier_tweak; extern int use_modifier_tweak;

@ -411,6 +411,7 @@ static void update_x11_pointer_mask(int mask) {
int skip = 0; int skip = 0;
if (!button_mask) { if (!button_mask) {
X_LOCK;
if (get_wm_frame_pos(&px, &py, &x, &y, &w, &h, if (get_wm_frame_pos(&px, &py, &x, &y, &w, &h,
&frame, &mwin)) { &frame, &mwin)) {
got_wm_frame = 1; got_wm_frame = 1;
@ -423,6 +424,7 @@ if (debug_scroll > 1) fprintf(stderr, "wm_win: 0x%lx\n", mwin);
} else { } else {
got_wm_frame = 0; got_wm_frame = 0;
} }
X_UNLOCK;
} }
if (got_wm_frame) { if (got_wm_frame) {
if (wireframe && near_wm_edge(x, y, w, h, px, py)) { if (wireframe && near_wm_edge(x, y, w, h, px, py)) {

@ -200,7 +200,9 @@ void initialize_speeds(void) {
int n = 0; int n = 0;
double dt, timer; double dt, timer;
dtime0(&timer); dtime0(&timer);
if (fullscreen) { if (raw_fb && ! dpy) { /* raw_fb hack */
n = 0;
} else if (fullscreen) {
copy_image(fullscreen, 0, 0, 0, 0); copy_image(fullscreen, 0, 0, 0, 0);
n = fullscreen->bytes_per_line * fullscreen->height; n = fullscreen->bytes_per_line * fullscreen->height;
} else if (scanline) { } else if (scanline) {

@ -563,6 +563,7 @@ int remote_control_access_ok(void) {
rfbLog("XAUTHORITY is not required on display.\n"); rfbLog("XAUTHORITY is not required on display.\n");
rfbLog(" %s\n", DisplayString(dpy)); rfbLog(" %s\n", DisplayString(dpy));
XCloseDisplay(dpy2); XCloseDisplay(dpy2);
dpy2 = NULL;
return 0; return 0;
} }
@ -1005,6 +1006,26 @@ char *process_remote_cmd(char *cmd, int stringonly) {
cmap8to24 = 0; cmap8to24 = 0;
do_new_fb(0); do_new_fb(0);
} else if (strstr(p, "8to24_opts") == p) {
COLON_CHECK("8to24_opts:")
if (query) {
snprintf(buf, bufn, "ans=%s%s%s", p, co,
NONUL(cmap8to24_str));
goto qry;
}
p += strlen("8to24_opts:");
if (cmap8to24_str) {
free(cmap8to24_str);
}
cmap8to24_str = strdup(p);
if (*p == '\0') {
cmap8to24 = 0;
} else {
cmap8to24 = 1;
}
rfbLog("remote_cmd: set cmap8to24_str to: %s\n", cmap8to24_str);
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) {

@ -980,6 +980,8 @@ static XImage *initialize_raw_fb(void) {
raw_fb_image->depth = (b == 32) ? 24 : b; raw_fb_image->depth = (b == 32) ? 24 : b;
} }
depth = raw_fb_image->depth;
if (clipshift) { if (clipshift) {
memset(raw_fb, 0xff, dpy_x * dpy_y * b/8); memset(raw_fb, 0xff, dpy_x * dpy_y * b/8);
} else if (raw_fb_addr) { } else if (raw_fb_addr) {

@ -122,6 +122,7 @@ Screen
overlay overlay
overlay_nocursor overlay_nocursor
8to24 8to24
8to24_opts:
=GAL LOFF =GAL LOFF
=GAL 8-Bit-Color:: =GAL 8-Bit-Color::
flashcmap flashcmap

@ -133,6 +133,7 @@ char gui_code[] = "";
" overlay\n" " overlay\n"
" overlay_nocursor\n" " overlay_nocursor\n"
" 8to24\n" " 8to24\n"
" 8to24_opts:\n"
" =GAL LOFF\n" " =GAL LOFF\n"
" =GAL 8-Bit-Color::\n" " =GAL 8-Bit-Color::\n"
" flashcmap\n" " flashcmap\n"

@ -217,6 +217,7 @@ void update_stack_list(void) {
dtime0(&now); dtime0(&now);
X_LOCK;
for (k=0; k < stack_list_num; k++) { for (k=0; k < stack_list_num; k++) {
Window win = stack_list[k].win; Window win = stack_list[k].win;
if (win != None && win < 10) { if (win != None && win < 10) {
@ -241,6 +242,7 @@ void update_stack_list(void) {
stack_list[k].fetched = 1; stack_list[k].fetched = 1;
stack_list[k].time = now; stack_list[k].time = now;
} }
X_UNLOCK;
if (0) fprintf(stderr, "update_stack_list[%d]: %.4f %.4f\n", stack_list_num, now - x11vnc_start, dtime(&now)); if (0) fprintf(stderr, "update_stack_list[%d]: %.4f %.4f\n", stack_list_num, now - x11vnc_start, dtime(&now));
} }

@ -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-18 version: 0.8, lastmod: 2006-01-21
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
@ -178,29 +178,26 @@ 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 \fB-8to24\fR \fI[opts]\fR
.IP .IP
If \fB-overlay\fR is not supported on your OS, and you have a Try this option if \fB-overlay\fR is not supported on your
legacy 8bpp app that you want to view on a multi-depth OS, and you have a legacy 8bpp app that you want to
display with default depth 24 (and is 32 bpp), try view on a multi-depth display with default depth 24
this option. It will also work for a default depth 8 (and is 32 bpp) or have default depth 8 display with
display with depth 24 overlay windows. This option depth 24 overlay windows for some apps. This option
may not work on all X servers and hardware (tested on may not work on all X servers and hardware (tested on
XFree86/Xorg mga driver). XFree86/Xorg mga driver). The "opts" string is not
.IP required and is described below.
It enables a hack where x11vnc monitors windows within 3 .IP
levels from the root window. If it finds any that are This mode enables a hack where x11vnc monitors windows
8bpp it will apply a transformation for pixel data in within 3 levels from the root window. If it finds
these regions where it extracts the 8bpp index color any that are 8bpp it will apply a transformation for
value from bits 25-32 and maps them on to TrueColor pixel data in these regions where it extracts the 8bpp
values and inserts them into bits 1-24 (i.e. overwrites index color value from bits 25-32 and maps them on
bits 1-24). to TrueColor values and inserts them into bits 1-24
.IP (i.e. overwrites bits 1-24). Whereas for default
For default depth 8 displays, everything is tranformed depth 8 displays, everything is tranformed to 32bpp
to 32bpp (and is potentially a improvement over (and is potentially a improvement over \fB-flashcmap).\fR
\fB-flashcmap).\fR Also for default depth 8 displays, setting
the env. var. HIGHBITS_8TO24 may give a speedup for
transforming 8bpp pixel data.
.IP .IP
These schemes appear to work, but may still have These schemes appear to work, but may still have
bugs and note that they do hog resources. If there bugs and note that they do hog resources. If there
@ -217,17 +214,24 @@ Also the option, say, \fB-fixscreen\fR V=3.0 may be use
to periodically refresh the screen (at the cost of to periodically refresh the screen (at the cost of
bandwidth). bandwidth).
.IP .IP
Debugging for this mode can be enabled by setting the The [opts] string can contain the following settings.
environment variable DEBUG_8TO24 to 1, 2, or 3. Multiple settings are separated by commas.
.IP .IP
If there are problems, to enable an even more For when there are still color problems, enable an even
experimental mode, set the environment variable more experimental mode via the option "getimage".
XGETIMAGE_8TO24=1 before starting x11vnc. This enables This enables a scheme were XGetImage() is used to
a scheme were XGetImage() is used to retrieve the 8bpp retrieve the 8bpp data instead of assuming that data
data instead of assuming that data is in bits 25-32. is in bits 25-32. This mode is significantly slower
This mode is significantly slower than the above mode. than the above mode. For the default depth 8 case,
For the default depth 8 case, XGetImage() is always XGetImage() is always used to access depth 24 pixel
used to access depth 24 pixel data. data.
.IP
For default depth 8 displays, setting option
"highbits" may give a speedup for transforming 8bpp
pixel data.
.IP
Debugging for this mode can be enabled by setting
"dbg=1", "dbg=2", or "dbg=3"
.PP .PP
\fB-scale\fR \fIfraction\fR \fB-scale\fR \fIfraction\fR
.IP .IP
@ -2035,6 +2039,8 @@ nooverlay_cursor.
.IP .IP
no8to24 disable \fB-8to24\fR mode. no8to24 disable \fB-8to24\fR mode.
.IP .IP
8to24_opts:str set the \fB-8to24\fR opts to "str".
.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"
@ -2474,22 +2480,22 @@ 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 8to24 no8to24 nooverlay_yescursor overlay_nocursor 8to24 no8to24
visual scale scale_cursor viewonly noviewonly shared 8to24_opts visual scale scale_cursor viewonly
noshared forever noforever once timeout filexfer deny noviewonly shared noshared forever noforever once
lock nodeny unlock connect allowonce allow localhost timeout filexfer deny lock nodeny unlock connect
nolocalhost listen lookup nolookup accept afteraccept allowonce allow localhost nolocalhost listen lookup
gone shm noshm flipbyteorder noflipbyteorder onetile nolookup accept afteraccept gone shm noshm flipbyteorder
noonetile solid_color solid nosolid blackout xinerama noflipbyteorder onetile noonetile solid_color solid
noxinerama xtrap noxtrap xrandr noxrandr xrandr_mode nosolid blackout xinerama noxinerama xtrap noxtrap
padgeom quiet q noquiet modtweak nomodtweak xkb xrandr noxrandr xrandr_mode padgeom quiet q noquiet
noxkb skip_keycodes sloppy_keys nosloppy_keys modtweak nomodtweak xkb noxkb skip_keycodes sloppy_keys
skip_dups noskip_dups add_keysyms noadd_keysyms nosloppy_keys skip_dups noskip_dups add_keysyms
clear_mods noclear_mods clear_keys noclear_keys noadd_keysyms clear_mods noclear_mods clear_keys
remap repeat norepeat fb nofb bell nobell sel nosel noclear_keys remap repeat norepeat fb nofb bell
primary noprimary seldir cursorshape nocursorshape nobell sel nosel primary noprimary seldir cursorshape
cursorpos nocursorpos cursor show_cursor noshow_cursor nocursorshape cursorpos nocursorpos cursor show_cursor
nocursor arrow xfixes noxfixes xdamage noxdamage noshow_cursor nocursor arrow xfixes noxfixes xdamage
xd_area xd_mem alphacut alphafrac alpharemove noxdamage xd_area xd_mem alphacut alphafrac alpharemove
noalpharemove alphablend noalphablend xwarppointer noalpharemove alphablend noalphablend xwarppointer
xwarp noxwarppointer noxwarp buttonmap dragging xwarp noxwarppointer noxwarp buttonmap dragging
nodragging wireframe_mode wireframe wf nowireframe nodragging wireframe_mode wireframe wf nowireframe

@ -1273,6 +1273,12 @@ int main(int argc, char* argv[]) {
overlay_cursor = 2; overlay_cursor = 2;
} else if (!strcmp(arg, "-8to24")) { } else if (!strcmp(arg, "-8to24")) {
cmap8to24 = 1; cmap8to24 = 1;
if (i < argc-1) {
char *s = argv[i+1];
if (s[0] != '-') {
cmap8to24_str = strdup(s);
}
}
} else if (!strcmp(arg, "-visual")) { } else if (!strcmp(arg, "-visual")) {
CHECK_ARGC CHECK_ARGC
visual_str = strdup(argv[++i]); visual_str = strdup(argv[++i]);

@ -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-18"; char lastmod[] = "0.8 lastmod: 2006-01-21";
/* X display info */ /* X display info */

Loading…
Cancel
Save