X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fwindows.c;h=29e046190fed02b12ece386ba3a496c2c3d875bf;hb=82c5080773aae5e72ec155327c075775e023d2ee;hp=21eb6a39aac25a71b15d7aed591f5fdc2d2c78fd;hpb=72c1f4c1dc6ab07fe121a327ff1c30bf51ef74c1;p=xscreensaver diff --git a/driver/windows.c b/driver/windows.c index 21eb6a39..29e04619 100644 --- a/driver/windows.c +++ b/driver/windows.c @@ -1,5 +1,5 @@ /* windows.c --- turning the screen black; dealing with visuals, virtual roots. - * xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski + * xscreensaver, Copyright (c) 1991-2001 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -159,28 +159,39 @@ static Bool grab_keyboard_and_mouse (saver_info *si, Window window, Cursor cursor) { Status mstatus, kstatus; - XSync (si->dpy, False); + int i; + int retries = 4; - kstatus = grab_kbd (si, window); - if (kstatus != GrabSuccess) - { /* try again in a second */ - sleep (1); + for (i = 0; i < retries; i++) + { + XSync (si->dpy, False); kstatus = grab_kbd (si, window); - if (kstatus != GrabSuccess) - fprintf (stderr, "%s: couldn't grab keyboard! (%s)\n", - blurb(), grab_string(kstatus)); - } + if (kstatus == GrabSuccess) + break; - mstatus = grab_mouse (si, window, cursor); - if (mstatus != GrabSuccess) - { /* try again in a second */ + /* else, wait a second and try to grab again. */ sleep (1); + } + + if (kstatus != GrabSuccess) + fprintf (stderr, "%s: couldn't grab keyboard! (%s)\n", + blurb(), grab_string(kstatus)); + + for (i = 0; i < retries; i++) + { + XSync (si->dpy, False); mstatus = grab_mouse (si, window, cursor); - if (mstatus != GrabSuccess) - fprintf (stderr, "%s: couldn't grab pointer! (%s)\n", - blurb(), grab_string(mstatus)); + if (mstatus == GrabSuccess) + break; + + /* else, wait a second and try to grab again. */ + sleep (1); } + if (mstatus != GrabSuccess) + fprintf (stderr, "%s: couldn't grab pointer! (%s)\n", + blurb(), grab_string(mstatus)); + return (kstatus == GrabSuccess || mstatus == GrabSuccess); } @@ -651,14 +662,10 @@ saver_exit (saver_info *si, int status, const char *dump_core_reason) vrs = restore_real_vroot_1 (si); emergency_kill_subproc (si); + shutdown_stderr (si); - if (p->verbose_p) /* nobody cares about this */ - { - if (vrs) - fprintf (real_stderr, "%s: vroot restored, exiting.\n", blurb()); - else if (p->verbose_p) - fprintf (real_stderr, "%s: no vroot to restore; exiting.\n", blurb()); - } + if (p->verbose_p && vrs) + fprintf (real_stderr, "%s: old vroot restored.\n", blurb()); fflush(real_stdout); @@ -1470,16 +1477,14 @@ select_visual (saver_screen_info *ssi, const char *visual_name) visual_name = "default"; install_cmap_p = False; } -#ifdef DAEMON_USE_GL else if (!strcmp(visual_name, "gl") || !strcmp(visual_name, "Gl") || !strcmp(visual_name, "GL")) { - new_v = get_gl_visual (ssi->screen); + new_v = ssi->best_gl_visual; if (!new_v && p->verbose_p) fprintf (stderr, "%s: no GL visuals.\n", progname); } -#endif /* DAEMON_USE_GL */ if (!new_v) new_v = get_visual (ssi->screen, visual_name, True, False);