Previously, if failonclear was set to True and a modifier key (especially shift) was pressed and held in order to modify the next keypress, slock would detect that a keypress had been made, observe that the buffer was clear and set the screen to the failure colour.
That behaviour is unwanted if the first key in a password is 'shift'.
The new behaviour will still turn slock to the failure colour if the shift key
is pressed, but only once it is released and the buffer is still clear.
---
slock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/slock.c b/slock.c
index df2d3c6..2a65f54 100644
--- a/slock.c
+++ b/slock.c
@@ -136,12 +136,15 @@ readpw(Display *dpy, const char *pws)
len = 0;
running = True;
+ /* slurp lingering key release events */
+ do XNextEvent(dpy, &ev); while (ev.type == KeyRelease);
+
/* As "slock" stands for "Simple X display locker", the DPMS settings
* had been removed and you can set it with "xset" or some other
* utility. This way the user can easily set a customized DPMS
* timeout. */
while (running && !XNextEvent(dpy, &ev)) {
- if (ev.type == KeyPress) {
+ if (ev.type == KeyRelease) {
buf[0] = 0;
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym,
0);
if (IsKeypadKey(ksym)) {
--
2.7.0
signature.asc
Description: PGP signature
