From 32597530dc387f3cef966b38ebfca97e45128a76 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Mon, 24 May 2021 20:50:06 -0400 Subject: [PATCH] Apply quickcancel patch --- config.def.h | 3 +++ slock.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/config.def.h b/config.def.h index 9855e21..e0bf95a 100644 --- a/config.def.h +++ b/config.def.h @@ -10,3 +10,6 @@ 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; diff --git a/slock.c b/slock.c index 04665ff..4a10a94 100644 --- a/slock.c +++ b/slock.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,8 @@ char *argv0; +static time_t locktime; + enum { INIT, INPUT, @@ -141,6 +144,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); @@ -292,6 +296,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask); XSelectInput(dpy, lock->root, SubstructureNotifyMask); + locktime = time(NULL); return lock; } -- 2.39.2