X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=driver%2Fxscreensaver.c;h=4460c19df6125b9c358df07e4a3a179bb06f98e4;hp=7b16c898aaab4d95f22aa643084ed3842b2cd772;hb=551b3de3f619c04c2dd1971ee9b3f02e270c28c9;hpb=59ac4e9a0de290e4275a7bbb890ad16abd09d68f diff --git a/driver/xscreensaver.c b/driver/xscreensaver.c index 7b16c898..4460c19d 100644 --- a/driver/xscreensaver.c +++ b/driver/xscreensaver.c @@ -419,12 +419,29 @@ set_version_string (saver_info *si, int *argc, char **argv) static void privileged_initialization (saver_info *si, int *argc, char **argv) { +#ifndef NO_LOCKING + /* before hack_uid() for proper permissions */ + lock_priv_init (*argc, argv, si->prefs.verbose_p); +#endif /* NO_LOCKING */ + +#ifndef NO_SETUID + hack_uid (si); +#endif /* NO_SETUID */ +} + + +/* Figure out what locking mechanisms are supported. + */ +static void +lock_initialization (saver_info *si, int *argc, char **argv) +{ #ifdef NO_LOCKING si->locking_disabled_p = True; si->nolock_reason = "not compiled with locking support"; #else /* !NO_LOCKING */ si->locking_disabled_p = False; - /* before hack_uid() for proper permissions */ + + /* Finish initializing locking, now that we're out of privileged code. */ if (! lock_init (*argc, argv, si->prefs.verbose_p)) { si->locking_disabled_p = True; @@ -879,7 +896,25 @@ main_loop (saver_info *si) maybe_reload_init_file (si); - blank_screen (si); + if (! blank_screen (si)) + { + /* We were unable to grab either the keyboard or mouse. + This means we did not (and must not) blank the screen. + If we were to blank the screen while some other program + is holding both the mouse and keyboard grabbed, then + we would never be able to un-blank it! We would never + see any events, and the display would be wedged. + + So, just go around the loop again and wait for the + next bout of idleness. + */ + + fprintf (stderr, + "%s: unable to grab keyboard or mouse! Blanking aborted.\n", + blurb()); + continue; + } + kill_screenhack (si); spawn_screenhack (si, True); @@ -997,6 +1032,7 @@ main (int argc, char **argv) exit (1); load_init_file (p); + lock_initialization (si, &argc, argv); if (p->xsync_p) XSynchronize (si->dpy, True); blurb_timestamp_p = p->timestamp_p; /* kludge */