From c997e901c4c268438d063a78bdb121b8f5e8d585 Mon Sep 17 00:00:00 2001 From: runge Date: Mon, 6 Mar 2006 16:29:35 +0000 Subject: x11vnc: gui speedup and fixes. -unixpw and -inetd --- x11vnc/gui.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'x11vnc/gui.c') diff --git a/x11vnc/gui.c b/x11vnc/gui.c index b82e921..32bc51a 100644 --- a/x11vnc/gui.c +++ b/x11vnc/gui.c @@ -22,6 +22,7 @@ int tray_manager_ok = 0; Window tray_request = None; Window tray_window = None; int tray_unembed = 0; +pid_t run_gui_pid = 0; char *get_gui_code(void); @@ -183,6 +184,12 @@ static char *icon_mode_embed_id = NULL; static char *icon_mode_font = NULL; static char *icon_mode_params = NULL; +static int got_sigusr1 = 0; + +static void sigusr1 (int sig) { + got_sigusr1 = 1; +} + static void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int start_x11vnc, int simple_gui, pid_t parent, char *gui_opts) { char *x11vnc_xdisplay = NULL; @@ -191,10 +198,11 @@ static void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int start_x11vnc, char cmd[100]; char *wish = NULL, *orig_path, *full_path, *tpath, *p; char *old_xauth = NULL; - int try_max = 4, sleep = 300; + int try_max = 4, sleep = 300, totms; pid_t mypid = getpid(); FILE *pipe, *tmpf; +if (0) fprintf(stderr, "run_gui: %s -- %d %d\n", gui_xdisplay, connect_to_x11vnc, (int) parent); if (*gui_code == '\0') { rfbLog("gui: gui not compiled into this program.\n"); exit(0); @@ -234,21 +242,44 @@ static void run_gui(char *gui_xdisplay, int connect_to_x11vnc, int start_x11vnc, scr = DefaultScreen(dpy); rootwin = RootWindow(dpy, scr); initialize_vnc_connect_prop(); + initialize_x11vnc_remote_prop(); + } + + signal(SIGUSR1, sigusr1); + got_sigusr1 = 0; + totms = 0; + while (totms < 3500) { + usleep(50*1000); + totms += 50; + if (got_sigusr1) { + fprintf(stderr, "\n"); + if (! quiet) rfbLog("gui: got SIGUSR1\n"); + break; + } + if (! start_x11vnc && totms >= 150) { + break; + } } - usleep(2200*1000); - fprintf(stderr, "\n"); - if (!quiet) { + signal(SIGUSR1, SIG_DFL); + if (! got_sigusr1) fprintf(stderr, "\n"); + + if (!quiet && ! got_sigusr1) { rfbLog("gui: trying to contact a x11vnc server at X" " display %s ...\n", NONUL(x11vnc_xdisplay)); } + for (i=0; i