[wiki] [sites] [slock][patch][quickcancel] Port to 1.4 || aleks

From: <git_AT_suckless.org>
Date: Thu, 10 Oct 2019 17:41:11 +0200

commit 45d1a7f24ced7ab5a928f5ad859b61d99e47e6a8
Author: aleks <aleks.stier_AT_icloud.com>
Date: Thu Oct 10 17:40:53 2019 +0200

    [slock][patch][quickcancel] Port to 1.4

diff --git a/tools.suckless.org/slock/patches/quickcancel/index.md b/tools.suckless.org/slock/patches/quickcancel/index.md
index 360f1497..5516e514 100644
--- a/tools.suckless.org/slock/patches/quickcancel/index.md
+++ b/tools.suckless.org/slock/patches/quickcancel/index.md
_AT_@ -3,22 +3,15 @@ quickcancel
 
 Description
 -----------
-Allow slock to be cancelled by simple mouse movement within the
-first 3 seconds after starting.
-
-This is useful if you forgot to disable `xautolock` during
-an activity that requires no input (e.g. reading text, watching video).
-
-Notes
------
-The number of seconds while the lock can be cancelled is configured
-in `config.h` via the `timetocancel` option.
+Cancel slock by moving the mouse within a certain time-period after slock started. The time-period can be defined in seconds with the setting *timetocancel* in the config.h. This is useful if you forgot to disable `xautolock` during an activity that requires no input (e.g. reading text, watching video).
 
 Download
 --------
+* [slock-quickcancel-1.4.diff](slock-quickcancel-1.4.diff)
 * [slock-quickcancel-20160619-65b8d52.diff](slock-quickcancel-20160619-65b8d52.diff)
 
 Authors
 -------
 * Matthias Schoth - mschoth_AT_gmail.com
+* Aleksandrs Stier (1.4 port)
 
diff --git a/tools.suckless.org/slock/patches/quickcancel/slock-quickcancel-1.4.diff b/tools.suckless.org/slock/patches/quickcancel/slock-quickcancel-1.4.diff
new file mode 100644
index 00000000..f990806a
--- /dev/null
+++ b/tools.suckless.org/slock/patches/quickcancel/slock-quickcancel-1.4.diff
_AT_@ -0,0 +1,66 @@
+From e37f8981efe54bc620cb2f2280832cdab3959a32 Mon Sep 17 00:00:00 2001
+From: aleks <aleks.stier_AT_icloud.com>
+Date: Thu, 10 Oct 2019 17:35:27 +0200
+Subject: [PATCH] Apply quickcancel
+
+Cancel slock by moving the mouse within a certain time-period after
+slock started. The time-period can be defined in seconds with the
+setting *timetocancel* in the config.h. This is useful if you forgot to
+disable `xautolock` during an activity that requires no input (e.g.
+reading text, watching video).
+---
+ 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
+_AT_@ -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 d2f0886..f7462ee 100644
+--- a/slock.c
++++ b/slock.c
+_AT_@ -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/keysym.h>
+_AT_@ -24,6 +25,8 @@
+
+ char *argv0;
+
++static time_t locktime;
++
+ enum {
+ INIT,
+ INPUT,
+_AT_@ -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);
+_AT_@ -268,6 +272,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.23.0
+
Received on Thu Oct 10 2019 - 17:41:11 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 10 2019 - 17:48:30 CEST