diff -up a/config.def.h b/config.def.h --- a/config.def.h +++ b/config.def.h @@ -13,3 +13,9 @@ static const int failonclear = 1; /* time in seconds before the monitor shuts down */ static const int monitortime = 5; + +/* treat a cleared input like a wrong password */ +static const int failonclear = 1; + +/* time to cancel lock with mouse movement in seconds */ +static const int timetocancel = 3; diff -up a/slock.c b/slock.c --- a/slock.c +++ b/slock.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,8 @@ #include "arg.h" #include "util.h" +static time_t tim; + char *argv0; enum { @@ -142,6 +145,7 @@ readpw(Display *dpy, struct xrandr *rr, oldc = INIT; while (running && !XNextEvent(dpy, &ev)) { + running = !((time(NULL) - tim < timetocancel) && (ev.type == MotionNotify)); if (ev.type == KeyPress) { explicit_bzero(&buf, sizeof(buf)); num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0); @@ -269,6 +273,7 @@ lockscreen(Display *dpy, struct xrandr * XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask); XSelectInput(dpy, lock->root, SubstructureNotifyMask); + tim = time(NULL); return lock; }