i3 - improved tiling WM


Discard half-entered passwd after some inactivity

Patch status: merged

Patch by Vytautas Ĺ altenis

Long description:

When you start typing a password and then wander off, let's discard that
attempt after a few minutes of inactivity (and turn off the monitors if
dpms is on).

This is a real actual case of making the software cat-proof: when my cat
treads over the keyboard at night, I don't want the monitors to shine
for the rest of the night.

To apply this patch, use:
curl http://cr.i3wm.org/patch/487/raw.patch | git am

b/i3lock.c

20
@@ -35,6 +35,7 @@
21
 #include "xinerama.h"
22
 
23
 #define TSTAMP_N_SECS(n) (n * 1.0)
24
+#define TSTAMP_N_MINS(n) (60 * TSTAMP_N_SECS(n))
25
 #define START_TIMER(timer_obj, timeout, callback) \
26
     timer_obj = start_timer(timer_obj, timeout, callback)
27
 #define STOP_TIMER(timer_obj) \
28
@@ -62,6 +63,7 @@ struct ev_loop *main_loop;
29
 static struct ev_timer *clear_pam_wrong_timeout;
30
 static struct ev_timer *clear_indicator_timeout;
31
 static struct ev_timer *dpms_timeout;
32
+static struct ev_timer *discard_passwd_timeout;
33
 extern unlock_state_t unlock_state;
34
 extern pam_state_t pam_state;
35
 
36
@@ -256,6 +258,12 @@ static void turn_off_monitors_cb(EV_P_ ev_timer *w, int revents) {
37
     STOP_TIMER(dpms_timeout);
38
 }
39
 
40
+static void discard_passwd_cb(EV_P_ ev_timer *w, int revents) {
41
+    clear_input();
42
+    turn_monitors_off();
43
+    STOP_TIMER(discard_passwd_timeout);
44
+}
45
+
46
 static void input_done(void) {
47
     if (clear_pam_wrong_timeout) {
48
         ev_timer_stop(main_loop, clear_pam_wrong_timeout);
49
@@ -413,6 +421,7 @@ static void handle_key_press(xcb_key_press_event_t *event) {
50
     }
51
 
52
     STOP_TIMER(clear_indicator_timeout);
53
+    START_TIMER(discard_passwd_timeout, TSTAMP_N_MINS(3), discard_passwd_cb);
54
 }
55
 
56
 /*