quickcancel patch
This commit is contained in:
parent
983851a660
commit
af38bce536
@ -13,6 +13,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;
|
||||
|
||||
static const int logosize = 75;
|
||||
static const int logow = 12; /* Grid width and height for right center alignment*/
|
||||
static const int logoh = 6;
|
||||
|
66
patches/slock-quickcancel-1.4.diff
Normal file
66
patches/slock-quickcancel-1.4.diff
Normal file
@ -0,0 +1,66 @@
|
||||
From e37f8981efe54bc620cb2f2280832cdab3959a32 Mon Sep 17 00:00:00 2001
|
||||
From: aleks <aleks.stier@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
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
5
slock.c
5
slock.c
@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#ifdef XINERAMA
|
||||
@ -33,6 +34,8 @@
|
||||
|
||||
char *argv0;
|
||||
|
||||
static time_t locktime;
|
||||
|
||||
enum {
|
||||
BACKGROUND,
|
||||
INIT,
|
||||
@ -200,6 +203,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
||||
caps = indicators & 1;
|
||||
|
||||
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);
|
||||
@ -390,6 +394,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user