Wait for the locked event

We were ignoring the locked event. Wait for it instead.
This commit is contained in:
Simon Ser 2023-01-27 13:18:36 +01:00 committed by Kenny Levinsen
parent 6213fa0a7c
commit be566a2935
2 changed files with 18 additions and 3 deletions

View File

@ -90,7 +90,7 @@ struct swaylock_state {
cairo_t *test_cairo; // used to estimate font/text sizes cairo_t *test_cairo; // used to estimate font/text sizes
enum auth_state auth_state; enum auth_state auth_state;
int failed_attempts; int failed_attempts;
bool run_display; bool run_display, locked;
struct ext_session_lock_manager_v1 *ext_session_lock_manager_v1; struct ext_session_lock_manager_v1 *ext_session_lock_manager_v1;
struct ext_session_lock_v1 *ext_session_lock_v1; struct ext_session_lock_v1 *ext_session_lock_v1;
}; };

19
main.c
View File

@ -313,7 +313,8 @@ struct wl_output_listener _wl_output_listener = {
}; };
static void ext_session_lock_v1_handle_locked(void *data, struct ext_session_lock_v1 *lock) { static void ext_session_lock_v1_handle_locked(void *data, struct ext_session_lock_v1 *lock) {
// Who cares struct swaylock_state *state = data;
state->locked = true;
} }
static void ext_session_lock_v1_handle_finished(void *data, struct ext_session_lock_v1 *lock) { static void ext_session_lock_v1_handle_finished(void *data, struct ext_session_lock_v1 *lock) {
@ -1295,8 +1296,22 @@ int main(int argc, char **argv) {
create_surface(surface); create_surface(surface);
} }
if (state.ext_session_lock_manager_v1) {
while (!state.locked) {
if (wl_display_dispatch(state.display) < 0) {
swaylock_log(LOG_ERROR, "wl_display_dispatch() failed");
return 2;
}
}
} else {
if (wl_display_roundtrip(state.display) < 0) {
swaylock_log(LOG_ERROR, "wl_display_roundtrip() failed");
return 2;
}
state.locked = true;
}
if (state.args.daemonize) { if (state.args.daemonize) {
wl_display_roundtrip(state.display);
daemonize(); daemonize();
} }