summaryrefslogtreecommitdiffstats
path: root/x11vnc/screen.c
diff options
context:
space:
mode:
authorrunge <[email protected]>2009-10-08 17:30:36 -0400
committerrunge <[email protected]>2009-10-08 17:30:36 -0400
commit3129ef668abf2b3f9b624bdb4c5ac0365ae2583b (patch)
treea2f7edda96dd11da79f7fbbab886625caaa41ae8 /x11vnc/screen.c
parent169ef3a0429b3e21720856024076e1941221e987 (diff)
downloadlibtdevnc-3129ef668abf2b3f9b624bdb4c5ac0365ae2583b.tar.gz
libtdevnc-3129ef668abf2b3f9b624bdb4c5ac0365ae2583b.zip
Huge number of changes, see x11vnc/ChangeLog
Diffstat (limited to 'x11vnc/screen.c')
-rw-r--r--x11vnc/screen.c177
1 files changed, 127 insertions, 50 deletions
diff --git a/x11vnc/screen.c b/x11vnc/screen.c
index 71f4462..6a9a5fe 100644
--- a/x11vnc/screen.c
+++ b/x11vnc/screen.c
@@ -1179,6 +1179,8 @@ static char* vnc_reflect_get_password(rfbClient* client) {
char *q, *p, *str = getenv("X11VNC_REFLECT_PASSWORD");
int len = 110;
+ if (client) {}
+
if (str) {
len += 2*strlen(str);
}
@@ -2846,11 +2848,17 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
/* n.b. samplesPerPixel (set = 1 here) seems to be unused. */
if (create_screen) {
- if (use_openssl) {
- openssl_init(0);
- } else if (use_stunnel) {
+ if (use_stunnel) {
setup_stunnel(0, argc, argv);
}
+ if (use_openssl) {
+ if (use_stunnel && enc_str && !strcmp(enc_str, "none")) {
+ /* emulating HTTPS oneport */
+ ;
+ } else {
+ openssl_init(0);
+ }
+ }
screen = rfbGetScreen(argc, argv, width, height,
bits_per_color, 1, fb_bpp/8);
if (screen && http_dir) {
@@ -3367,6 +3375,10 @@ void announce(int lport, int ssl, char *iface) {
char *host = this_host();
char *tvdt;
+ if (remote_direct) {
+ return;
+ }
+
if (! ssl) {
tvdt = "The VNC desktop is: ";
} else {
@@ -3422,12 +3434,12 @@ void announce(int lport, int ssl, char *iface) {
}
}
-static void announce_http(int lport, int ssl, char *iface) {
+static void announce_http(int lport, int ssl, char *iface, char *extra) {
char *host = this_host();
char *jvu;
- if (enc_str && !strcmp(enc_str, "none")) {
+ if (enc_str && !strcmp(enc_str, "none") && !use_stunnel) {
jvu = "Java viewer URL: http";
} else if (ssl == 1) {
jvu = "Java SSL viewer URL: https";
@@ -3442,44 +3454,91 @@ static void announce_http(int lport, int ssl, char *iface) {
}
if (host != NULL) {
if (! inetd) {
- fprintf(stderr, "%s://%s:%d/\n", jvu, host, lport);
- if (screen && enc_str && !strcmp(enc_str, "none")) {
- fprintf(stderr, "%s://%s:%d/\n", jvu, host, screen->port);
+ fprintf(stderr, "%s://%s:%d/%s\n", jvu, host, lport, extra);
+ }
+ }
+}
+
+void do_announce_http(void) {
+ if (!screen) {
+ return;
+ }
+ if (remote_direct) {
+ return;
+ }
+
+ if (screen->httpListenSock > -1 && screen->httpPort) {
+ int enc_none = (enc_str && !strcmp(enc_str, "none"));
+ char *SPORT = " (single port)";
+ if (use_openssl && ! enc_none) {
+ announce_http(screen->port, 1, listen_str, SPORT);
+ if (https_port_num >= 0) {
+ announce_http(https_port_num, 1,
+ listen_str, "");
+ }
+ announce_http(screen->httpPort, 2, listen_str, "");
+ } else if (use_stunnel) {
+ char pmsg[100];
+ pmsg[0] = '\0';
+ if (stunnel_port) {
+ sprintf(pmsg, "?PORT=%d", stunnel_port);
+ }
+ announce_http(screen->httpPort, 2, listen_str, pmsg);
+ if (stunnel_http_port > 0) {
+ announce_http(stunnel_http_port, 1, NULL, pmsg);
+ }
+ if (enc_none) {
+ strcat(pmsg, SPORT);
+ announce_http(stunnel_port, 1, NULL, pmsg);
+ }
+ } else {
+ announce_http(screen->httpPort, 0, listen_str, "");
+ if (enc_none) {
+ announce_http(screen->port, 1, NULL, SPORT);
}
}
}
}
+void do_mention_java_urls(void) {
+ if (! quiet && screen) {
+ if (screen->httpListenSock > -1 && screen->httpPort) {
+ rfbLog("\n");
+ rfbLog("The URLs printed out below ('Java ... viewer URL') can\n");
+ rfbLog("be used for Java enabled Web browser connections.\n");
+ if (!stunnel_port && enc_str && !strcmp(enc_str, "none")) {
+ ;
+ } else if (use_openssl || stunnel_port) {
+ rfbLog("Here are some additional possibilities:\n");
+ rfbLog("\n");
+ rfbLog("https://host:port/proxy.vnc (MUST be used if Web Proxy used)\n");
+ rfbLog("\n");
+ rfbLog("https://host:port/ultra.vnc (Use UltraVNC Java Viewer)\n");
+ rfbLog("https://host:port/ultraproxy.vnc (Web Proxy with UltraVNC)\n");
+ rfbLog("https://host:port/ultrasigned.vnc (Signed UltraVNC Filexfer)\n");
+ rfbLog("\n");
+ rfbLog("Where you replace \"host:port\" with that printed below, or\n");
+ rfbLog("whatever is needed to reach the host e.g. Internet IP number\n");
+ rfbLog("\n");
+ rfbLog("Append ?GET=1 to a URL for faster loading.\n");
+ }
+ }
+ rfbLog("\n");
+ }
+}
+
void set_vnc_desktop_name(void) {
sprintf(vnc_desktop_name, "unknown");
if (inetd) {
sprintf(vnc_desktop_name, "%s/inetd-no-further-clients",
this_host());
}
+ if (remote_direct) {
+ return;
+ }
if (screen->port) {
- if (! quiet) {
- if (screen->httpListenSock > -1 && screen->httpPort) {
- rfbLog("\n");
- rfbLog("The URLs printed out below ('Java ... viewer URL') can\n");
- rfbLog("be used for Java enabled Web browser connections.\n");
- if (enc_str && !strcmp(enc_str, "none")) {
- ;
- } else if (use_openssl || stunnel_port) {
- rfbLog("Here are some additional possibilities:\n");
- rfbLog("\n");
- rfbLog("https://host:port/proxy.vnc (MUST be used if Web Proxy used)\n");
- rfbLog("\n");
- rfbLog("https://host:port/ultra.vnc (Use UltraVNC Java Viewer)\n");
- rfbLog("https://host:port/ultraproxy.vnc (Web Proxy with UltraVNC)\n");
- rfbLog("https://host:port/ultrasigned.vnc (Signed UltraVNC Filexfer)\n");
- rfbLog("\n");
- rfbLog("Where you replace \"host:port\" with that printed below, or\n");
- rfbLog("whatever is needed to reach the host e.g. Internet IP number\n");
- }
- }
- rfbLog("\n");
- }
+ do_mention_java_urls();
if (use_openssl) {
announce(screen->port, 1, listen_str);
@@ -3489,24 +3548,8 @@ void set_vnc_desktop_name(void) {
if (stunnel_port) {
announce(stunnel_port, 1, NULL);
}
- if (screen->httpListenSock > -1 && screen->httpPort) {
- if (use_openssl) {
- if (enc_str && !strcmp(enc_str, "none")) {
- ;
- } else {
- announce_http(screen->port, 1, listen_str);
- }
- if (https_port_num >= 0) {
- announce_http(https_port_num, 1,
- listen_str);
- }
- announce_http(screen->httpPort, 2, listen_str);
- } else if (use_stunnel) {
- announce_http(screen->httpPort, 2, listen_str);
- } else {
- announce_http(screen->httpPort, 0, listen_str);
- }
- }
+
+ do_announce_http();
fflush(stderr);
if (inetd) {
@@ -3954,13 +3997,19 @@ void watch_loop(void) {
* see quickly (just 1 rfbPE will likely
* only process the subsequent "up" event)
*/
- if (tm < last_keyboard_time + 0.16) {
+ if (tm < last_keyboard_time + 0.20) {
rfbPE(0);
rfbPE(0);
rfbPE(-1);
rfbPE(0);
rfbPE(0);
} else {
+ if (extra_fbur > 0) {
+ int i;
+ for (i=0; i < extra_fbur; i++) {
+ rfbPE(0);
+ }
+ }
rfbPE(-1);
}
if (x11vnc_current < last_new_client + 0.5) {
@@ -4126,6 +4175,7 @@ void watch_loop(void) {
} else {
static double last_dt = 0.0;
double xdamage_thrash = 0.4;
+ static int tilecut = -1;
check_cursor_changes();
@@ -4176,8 +4226,15 @@ void watch_loop(void) {
last_dt = dt;
}
+ if (tilecut < 0) {
+ if (getenv("TILECUT")) {
+ tilecut = atoi(getenv("TILECUT"));
+ }
+ if (tilecut < 0) tilecut = 4;
+ }
+
if ((debug_tiles || debug_scroll > 1 || debug_wireframe > 1)
- && (tile_diffs > 4 || debug_tiles > 1)) {
+ && (tile_diffs > tilecut || debug_tiles > 1)) {
double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt;
fprintf(stderr, "============================= TILES: %d dt: %.4f"
" t: %.4f %.2f MB/s nap_ok: %d\n", tile_diffs, dt,
@@ -4188,13 +4245,33 @@ void watch_loop(void) {
/* sleep a bit to lessen load */
wait = choose_delay(dt);
+
if (urgent_update) {
;
} else if (wait > 2*waitms) {
/* bog case, break it up */
nap_sleep(wait, 10);
} else {
+ double t1, t2;
+ int idt;
+ if (extra_fbur > 0) {
+ int i;
+ for (i=0; i <= extra_fbur; i++) {
+ int r = rfbPE(0);
+ if (!r) break;
+ }
+ }
+
+ /* sometimes the sleep is too short, so measure it: */
+ t1 = dnow();
usleep(wait * 1000);
+ t2 = dnow();
+
+ idt = (int) (1000. * (t2 - t1));
+ if (idt > 0 && idt < wait) {
+ /* try to sleep the remainder */
+ usleep((wait - idt) * 1000);
+ }
}
cnt++;