diff options
author | runge <[email protected]> | 2009-05-21 10:57:03 -0400 |
---|---|---|
committer | runge <[email protected]> | 2009-05-21 10:57:03 -0400 |
commit | 94d058b35f075cec2d6e8b6e37ee1a94086ea3f8 (patch) | |
tree | 6cec0620ab70b5db6b33645dbcac1071f3c7a556 /x11vnc/xwrappers.c | |
parent | 804335f9d296440bb708ca844f5d89b58b50b0c6 (diff) | |
download | libtdevnc-94d058b35f075cec2d6e8b6e37ee1a94086ea3f8.tar.gz libtdevnc-94d058b35f075cec2d6e8b6e37ee1a94086ea3f8.zip |
Thread safety. Fix -clip -in -rawfb. Try to avoid Xorg stuck
key bug.
Diffstat (limited to 'x11vnc/xwrappers.c')
-rw-r--r-- | x11vnc/xwrappers.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/x11vnc/xwrappers.c b/x11vnc/xwrappers.c index e585fa8..aa04f35 100644 --- a/x11vnc/xwrappers.c +++ b/x11vnc/xwrappers.c @@ -601,6 +601,9 @@ static void copy_raw_fb_24_to_32(XImage *dest, int x, int y, unsigned int w, } else if (! raw_fb_seek) { /* mmap */ bpl = raw_fb_bytes_per_line; + if (clipshift && wdpy_x != cdpy_x) { + bpl = wdpy_x * 3; + } src = raw_fb_addr + raw_fb_offset + bpl*y + 3*x; dst = dest->data; @@ -626,6 +629,9 @@ static void copy_raw_fb_24_to_32(XImage *dest, int x, int y, unsigned int w, /* lseek */ off_t off; bpl = raw_fb_bytes_per_line; + if (clipshift && wdpy_x != cdpy_x) { + bpl = wdpy_x * 3; + } off = (off_t) (raw_fb_offset + bpl*y + 3*x); lseek(raw_fb_fd, off, SEEK_SET); @@ -671,7 +677,7 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { char *src, *dst; unsigned int line; int pixelsize = bpp/8; - int bpl = wdpy_x * pixelsize; + static int db = -1; if (xform24to32) { copy_raw_fb_24_to_32(dest, x, y, w, h); @@ -681,17 +687,27 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { copy_raw_fb_low_bpp(dest, x, y, w, h); return; } + if (db < 0) { + if (getenv("DEBUG_COPY_RAW_FB")) { + db = atoi(getenv("DEBUG_COPY_RAW_FB")); + } else { + db = 0; + } + } if (clipshift && ! use_snapfb) { x += coff_x; y += coff_y; } + if (use_snapfb && dest != snap) { /* snapfb src */ src = snap->data + snap->bytes_per_line*y + pixelsize*x; dst = dest->data; +if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", snap->bytes_per_line, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x); + for (line = 0; line < h; line++) { memcpy(dst, src, w * pixelsize); src += snap->bytes_per_line; @@ -700,10 +716,17 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { } else if (! raw_fb_seek) { /* mmap */ - bpl = raw_fb_bytes_per_line; + int bpl = raw_fb_bytes_per_line; + + if (clipshift && wdpy_x != cdpy_x) { + bpl = wdpy_x * pixelsize; + } + src = raw_fb_addr + raw_fb_offset + bpl*y + pixelsize*x; dst = dest->data; +if (db) fprintf(stderr, "bpl: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", bpl, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x); + for (line = 0; line < h; line++) { memcpy(dst, src, w * pixelsize); src += bpl; @@ -714,20 +737,25 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) { /* lseek */ int n, len, del, sz = w * pixelsize; off_t off; - bpl = raw_fb_bytes_per_line; + int bpl = raw_fb_bytes_per_line; + + if (clipshift && wdpy_x != cdpy_x) { + bpl = wdpy_x * pixelsize; + } + off = (off_t) (raw_fb_offset + bpl*y + pixelsize*x); lseek(raw_fb_fd, off, SEEK_SET); dst = dest->data; -if (0) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, sz, (int) off, bpl); +if (db) fprintf(stderr, "lseek 0 ps: %d sz: %d off: %d bpl: %d\n", pixelsize, sz, (int) off, bpl); for (line = 0; line < h; line++) { len = sz; del = 0; while (len > 0) { n = read(raw_fb_fd, dst + del, len); -if (0) fprintf(stderr, "len: %d n: %d\n", len, n); +//if (db > 2) fprintf(stderr, "len: %d n: %d\n", len, n); if (n > 0) { del += n; @@ -739,7 +767,7 @@ if (0) fprintf(stderr, "len: %d n: %d\n", len, n); } } if (bpl > sz) { -if (0) fprintf(stderr, "bpl>sz %d %d\n", bpl, sz); +//if (db > 1) fprintf(stderr, "bpl>sz %d %d\n", bpl, sz); off = (off_t) (bpl - sz); lseek(raw_fb_fd, off, SEEK_CUR); } |