mirror of
https://github.com/mintycube/slock.git
synced 2024-10-22 14:05:51 +02:00
Move screen unlocking inside cleanup()
This commit is contained in:
parent
e378f735d8
commit
39fb855aa1
20
slock.c
20
slock.c
@ -234,6 +234,11 @@ unlockscreen(Display *dpy, Lock *lock)
|
|||||||
static void
|
static void
|
||||||
cleanup(Display *dpy)
|
cleanup(Display *dpy)
|
||||||
{
|
{
|
||||||
|
int s;
|
||||||
|
|
||||||
|
for (s = 0; s < nscreens; ++s)
|
||||||
|
unlockscreen(dpy, locks[s]);
|
||||||
|
|
||||||
free(locks);
|
free(locks);
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
@ -305,8 +310,6 @@ lockscreen(Display *dpy, int screen)
|
|||||||
fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen);
|
fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n", screen);
|
||||||
if (kbgrab != GrabSuccess)
|
if (kbgrab != GrabSuccess)
|
||||||
fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen);
|
fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen);
|
||||||
running = 0;
|
|
||||||
unlockscreen(dpy, lock);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,19 +362,21 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* get number of screens in display "dpy" and blank them */
|
/* get number of screens in display "dpy" and blank them */
|
||||||
nscreens = ScreenCount(dpy);
|
nscreens = ScreenCount(dpy);
|
||||||
if (!(locks = malloc(sizeof(Lock *) * nscreens))) {
|
if (!(locks = calloc(nscreens, sizeof(Lock *)))) {
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
die("slock: out of memory\n");
|
die("slock: out of memory\n");
|
||||||
}
|
}
|
||||||
for (nlocks = 0, s = 0; s < nscreens; s++) {
|
for (nlocks = 0, s = 0; s < nscreens; s++) {
|
||||||
if ((locks[s] = lockscreen(dpy, s)) != NULL)
|
if ((locks[s] = lockscreen(dpy, s)) != NULL)
|
||||||
nlocks++;
|
nlocks++;
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
XSync(dpy, 0);
|
XSync(dpy, 0);
|
||||||
|
|
||||||
/* did we actually manage to lock anything? */
|
/* did we manage to lock everything? */
|
||||||
if (nlocks == 0) {
|
if (nlocks != nscreens) {
|
||||||
/* nothing to protect */
|
running = 0;
|
||||||
cleanup(dpy);
|
cleanup(dpy);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -400,9 +405,6 @@ main(int argc, char **argv) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* password ok, unlock everything and quit */
|
/* password ok, unlock everything and quit */
|
||||||
for (s = 0; s < nscreens; s++)
|
|
||||||
unlockscreen(dpy, locks[s]);
|
|
||||||
|
|
||||||
cleanup(dpy);
|
cleanup(dpy);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user