swaylock: Don't wait too long for surface damage before verifying

This commit is contained in:
Ryan Dwyer 2018-10-13 17:06:33 +10:00
parent fa11b7f701
commit f98f351a52
2 changed files with 19 additions and 1 deletions

View file

@ -57,6 +57,7 @@ struct swaylock_state {
struct loop *eventloop; struct loop *eventloop;
struct loop_event *clear_indicator_timer; // clears the indicator struct loop_event *clear_indicator_timer; // clears the indicator
struct loop_event *clear_password_timer; // clears the password buffer struct loop_event *clear_password_timer; // clears the password buffer
struct loop_event *verify_password_timer;
struct wl_display *display; struct wl_display *display;
struct wl_compositor *compositor; struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_layer_shell_v1 *layer_shell;

View file

@ -72,6 +72,11 @@ static void schedule_password_clear(struct swaylock_state *state) {
state->eventloop, 10000, clear_password, state); state->eventloop, 10000, clear_password, state);
} }
static void handle_preverify_timeout(int fd, short mask, void *data) {
struct swaylock_state *state = data;
state->verify_password_timer = NULL;
}
void swaylock_handle_key(struct swaylock_state *state, void swaylock_handle_key(struct swaylock_state *state,
xkb_keysym_t keysym, uint32_t codepoint) { xkb_keysym_t keysym, uint32_t codepoint) {
switch (keysym) { switch (keysym) {
@ -83,7 +88,18 @@ void swaylock_handle_key(struct swaylock_state *state,
state->auth_state = AUTH_STATE_VALIDATING; state->auth_state = AUTH_STATE_VALIDATING;
damage_state(state); damage_state(state);
while (wl_display_dispatch(state->display) != -1 && state->run_display) {
// We generally want to wait until all surfaces are showing the
// "verifying" state before we go and verify the password, because
// verifying it is a blocking operation. However, if the surface is on
// an output with DPMS off then it won't update, so we set a timer.
state->verify_password_timer = loop_add_timer(
state->eventloop, 50, handle_preverify_timeout, state);
while (state->run_display && state->verify_password_timer) {
wl_display_flush(state->display);
loop_poll(state->eventloop);
bool ok = 1; bool ok = 1;
struct swaylock_surface *surface; struct swaylock_surface *surface;
wl_list_for_each(surface, &state->surfaces, link) { wl_list_for_each(surface, &state->surfaces, link) {
@ -103,6 +119,7 @@ void swaylock_handle_key(struct swaylock_state *state,
} }
state->auth_state = AUTH_STATE_INVALID; state->auth_state = AUTH_STATE_INVALID;
damage_state(state); damage_state(state);
schedule_indicator_clear(state);
break; break;
case XKB_KEY_Delete: case XKB_KEY_Delete:
case XKB_KEY_BackSpace: case XKB_KEY_BackSpace: