Ignore empty passwd after repeated Enter keypress
Patch status: merged
Patch by Vytautas Šaltenis
Long description:
When no ignore_empty_password flag is specified, but Enter key is held down for some time, i3lock enters a finite, but hours-long loop verifying empty password. Don't do that, skip empty password verification if nothing was pressed after last Enter keypress. Again, making the software cat-proof.
To apply this patch, use:
curl http://cr.i3wm.org/patch/489/raw.patch | git am
b/i3lock.c
19 |
@@ -74,6 +74,7 @@ static struct xkb_keymap *xkb_keymap; |
20 |
cairo_surface_t *img = NULL; |
21 |
bool tile = false; |
22 |
bool ignore_empty_password = false; |
23 |
+bool skip_repeated_empty_password = false; |
24 |
|
25 |
/* isutf, u8_dec © 2005 Jeff Bezanson, public domain */ |
26 |
#define isutf(c) (((c) & 0xC0) != 0x80) |
27 |
@@ -325,6 +326,16 @@ static void redraw_timeout(EV_P_ ev_timer *w, int revents) { |
28 |
free(w); |
29 |
} |
30 |
|
31 |
+static bool skip_without_validation(void) { |
32 |
+ if (input_position != 0) |
33 |
+ return false; |
34 |
+ |
35 |
+ if (skip_repeated_empty_password || ignore_empty_password) |
36 |
+ return true; |
37 |
+ |
38 |
+ return false; |
39 |
+} |
40 |
+ |
41 |
/* |
42 |
* Handle key presses. Fixes state, then looks up the key symbol for the |
43 |
* given keycode, then looks up the key symbol (as UCS-2), converts it to |
44 |
@@ -349,7 +360,7 @@ static void handle_key_press(xcb_key_press_event_t *event) { |
45 |
case XKB_KEY_Return: |
46 |
case XKB_KEY_KP_Enter: |
47 |
case XKB_KEY_XF86ScreenSaver: |
48 |
- if (ignore_empty_password && input_position == 0) { |
49 |
+ if (skip_without_validation()) { |
50 |
clear_input(); |
51 |
return; |
52 |
} |
53 |
@@ -357,8 +368,13 @@ static void handle_key_press(xcb_key_press_event_t *event) { |
54 |
unlock_state = STATE_KEY_PRESSED; |
55 |
redraw_screen(); |
56 |
input_done(); |
57 |
+ skip_repeated_empty_password = true; |
58 |
return; |
59 |
+ default: |
60 |
+ skip_repeated_empty_password = false; |
61 |
+ } |
62 |
|
63 |
+ switch (ksym) { |
64 |
case XKB_KEY_u: |
65 |
if (ctrl) { |
66 |
DEBUG("C-u pressed\n"); |