swaylock: Submit password on Ctrl-D

Ctrl-D functions as EOF in most cases on the terminal. login(1) & many other
programs check the password on EOF, same as Enter. To make behavior consistent,
have swaylock submit the password on Ctrl-D.

This commit moves the handling for Enter into its own static function, which is
now also called on Ctrl-D.
master
Milkey Mouse 6 years ago committed by emersion
parent 9877189ea3
commit 82b0296964

@ -77,13 +77,9 @@ static void handle_preverify_timeout(void *data) {
state->verify_password_timer = NULL; state->verify_password_timer = NULL;
} }
void swaylock_handle_key(struct swaylock_state *state, static void submit_password(struct swaylock_state *state) {
xkb_keysym_t keysym, uint32_t codepoint) {
switch (keysym) {
case XKB_KEY_KP_Enter: /* fallthrough */
case XKB_KEY_Return:
if (state->args.ignore_empty && state->password.len == 0) { if (state->args.ignore_empty && state->password.len == 0) {
break; return;
} }
state->auth_state = AUTH_STATE_VALIDATING; state->auth_state = AUTH_STATE_VALIDATING;
@ -118,11 +114,19 @@ void swaylock_handle_key(struct swaylock_state *state,
if (attempt_password(&state->password)) { if (attempt_password(&state->password)) {
state->run_display = false; state->run_display = false;
break; return;
} }
state->auth_state = AUTH_STATE_INVALID; state->auth_state = AUTH_STATE_INVALID;
damage_state(state); damage_state(state);
schedule_indicator_clear(state); schedule_indicator_clear(state);
}
void swaylock_handle_key(struct swaylock_state *state,
xkb_keysym_t keysym, uint32_t codepoint) {
switch (keysym) {
case XKB_KEY_KP_Enter: /* fallthrough */
case XKB_KEY_Return:
submit_password(state);
break; break;
case XKB_KEY_Delete: case XKB_KEY_Delete:
case XKB_KEY_BackSpace: case XKB_KEY_BackSpace:
@ -165,6 +169,12 @@ void swaylock_handle_key(struct swaylock_state *state,
schedule_indicator_clear(state); schedule_indicator_clear(state);
schedule_password_clear(state); schedule_password_clear(state);
break; break;
case XKB_KEY_d:
if (state->xkb.control) {
submit_password(state);
break;
}
// fallthrough
case XKB_KEY_c: /* fallthrough */ case XKB_KEY_c: /* fallthrough */
case XKB_KEY_u: case XKB_KEY_u:
if (state->xkb.control) { if (state->xkb.control) {

Loading…
Cancel
Save