i3 - improved tiling WM


Extract if(dpms) calls to wrapper functions

Patch status: merged

Patch by Vytautas Ĺ altenis

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

b/i3lock.c

13
@@ -73,6 +73,16 @@ void u8_dec(char *s, int *i) {
14
     (void)(isutf(s[--(*i)]) || isutf(s[--(*i)]) || isutf(s[--(*i)]) || --(*i));
15
 }
16
 
17
+static void turn_monitors_on(void) {
18
+    if (dpms)
19
+        dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_ON);
20
+}
21
+
22
+static void turn_monitors_off(void) {
23
+    if (dpms)
24
+        dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
25
+}
26
+
27
 /*
28
  * Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
29
  * Necessary so that we can properly let xkbcommon track the keyboard state and
30
@@ -214,8 +224,7 @@ static void input_done(void) {
31
         clear_password_memory();
32
         /* Turn the screen on, as it may have been turned off
33
          * on release of the 'enter' key. */
34
-        if (dpms)
35
-            dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_ON);
36
+        turn_monitors_on();
37
         exit(0);
38
     }
39
 
40
@@ -500,8 +509,8 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
41
 
42
                 /* If this was the backspace or escape key we are back at an
43
                  * empty input, so turn off the screen if DPMS is enabled */
44
-                if (dpms && input_position == 0)
45
-                    dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
46
+                if (input_position == 0)
47
+                    turn_monitors_off();
48
 
49
                 break;
50
 
51
@@ -774,8 +783,7 @@ int main(int argc, char *argv[]) {
52
      * keyboard. */
53
     (void)load_keymap();
54
 
55
-    if (dpms)
56
-        dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
57
+    turn_monitors_off();
58
 
59
     /* Initialize the libev event loop. */
60
     main_loop = EV_DEFAULT;