summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-13 17:06:33 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-15 00:26:27 +1000
commitf98f351a5275967c46482e1c9c754fee927d72ee (patch)
treeb94809766ed3a6a0a1523a2fcf3ff6988892403d
parentswaylock: clear password after 10 seconds (diff)
downloadsway-f98f351a5275967c46482e1c9c754fee927d72ee.tar.gz
sway-f98f351a5275967c46482e1c9c754fee927d72ee.tar.zst
sway-f98f351a5275967c46482e1c9c754fee927d72ee.zip
swaylock: Don't wait too long for surface damage before verifying
-rw-r--r--include/swaylock/swaylock.h1
-rw-r--r--swaylock/password.c19
2 files changed, 19 insertions, 1 deletions
diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h
index ae042c4f..e7165b3b 100644
--- a/include/swaylock/swaylock.h
+++ b/include/swaylock/swaylock.h
@@ -57,6 +57,7 @@ struct swaylock_state {
57 struct loop *eventloop; 57 struct loop *eventloop;
58 struct loop_event *clear_indicator_timer; // clears the indicator 58 struct loop_event *clear_indicator_timer; // clears the indicator
59 struct loop_event *clear_password_timer; // clears the password buffer 59 struct loop_event *clear_password_timer; // clears the password buffer
60 struct loop_event *verify_password_timer;
60 struct wl_display *display; 61 struct wl_display *display;
61 struct wl_compositor *compositor; 62 struct wl_compositor *compositor;
62 struct zwlr_layer_shell_v1 *layer_shell; 63 struct zwlr_layer_shell_v1 *layer_shell;
diff --git a/swaylock/password.c b/swaylock/password.c
index 5ab50042..3f9949b2 100644
--- a/swaylock/password.c
+++ b/swaylock/password.c
@@ -72,6 +72,11 @@ static void schedule_password_clear(struct swaylock_state *state) {
72 state->eventloop, 10000, clear_password, state); 72 state->eventloop, 10000, clear_password, state);
73} 73}
74 74
75static void handle_preverify_timeout(int fd, short mask, void *data) {
76 struct swaylock_state *state = data;
77 state->verify_password_timer = NULL;
78}
79
75void swaylock_handle_key(struct swaylock_state *state, 80void swaylock_handle_key(struct swaylock_state *state,
76 xkb_keysym_t keysym, uint32_t codepoint) { 81 xkb_keysym_t keysym, uint32_t codepoint) {
77 switch (keysym) { 82 switch (keysym) {
@@ -83,7 +88,18 @@ void swaylock_handle_key(struct swaylock_state *state,
83 88
84 state->auth_state = AUTH_STATE_VALIDATING; 89 state->auth_state = AUTH_STATE_VALIDATING;
85 damage_state(state); 90 damage_state(state);
86 while (wl_display_dispatch(state->display) != -1 && state->run_display) { 91
92 // We generally want to wait until all surfaces are showing the
93 // "verifying" state before we go and verify the password, because
94 // verifying it is a blocking operation. However, if the surface is on
95 // an output with DPMS off then it won't update, so we set a timer.
96 state->verify_password_timer = loop_add_timer(
97 state->eventloop, 50, handle_preverify_timeout, state);
98
99 while (state->run_display && state->verify_password_timer) {
100 wl_display_flush(state->display);
101 loop_poll(state->eventloop);
102
87 bool ok = 1; 103 bool ok = 1;
88 struct swaylock_surface *surface; 104 struct swaylock_surface *surface;
89 wl_list_for_each(surface, &state->surfaces, link) { 105 wl_list_for_each(surface, &state->surfaces, link) {
@@ -103,6 +119,7 @@ void swaylock_handle_key(struct swaylock_state *state,
103 } 119 }
104 state->auth_state = AUTH_STATE_INVALID; 120 state->auth_state = AUTH_STATE_INVALID;
105 damage_state(state); 121 damage_state(state);
122 schedule_indicator_clear(state);
106 break; 123 break;
107 case XKB_KEY_Delete: 124 case XKB_KEY_Delete:
108 case XKB_KEY_BackSpace: 125 case XKB_KEY_BackSpace: