diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-03 15:04:31 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-04-04 18:47:48 -0400 |
commit | d053acbed6fea0f73eb79ac800c1342f8afadeb8 (patch) | |
tree | 76a170cc89fdf111dfef0de45b1fe7ce06bf62e9 /swaylock/password.c | |
parent | e902de34db2354335c1cbd6baf2fcf7e82509b63 (diff) |
R E N D E R I N G
Diffstat (limited to 'swaylock/password.c')
-rw-r--r-- | swaylock/password.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/swaylock/password.c b/swaylock/password.c index 9af7fe16..2bdf151f 100644 --- a/swaylock/password.c +++ b/swaylock/password.c @@ -50,21 +50,23 @@ static bool attempt_password(struct swaylock_password *pw) { wlr_log(L_ERROR, "pam_end failed"); goto fail; } - // PAM freed this + // PAM frees this pw->buffer = NULL; pw->len = pw->size = 0; return true; fail: - // PAM freed this + // PAM frees this pw->buffer = NULL; pw->len = pw->size = 0; return false; } -static void backspace(struct swaylock_password *pw) { +static bool backspace(struct swaylock_password *pw) { if (pw->len != 0) { pw->buffer[--pw->len] = 0; + return true; } + return false; } static void append_ch(struct swaylock_password *pw, uint32_t codepoint) { @@ -97,17 +99,27 @@ void swaylock_handle_key(struct swaylock_state *state, switch (keysym) { case XKB_KEY_KP_Enter: /* fallthrough */ case XKB_KEY_Return: + state->auth_state = AUTH_STATE_VALIDATING; + render_frames(state); if (attempt_password(&state->password)) { exit(0); } + state->auth_state = AUTH_STATE_INVALID; + render_frames(state); break; case XKB_KEY_BackSpace: - backspace(&state->password); + if (backspace(&state->password)) { + state->auth_state = AUTH_STATE_BACKSPACE; + render_frames(state); + } break; default: if (codepoint) { append_ch(&state->password, codepoint); + state->auth_state = AUTH_STATE_INPUT; + render_frames(state); } break; } + // TODO: Expire state in a few seconds } |