i3 - improved tiling WM


Delay to turn off the screen after wrong passwd

Patch status: needinfo

Patch by Vytautas Ĺ altenis

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

b/i3lock.c

13
@@ -34,6 +34,7 @@
14
 #include "unlock_indicator.h"
15
 #include "xinerama.h"
16
 
17
+#define TSTAMP_N_SECS(n) (n * 1.0)
18
 #define START_TIMER(timer_obj, timeout, callback) \
19
     timer_obj = start_timer(timer_obj, timeout, callback)
20
 #define STOP_TIMER(timer_obj) \
21
@@ -59,6 +60,7 @@ static bool dont_fork = false;
22
 struct ev_loop *main_loop;
23
 static struct ev_timer *clear_pam_wrong_timeout;
24
 static struct ev_timer *clear_indicator_timeout;
25
+static struct ev_timer *dpms_timeout;
26
 extern unlock_state_t unlock_state;
27
 extern pam_state_t pam_state;
28
 
29
@@ -246,6 +248,13 @@ static void clear_input(void) {
30
     unlock_state = STATE_KEY_PRESSED;
31
 }
32
 
33
+static void turn_off_monitors_cb(EV_P_ ev_timer *w, int revents) {
34
+    if (input_position == 0)
35
+        turn_monitors_off();
36
+
37
+    STOP_TIMER(dpms_timeout);
38
+}
39
+
40
 static void input_done(void) {
41
     if (clear_pam_wrong_timeout) {
42
         ev_timer_stop(main_loop, clear_pam_wrong_timeout);
43
@@ -545,10 +554,10 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
44
                 handle_key_release((xcb_key_release_event_t*)event);
45
 
46
                 /* If this was the backspace or escape key we are back at an
47
-                 * empty input, so turn off the screen if DPMS is enabled */
48
-                if (input_position == 0)
49
-                    turn_monitors_off();
50
-
51
+                 * empty input, so turn off the screen if DPMS is enabled, but
52
+                 * only do that after some timeout: maybe user mistyped and
53
+                 * will type again right away */
54
+                START_TIMER(dpms_timeout, TSTAMP_N_SECS(30), turn_off_monitors_cb);
55
                 break;
56
 
57
             case XCB_VISIBILITY_NOTIFY: