diff options
| author | Manuel Stoeckl <code@mstoeckl.com> | 2023-03-28 19:42:19 -0400 |
|---|---|---|
| committer | Kenny Levinsen <kl@kl.wtf> | 2023-04-02 02:34:19 +0200 |
| commit | 75e837c31abe2fa06167b6f1f1a253ab397faf81 (patch) | |
| tree | bdf655e80382c2555326fe3e3adc446b1e9902cc /password.c | |
| parent | 1d3e62c67f07a180fca02a6df1cf9648f2b50349 (diff) | |
Synchronize highlight position between outputs
This change has the additional benefit of ensuring that the position
of the highlight only changes in reaction to a letter key or
backspace being pressed, and not when the compositor sends a new
configure event or the output needs to be redrawn for some other
reason.
Diffstat (limited to 'password.c')
| -rw-r--r-- | password.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -93,6 +93,12 @@ static void submit_password(struct swaylock_state *state) { damage_state(state); } +static void update_highlight(struct swaylock_state *state) { + // Advance a random amount between 1/4 and 3/4 of a full turn + state->highlight_start = + (state->highlight_start + (rand() % 1024) + 512) % 2048; +} + void swaylock_handle_key(struct swaylock_state *state, xkb_keysym_t keysym, uint32_t codepoint) { // Ignore input events if validating @@ -109,6 +115,7 @@ void swaylock_handle_key(struct swaylock_state *state, case XKB_KEY_BackSpace: if (backspace(&state->password)) { state->auth_state = AUTH_STATE_BACKSPACE; + update_highlight(state); } else { state->auth_state = AUTH_STATE_CLEAR; } @@ -160,6 +167,7 @@ void swaylock_handle_key(struct swaylock_state *state, if (codepoint) { append_ch(&state->password, codepoint); state->auth_state = AUTH_STATE_INPUT; + update_highlight(state); damage_state(state); schedule_indicator_clear(state); schedule_password_clear(state); |
