diff options
author | runge <runge> | 2007-02-10 21:52:26 +0000 |
---|---|---|
committer | runge <runge> | 2007-02-10 21:52:26 +0000 |
commit | 90d96b971f04b11fe1902091a94be94697738766 (patch) | |
tree | 8331ed14521fd8e7b997465d6f482d521f4537cb /x11vnc/scan.c | |
parent | 76720eb71bb18ec452ec1782af9f8b8d09e77efc (diff) | |
download | libtdevnc-90d96b971f04b11fe1902091a94be94697738766.tar.gz libtdevnc-90d96b971f04b11fe1902091a94be94697738766.zip |
x11vnc: watch textchat, etc in unixpw, implement kbdReleaseAllKeys, setSingleWindow, setServerInput. watch for OpenGL apps breaking XDAMAGE.
Diffstat (limited to 'x11vnc/scan.c')
-rw-r--r-- | x11vnc/scan.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/x11vnc/scan.c b/x11vnc/scan.c index 9c3c0a1..f4810ac 100644 --- a/x11vnc/scan.c +++ b/x11vnc/scan.c @@ -2831,18 +2831,23 @@ void set_offset(void) { X_UNLOCK; } +static int xd_samples = 0, xd_misses = 0, xd_do_check = 0; + /* * Loop over 1-pixel tall horizontal scanlines looking for changes. * Record the changes in tile_has_diff[]. Scanlines in the loop are * equally spaced along y by NSCAN pixels, but have a slightly random * starting offset ystart ( < NSCAN ) from scanlines[]. */ + static int scan_display(int ystart, int rescan) { char *src, *dst; int pixelsize = bpp/8; int x, y, w, n; int tile_count = 0; int nodiffs = 0, diff_hint; + int xd_check, xd_freq = 1; + static int xd_tck = 0; y = ystart; @@ -2859,10 +2864,24 @@ static int scan_display(int ystart, int rescan) { if (use_xdamage) { XD_tot++; + xd_check = 0; if (xdamage_hint_skip(y)) { - XD_skip++; - y += NSCAN; - continue; + if (xd_do_check && dpy && use_xdamage == 1) { + xd_tck = (xd_tck++) % xd_freq; + if (xd_tck == 0) { + xd_check = 1; + xd_samples++; + } + } + if (!xd_check) { + XD_skip++; + y += NSCAN; + continue; + } + } else { + if (xd_do_check && 0) { + fprintf(stderr, "ns y=%d\n", y); + } } } @@ -2931,6 +2950,9 @@ fprintf(stderr, "\n*** SCAN_DISPLAY CHECK_NCACHE/%d *** %d rescan=%d\n", gotone, continue; } } + if (xd_check) { + xd_misses++; + } x = 0; while (x < dpy_x) { @@ -3132,6 +3154,33 @@ int scan_for_updates(int count_only) { } } } + if (dpy && use_xdamage == 1) { + static time_t last_xd_check = 0; + if (time(NULL) > last_xd_check + 2) { + int cp = (scan_count + 3) % NSCAN; + xd_do_check = 1; + tile_count = scan_display(scanlines[cp], 0); + xd_do_check = 0; + SCAN_FATAL(tile_count); + last_xd_check = time(NULL); + if (xd_samples > 200) { + static bad = 0; + if (xd_misses > (5 * xd_samples) / 100) { + rfbLog("XDAMAGE is not working well... misses: %d/%d\n", xd_misses, xd_samples); + rfbLog("Maybe a OpenGL app like Beryl is the problem? Use -noxdamage\n"); + rfbLog("To disable this check and warning specify -xdamage twice.\n"); + if (++bad >= 10) { + rfbLog("XDAMAGE appears broken (OpenGL app?), turning it off.\n"); + use_xdamage = 0; + initialize_xdamage(); + destroy_xdamage_if_needed(); + } + } + xd_samples = 0; + xd_misses = 0; + } + } + } nap_set(tile_count); |