From ac4213a136ef2783782143186d174f7e17dbd0cb Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Thu, 26 May 2016 08:35:16 -0500 Subject: clear password buffer with ctrl-u in swaylock also prevent screen redraws on modifier key presses --- swaylock/main.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/swaylock/main.c b/swaylock/main.c index 777bca09..96e3ec29 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -144,6 +144,40 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod } break; } + case XKB_KEY_Control_L: // fallthrough + case XKB_KEY_Control_R: // fallthrough + case XKB_KEY_Shift_L: // fallthrough + case XKB_KEY_Shift_R: // fallthrough + case XKB_KEY_Caps_Lock: // fallthrough + case XKB_KEY_Shift_Lock: // fallthrough + case XKB_KEY_Meta_L: // fallthrough + case XKB_KEY_Meta_R: // fallthrough + case XKB_KEY_Alt_L: // fallthrough + case XKB_KEY_Alt_R: // fallthrough + case XKB_KEY_Super_L: // fallthrough + case XKB_KEY_Super_R: // fallthrough + case XKB_KEY_Hyper_L: // fallthrough + case XKB_KEY_Hyper_R: // fallthrough + { + // don't draw screen on modifier keys + break; + } + case XKB_KEY_u: // fallthrough + case XKB_KEY_U: + { + // clear password buffer on ctrl-u + if (xkb_state_mod_name_is_active(registry->input->xkb.state, + XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE) > 0) { + render_data.auth_state = AUTH_STATE_BACKSPACE; + redraw_screen = 1; + + password_size = 1024; + free(password); + password = malloc(password_size); + password[0] = '\0'; + break; + } + } default: { render_data.auth_state = AUTH_STATE_INPUT; -- cgit v1.2.3-54-g00ecf From 06e06f9af2132cda9c26a2464486393e0ea76e28 Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Thu, 26 May 2016 08:41:22 -0500 Subject: clear swaylock password buffer with esc for i3lock compatibility --- swaylock/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swaylock/main.c b/swaylock/main.c index 96e3ec29..666e59d2 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -162,11 +162,12 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod // don't draw screen on modifier keys break; } + case XKB_KEY_Escape: // fallthrough case XKB_KEY_u: // fallthrough case XKB_KEY_U: { - // clear password buffer on ctrl-u - if (xkb_state_mod_name_is_active(registry->input->xkb.state, + // clear password buffer on ctrl-u (or escape for i3lock compatibility) + if (sym == XKB_KEY_Escape || xkb_state_mod_name_is_active(registry->input->xkb.state, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE) > 0) { render_data.auth_state = AUTH_STATE_BACKSPACE; redraw_screen = 1; -- cgit v1.2.3-54-g00ecf