From 198382dcf3c9b86919b7b69b9cedff7a162ba9cf Mon Sep 17 00:00:00 2001 From: runge Date: Sat, 10 Jan 2009 23:03:24 +0000 Subject: [PATCH] x11vnc: fix failure of -8to24 on default depth 24 due to nonstandard indexed color support changes. Fix small window for failure after XSendEvent selection call; add env var. X11VNC_SENDEVENT_SYNC=1 to take even more care. --- x11vnc/8to24.c | 19 +++++++++++++------ x11vnc/ChangeLog | 6 ++++++ x11vnc/README | 6 +++--- x11vnc/screen.c | 4 +++- x11vnc/selection.c | 17 ++++++++++++++++- x11vnc/x11vnc.1 | 2 +- x11vnc/x11vnc_defs.c | 2 +- x11vnc/xrecord.c | 2 +- 8 files changed, 44 insertions(+), 14 deletions(-) diff --git a/x11vnc/8to24.c b/x11vnc/8to24.c index a8ba59a..f69fb9a 100644 --- a/x11vnc/8to24.c +++ b/x11vnc/8to24.c @@ -79,7 +79,9 @@ static void set_root_cmap(void) { RAWFB_RET_VOID - if (depth > 8) { + if (depth > 16) { + ncolor = NCOLOR; + } else if (depth > 8) { ncolor = 1 << depth; } else { ncolor = NCOLOR; @@ -255,7 +257,7 @@ static void set_poll_fb(void) { return; /* this saves a bit of RAM */ } pfb(4, &poll24_fb, &poll24_fb_w, &poll24_fb_h); - if (depth > 8) { + if (depth > 8 && depth <= 16) { pfb(2, &poll8_fb, &poll8_fb_w, &poll8_fb_h); /* 2X for rare 16bpp colormap case */ } else { pfb(1, &poll8_fb, &poll8_fb_w, &poll8_fb_h); @@ -333,7 +335,7 @@ if (db24 > 2) fprintf(stderr, " check_for_multivis: %.4f\n", now - last_call); if (stack_old) { free(stack_old); } - stack_old = (Window *) malloc(n*sizeof(Window)); + stack_old = (Window *) calloc(n*sizeof(Window), 1); stack_old_len = n; } @@ -1340,7 +1342,10 @@ static int get_cmap(int j, Colormap cmap) { RAWFB_RET(0) - if (depth > 8) { + if (depth > 16) { + /* 24 */ + ncolor = NCOLOR; + } else if (depth > 8) { ncolor = 1 << depth; } else { ncolor = NCOLOR; @@ -1362,9 +1367,10 @@ static int get_cmap(int j, Colormap cmap) { } else { ncells = NCOLOR; } -if (db24 > 1) fprintf(stderr, "get_cmap: %d 0x%x\n", j, (unsigned int) cmap); - if (ncells > ncolor) { + if (depth > 16) { + ; + } else if (ncells > ncolor) { ncells = ncolor; } else if (ncells == 8 && depth != 3) { /* XXX. see set_colormap() */ @@ -1376,6 +1382,7 @@ if (db24 > 1) fprintf(stderr, "get_cmap: %d 0x%x\n", j, (unsigned int) cmap); color[j][i].pixel = i; color[j][i].pad = 0; } +if (db24 > 1) fprintf(stderr, "get_cmap: %d 0x%x ncolor=%d ncells=%d\n", j, (unsigned int) cmap, ncolor, ncells); /* try to query the colormap, trap errors */ X_LOCK; diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index 128ca49..6305c04 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,9 @@ +2009-01-10 Karl Runge + * x11vnc: fix failure of -8to24 on default depth 24 due to + nonstandard indexed color support changes. Fix small window + for failure after XSendEvent selection call; add env var. + X11VNC_SENDEVENT_SYNC=1 to take even more care. + 2009-01-03 Karl Runge * x11vnc: add -rmflag option, -rawfb vt support, bpp < 8 support for rawfb, find /dev/video better. Fix reverse SSL connection diff --git a/x11vnc/README b/x11vnc/README index d0c1cc4..66dfeb7 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Sat Jan 3 23:43:28 EST 2009 +x11vnc README file Date: Wed Jan 7 21:16:30 EST 2009 The following information is taken from these URLs: @@ -12266,7 +12266,7 @@ x11vnc: a VNC server for real X displays Here are all of x11vnc command line options: % x11vnc -opts (see below for -help long descriptions) -x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-01-03 +x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-01-07 x11vnc options: -display disp -auth file -N @@ -12390,7 +12390,7 @@ libvncserver-tight-extension options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-01-03 +x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-01-07 (type "x11vnc -opts" to just list the options.) diff --git a/x11vnc/screen.c b/x11vnc/screen.c index a65230d..f66450a 100644 --- a/x11vnc/screen.c +++ b/x11vnc/screen.c @@ -194,7 +194,9 @@ void set_colormap(int reset) { } if (init) { - if (depth > 8) { + if (depth > 16) { + ncolor = NCOLOR; + } else if (depth > 8) { ncolor = 1 << depth; } else { ncolor = NCOLOR; diff --git a/x11vnc/selection.c b/x11vnc/selection.c index ae0075e..621a492 100644 --- a/x11vnc/selection.c +++ b/x11vnc/selection.c @@ -63,6 +63,7 @@ void selection_request(XEvent *ev, char *type) { unsigned int length; unsigned char *data; static Atom xa_targets = None; + static int sync_it = -1; # ifndef XA_LENGTH unsigned long XA_LENGTH; # endif @@ -72,6 +73,14 @@ void selection_request(XEvent *ev, char *type) { XA_LENGTH = XInternAtom(dpy, "LENGTH", True); # endif + if (sync_it < 0) { + if (getenv("X11VNC_SENDEVENT_SYNC")) { + sync_it = 1; + } else { + sync_it = 0; + } + } + req_event = &(ev->xselectionrequest); notify_event.type = SelectionNotify; notify_event.display = req_event->display; @@ -170,10 +179,16 @@ void selection_request(XEvent *ev, char *type) { rfbLog("selection_request: ignored XError while sending " "%s selection to 0x%x.\n", type, req_event->requestor); } + + XFlush_wr(dpy); + if (sync_it) { + usleep(5 * 1000); + XSync(dpy, False); + } + XSetErrorHandler(old_handler); trapped_xerror = 0; - XFlush_wr(dpy); #endif /* NO_X11 */ } diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index 313c3fa..1e9a1cc 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -2,7 +2,7 @@ .TH X11VNC "1" "January 2009" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.9.7, lastmod: 2009-01-03 + version: 0.9.7, lastmod: 2009-01-07 .SH SYNOPSIS .B x11vnc [OPTION]... diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c index 2ce482f..ad16cd0 100644 --- a/x11vnc/x11vnc_defs.c +++ b/x11vnc/x11vnc_defs.c @@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; int xdamage_base_event_type = 0; /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.9.7 lastmod: 2009-01-03"; +char lastmod[] = "0.9.7 lastmod: 2009-01-07"; /* X display info */ diff --git a/x11vnc/xrecord.c b/x11vnc/xrecord.c index 81b319b..3999154 100644 --- a/x11vnc/xrecord.c +++ b/x11vnc/xrecord.c @@ -135,8 +135,8 @@ static void xrecord_grabserver(int start) { XSetErrorHandler(old_handler); return; } - XSetErrorHandler(old_handler); XFlush_wr(gdpy_data); + XSetErrorHandler(old_handler); #else if (!rc || !old_handler) {} #endif