Xinqi Bao's Git
projects
/
slock.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
increasing for loops are idiomatic
[slock.git]
/
slock.c
diff --git
a/slock.c
b/slock.c
index
0682279
..
08ada6f
100644
(file)
--- a/
slock.c
+++ b/
slock.c
@@
-46,8
+46,6
@@
typedef struct {
static Lock **locks;
static int nscreens;
static Lock **locks;
static int nscreens;
-static Bool running = True;
-static Bool failure = False;
static Bool rr;
static int rrevbase;
static int rrerrbase;
static Bool rr;
static int rrevbase;
static int rrerrbase;
@@
-132,14
+130,15
@@
readpw(Display *dpy, const char *pws)
#endif
{
char buf[32], passwd[256], *encrypted;
#endif
{
char buf[32], passwd[256], *encrypted;
- int num, screen;
+ int num, screen
, running, failure
;
unsigned int len, color;
KeySym ksym;
XEvent ev;
static int oldc = INIT;
len = 0;
unsigned int len, color;
KeySym ksym;
XEvent ev;
static int oldc = INIT;
len = 0;
- running = True;
+ running = 1;
+ failure = 0;
/* As "slock" stands for "Simple X display locker", the DPMS settings
* had been removed and you can set it with "xset" or some other
/* As "slock" stands for "Simple X display locker", the DPMS settings
* had been removed and you can set it with "xset" or some other
@@
-253,7
+252,7
@@
lockscreen(Display *dpy, int screen)
XSetWindowAttributes wa;
Cursor invisible;
XSetWindowAttributes wa;
Cursor invisible;
- if (
!running ||
dpy == NULL || screen < 0 || !(lock = malloc(sizeof(Lock))))
+ if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(Lock))))
return NULL;
lock->screen = screen;
return NULL;
lock->screen = screen;
@@
-275,7
+274,7
@@
lockscreen(Display *dpy, int screen)
XDefineCursor(dpy, lock->win, invisible);
/* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */
XDefineCursor(dpy, lock->win, invisible);
/* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */
- for (i =
6, ptgrab = kbgrab = -1; i; --i
) {
+ for (i =
0, ptgrab = kbgrab = -1; i < 6; i++
) {
if (ptgrab != GrabSuccess) {
ptgrab = XGrabPointer(dpy, lock->root, False,
ButtonPressMask | ButtonReleaseMask |
if (ptgrab != GrabSuccess) {
ptgrab = XGrabPointer(dpy, lock->root, False,
ButtonPressMask | ButtonReleaseMask |
@@
-376,7
+375,6
@@
main(int argc, char **argv) {
/* did we manage to lock everything? */
if (nlocks != nscreens) {
/* did we manage to lock everything? */
if (nlocks != nscreens) {
- running = 0;
cleanup(dpy);
return 1;
}
cleanup(dpy);
return 1;
}