summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVytautas Ĺ altenis <vytas@rtfb.lt>2014-03-02 23:53:42 +0200
committerMichael Stapelberg <michael@stapelberg.de>2014-03-11 09:09:02 +0100
commitd91fdc368e4e119f4673e23741dbf2718624de45 (patch)
tree88a8cde2cf4b308007a4bbb4f896380df7c10fb7
parent6c34f6aa4057af48d1f68f8721172dd33cb0a7ea (diff)
Extract if(dpms) calls to wrapper functions
-rw-r--r--i3lock.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/i3lock.c b/i3lock.c
index 8c33ea4..28a93f0 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -73,6 +73,16 @@ void u8_dec(char *s, int *i) {
(void)(isutf(s[--(*i)]) || isutf(s[--(*i)]) || isutf(s[--(*i)]) || --(*i));
}
+static void turn_monitors_on(void) {
+ if (dpms)
+ dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_ON);
+}
+
+static void turn_monitors_off(void) {
+ if (dpms)
+ dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
+}
+
/*
* Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
* Necessary so that we can properly let xkbcommon track the keyboard state and
@@ -214,8 +224,7 @@ static void input_done(void) {
clear_password_memory();
/* Turn the screen on, as it may have been turned off
* on release of the 'enter' key. */
- if (dpms)
- dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_ON);
+ turn_monitors_on();
exit(0);
}
@@ -500,8 +509,8 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
/* If this was the backspace or escape key we are back at an
* empty input, so turn off the screen if DPMS is enabled */
- if (dpms && input_position == 0)
- dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
+ if (input_position == 0)
+ turn_monitors_off();
break;
@@ -774,8 +783,7 @@ int main(int argc, char *argv[]) {
* keyboard. */
(void)load_keymap();
- if (dpms)
- dpms_set_mode(conn, XCB_DPMS_DPMS_MODE_OFF);
+ turn_monitors_off();
/* Initialize the libev event loop. */
main_loop = EV_DEFAULT;