Skip to content

Commit be566a2

Browse files
emersionkennylevinsen
authored andcommitted
Wait for the locked event
We were ignoring the locked event. Wait for it instead.
1 parent 6213fa0 commit be566a2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

include/swaylock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct swaylock_state {
9090
cairo_t *test_cairo; // used to estimate font/text sizes
9191
enum auth_state auth_state;
9292
int failed_attempts;
93-
bool run_display;
93+
bool run_display, locked;
9494
struct ext_session_lock_manager_v1 *ext_session_lock_manager_v1;
9595
struct ext_session_lock_v1 *ext_session_lock_v1;
9696
};

main.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ struct wl_output_listener _wl_output_listener = {
313313
};
314314

315315
static void ext_session_lock_v1_handle_locked(void *data, struct ext_session_lock_v1 *lock) {
316-
// Who cares
316+
struct swaylock_state *state = data;
317+
state->locked = true;
317318
}
318319

319320
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) {
12951296
create_surface(surface);
12961297
}
12971298

1299+
if (state.ext_session_lock_manager_v1) {
1300+
while (!state.locked) {
1301+
if (wl_display_dispatch(state.display) < 0) {
1302+
swaylock_log(LOG_ERROR, "wl_display_dispatch() failed");
1303+
return 2;
1304+
}
1305+
}
1306+
} else {
1307+
if (wl_display_roundtrip(state.display) < 0) {
1308+
swaylock_log(LOG_ERROR, "wl_display_roundtrip() failed");
1309+
return 2;
1310+
}
1311+
state.locked = true;
1312+
}
1313+
12981314
if (state.args.daemonize) {
1299-
wl_display_roundtrip(state.display);
13001315
daemonize();
13011316
}
13021317

0 commit comments

Comments
 (0)