summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2023-05-02 21:00:41 -0400
committerSimon Ser <contact@emersion.fr>2023-05-09 12:40:41 +0200
commit31ebd85fe09701146b7275de1ec8c8e9ce3c15c6 (patch)
treec794f6e7a982a5ffc6d60f3aef0bbec66ce16f8a /include
parent876965f944f127a32c0265bcaa47f716d9e1451b (diff)
Separate input and auth state
This commit establishes separate state machines for auth state (whether the password submitted is being verified or is wrong) and input state (typing indicators and clear message -- things relevant to the state of the password being typed in, before it is submitted.) This makes it possible to display the auth state while updating the input state (for example, show that the previously submitted password is 'verifying' or 'wrong' while typing another.) The two state machines interact only when submitting a password. There is some interference with the rendering code -- a 'cleared' message from the input state machine supersedes verifying/wrong messages from the auth state machine; although since the 'clear' state has a shorter timeout than the auth 'invalid' state, this is unlikely to hide the 'wrong' message.
Diffstat (limited to 'include')
-rw-r--r--include/swaylock.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/include/swaylock.h b/include/swaylock.h
index d855627..0eea1b3 100644
--- a/include/swaylock.h
+++ b/include/swaylock.h
@@ -8,14 +8,20 @@
#include "pool-buffer.h"
#include "seat.h"
+// Indicator state: status of authentication attempt
enum auth_state {
- AUTH_STATE_IDLE,
- AUTH_STATE_CLEAR,
- AUTH_STATE_INPUT,
- AUTH_STATE_INPUT_NOP,
- AUTH_STATE_BACKSPACE,
- AUTH_STATE_VALIDATING,
- AUTH_STATE_INVALID,
+ AUTH_STATE_IDLE, // nothing happening
+ AUTH_STATE_VALIDATING, // currently validating password
+ AUTH_STATE_INVALID, // displaying message: password was wrong
+};
+
+// Indicator state: status of password buffer / typing letters
+enum input_state {
+ INPUT_STATE_IDLE, // nothing happening; other states decay to this after time
+ INPUT_STATE_CLEAR, // displaying message: password buffer was cleared
+ INPUT_STATE_LETTER, // pressed a key that input a letter
+ INPUT_STATE_BACKSPACE, // pressed backspace and removed a letter
+ INPUT_STATE_NEUTRAL, // pressed a key (like Ctrl) that did nothing
};
struct swaylock_colorset {
@@ -73,7 +79,8 @@ struct swaylock_password {
struct swaylock_state {
struct loop *eventloop;
- struct loop_timer *clear_indicator_timer; // clears the indicator
+ struct loop_timer *input_idle_timer; // timer to reset input state to IDLE
+ struct loop_timer *auth_idle_timer; // timer to stop displaying AUTH_STATE_INVALID
struct loop_timer *clear_password_timer; // clears the password buffer
struct wl_display *display;
struct wl_compositor *compositor;
@@ -86,7 +93,8 @@ struct swaylock_state {
struct swaylock_xkb xkb;
cairo_surface_t *test_surface;
cairo_t *test_cairo; // used to estimate font/text sizes
- enum auth_state auth_state;
+ enum auth_state auth_state; // state of the authentication attempt
+ enum input_state input_state; // state of the password buffer and key inputs
uint32_t highlight_start; // position of highlight; 2048 = 1 full turn
int failed_attempts;
bool run_display, locked;
@@ -129,7 +137,7 @@ void render_frame(struct swaylock_surface *surface);
void damage_surface(struct swaylock_surface *surface);
void damage_state(struct swaylock_state *state);
void clear_password_buffer(struct swaylock_password *pw);
-void schedule_indicator_clear(struct swaylock_state *state);
+void schedule_auth_idle(struct swaylock_state *state);
void initialize_pw_backend(int argc, char **argv);
void run_pw_backend_child(void);