diff options
| author | Simon Ser <contact@emersion.fr> | 2023-01-27 13:18:36 +0100 |
|---|---|---|
| committer | Kenny Levinsen <kl@kl.wtf> | 2023-01-28 22:51:38 +0100 |
| commit | be566a2935d12e31a0f7d2df15f294a7c7ed9dce (patch) | |
| tree | 5be097540a626a08f1224ad301e20410492e45a3 | |
| parent | 6213fa0a7cac6da1a49f340d4999b9f6f9e82a5c (diff) | |
Wait for the locked event
We were ignoring the locked event. Wait for it instead.
| -rw-r--r-- | include/swaylock.h | 2 | ||||
| -rw-r--r-- | 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; }; @@ -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(); } |
