From be566a2935d12e31a0f7d2df15f294a7c7ed9dce Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 27 Jan 2023 13:18:36 +0100 Subject: [PATCH] Wait for the locked event We were ignoring the locked event. Wait for it instead. --- include/swaylock.h | 2 +- main.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/swaylock.h b/include/swaylock.h index 077fc9a..b9ddda7 100644 --- a/include/swaylock.h +++ b/include/swaylock.h @@ -90,7 +90,7 @@ struct swaylock_state { cairo_t *test_cairo; // used to estimate font/text sizes enum auth_state auth_state; 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_v1 *ext_session_lock_v1; }; diff --git a/main.c b/main.c index 2a5dbc2..7b86168 100644 --- a/main.c +++ b/main.c @@ -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) { - // 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) { @@ -1295,8 +1296,22 @@ int main(int argc, char **argv) { 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) { - wl_display_roundtrip(state.display); daemonize(); }