summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-01-16 13:20:35 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-01-16 13:20:35 +0100
commit134756388105672448c444adb8991077fc0d12b9 (patch)
treee103a250da390f41b46cad2647fd4e0356bc53a8
parent156ed4787fd5f30811eb04dc45873a38ca54f73f (diff)
Apply quickcancel patch
-rw-r--r--config.def.h3
-rw-r--r--slock.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index c66a19f..a0305fb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,6 +12,9 @@ static const char *colorname[NUMCOLS] = {
/* treat a cleared input like a wrong password (color) */
static const int failonclear = 1;
+/* time in seconds to cancel lock with mouse movement */
+static const int timetocancel = 4;
+
/* time in seconds before the monitor shuts down */
static const int monitortime = 5;
diff --git a/slock.c b/slock.c
index 6ec145f..c273e62 100644
--- a/slock.c
+++ b/slock.c
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
#include <sys/types.h>
#include <X11/extensions/Xrandr.h>
#ifdef XINERAMA
@@ -30,6 +31,8 @@
char *argv0;
+static time_t locktime;
+
enum {
BACKGROUND,
INIT,
@@ -179,6 +182,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
oldc = INIT;
while (running && !XNextEvent(dpy, &ev)) {
+ running = !((time(NULL) - locktime < timetocancel) && (ev.type == MotionNotify));
if (ev.type == KeyPress) {
explicit_bzero(&buf, sizeof(buf));
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
@@ -337,6 +341,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
XSelectInput(dpy, lock->root, SubstructureNotifyMask);
+ locktime = time(NULL);
drawlogo(dpy, lock, INIT);
return lock;
}