mirror of
https://github.com/alrayyes/slock
synced 2023-11-13 18:16:41 +00:00
50 lines
1.3 KiB
Diff
50 lines
1.3 KiB
Diff
|
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 <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <unistd.h>
|
||
|
+#include <time.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <X11/extensions/Xrandr.h>
|
||
|
#include <X11/extensions/dpms.h>
|
||
|
@@ -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;
|
||
|
}
|
||
|
|