Skip to content

Commit

Permalink
Add very quick and dirty display of backend messages to UI
Browse files Browse the repository at this point in the history
This is just for testing, has to be properly implemented. With e.g. a
fingerprint reader there is no time to read 'Failed to match
fingerprint' messages and of course the text goes out the circle.
There's also a bunch of issues with timers, e.g. first entering the
wrong fingerprint ~5 times and then typing an incorrect password causes
the UI to go to a weird state.
  • Loading branch information
mgunyho committed Jan 4, 2025
1 parent e0775f4 commit a3f5184
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/swaylock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum auth_state {
AUTH_STATE_IDLE, // nothing happening
AUTH_STATE_VALIDATING, // currently validating password
AUTH_STATE_INVALID, // displaying message: password was wrong
AUTH_STATE_BACKEND_MSG, // displaying message from backend //TODO: WIP
};

// Indicator state: status of password buffer / typing letters
Expand Down Expand Up @@ -94,6 +95,7 @@ struct swaylock_state {
cairo_surface_t *test_surface;
cairo_t *test_cairo; // used to estimate font/text sizes
enum auth_state auth_state; // state of the authentication attempt
char *backend_msg; // message from the backend, will be NULL if empty //TODO: WIP
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;
Expand Down
6 changes: 5 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,12 @@ static void display_in(int fd, short mask, void *data) {
}

static void handle_backend_text_message(char *msg) {
//TODO: show message in UI
swaylock_log(LOG_DEBUG, "Received text message from backend: %s", msg);

//TODO: proper implementation
state.auth_state = AUTH_STATE_BACKEND_MSG;
state.backend_msg = msg;
damage_state(&state);
}

static void handle_auth_result(bool success) {
Expand Down
2 changes: 2 additions & 0 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ static bool render_frame(struct swaylock_surface *surface) {
text = "Verifying";
} else if (state->auth_state == AUTH_STATE_INVALID) {
text = "Wrong";
} else if (state->auth_state == AUTH_STATE_BACKEND_MSG && state->backend_msg) { //TODO: proper implementation
text = state->backend_msg;
} else {
// Caps Lock has higher priority
if (state->xkb.caps_lock && state->args.show_caps_lock_text) {
Expand Down

0 comments on commit a3f5184

Please sign in to comment.