i3 - improved tiling WM


Turn on the screen on successful authentication

Patch status: needinfo

Patch by Philippe Virouleau

Long description:

This fixes the behaviour described in ticket #1114, where the screen could be
left turned off on successful authentication..

Fixes #1114

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

b/i3lock.c

19
@@ -212,6 +212,8 @@ static void input_done(void) {
20
     if (pam_authenticate(pam_handle, 0) == PAM_SUCCESS) {
21
         DEBUG("successfully authenticated\n");
22
         clear_password_memory();
23
+        if (dpms)
24
+            dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_ON);
25
         exit(0);
26
     }
27
 
28
@@ -497,7 +499,7 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
29
                 /* If this was the backspace or escape key we are back at an
30
                  * empty input, so turn off the screen if DPMS is enabled */
31
                 if (dpms && input_position == 0)
32
-                    dpms_turn_off_screen(conn);
33
+                    dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
34
 
35
                 break;
36
 
37
@@ -771,7 +773,7 @@ int main(int argc, char *argv[]) {
38
     (void)load_keymap();
39
 
40
     if (dpms)
41
-        dpms_turn_off_screen(conn);
42
+        dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
43
 
44
     /* Initialize the libev event loop. */
45
     main_loop = EV_DEFAULT;

b/xcb.c

50
@@ -155,9 +155,13 @@ xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, c
51
     return win;
52
 }
53
 
54
-void dpms_turn_off_screen(xcb_connection_t *conn) {
55
+/*
56
+ * Set the dpms level to 'mode'.
57
+ *
58
+ */
59
+void dpms_set_mode(xcb_connection_t *conn, xcb_dpms_dpms_mode_t mode) {
60
     xcb_dpms_enable(conn);
61
-    xcb_dpms_force_level(conn, XCB_DPMS_DPMS_MODE_OFF);
62
+    xcb_dpms_force_level(conn, mode);
63
     xcb_flush(conn);
64
 }
65
 

b/xcb.h

70
@@ -2,6 +2,7 @@
71
 #define _XCB_H
72
 
73
 #include <xcb/xcb.h>
74
+#include <xcb/dpms.h>
75
 
76
 extern xcb_connection_t *conn;
77
 extern xcb_screen_t *screen;
78
@@ -10,7 +11,7 @@ xcb_visualtype_t *get_root_visual_type(xcb_screen_t *s);
79
 xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, u_int32_t *resolution, char *color);
80
 xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color, xcb_pixmap_t pixmap);
81
 void grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_t cursor);
82
-void dpms_turn_off_screen(xcb_connection_t *conn);
83
+void dpms_set_mode(xcb_connection_t *conn, xcb_dpms_dpms_mode_t mode);
84
 xcb_cursor_t create_cursor(xcb_connection_t *conn, xcb_screen_t *screen, xcb_window_t win, int choice);
85
 
86
 #endif