slock with DPMS and other tweaks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move screen unlocking inside cleanup()

authored by

Quentin Rameau and committed by
Markus Teich
39fb855a e378f735

+11 -9
+11 -9
slock.c
··· 234 234 static void 235 235 cleanup(Display *dpy) 236 236 { 237 + int s; 238 + 239 + for (s = 0; s < nscreens; ++s) 240 + unlockscreen(dpy, locks[s]); 241 + 237 242 free(locks); 238 243 XCloseDisplay(dpy); 239 244 } ··· 305 310 fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen); 306 311 if (kbgrab != GrabSuccess) 307 312 fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen); 308 - running = 0; 309 - unlockscreen(dpy, lock); 310 313 return NULL; 311 314 } 312 315 ··· 359 362 360 363 /* get number of screens in display "dpy" and blank them */ 361 364 nscreens = ScreenCount(dpy); 362 - if (!(locks = malloc(sizeof(Lock *) * nscreens))) { 365 + if (!(locks = calloc(nscreens, sizeof(Lock *)))) { 363 366 XCloseDisplay(dpy); 364 367 die("slock: out of memory\n"); 365 368 } 366 369 for (nlocks = 0, s = 0; s < nscreens; s++) { 367 370 if ((locks[s] = lockscreen(dpy, s)) != NULL) 368 371 nlocks++; 372 + else 373 + break; 369 374 } 370 375 XSync(dpy, 0); 371 376 372 - /* did we actually manage to lock anything? */ 373 - if (nlocks == 0) { 374 - /* nothing to protect */ 377 + /* did we manage to lock everything? */ 378 + if (nlocks != nscreens) { 379 + running = 0; 375 380 cleanup(dpy); 376 381 return 1; 377 382 } ··· 400 405 #endif 401 406 402 407 /* password ok, unlock everything and quit */ 403 - for (s = 0; s < nscreens; s++) 404 - unlockscreen(dpy, locks[s]); 405 - 406 408 cleanup(dpy); 407 409 408 410 return 0;