Skip to content

Commit

Permalink
Check wl_display_roundtrip() errors
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Dec 26, 2023
1 parent eafa06b commit 6d6b216
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,18 @@ bool init_wayland(struct mako_state *state) {
wl_list_init(&state->seats);

state->display = wl_display_connect(NULL);

if (state->display == NULL) {
fprintf(stderr, "failed to create display\n");
return false;
}

state->registry = wl_display_get_registry(state->display);
wl_registry_add_listener(state->registry, &registry_listener, state);
wl_display_roundtrip(state->display);

if (wl_display_roundtrip(state->display) < 0) {
fprintf(stderr, "wl_display_roundtrip() failed\n");
return false;
}

if (state->compositor == NULL) {
fprintf(stderr, "compositor doesn't support wl_compositor\n");
Expand All @@ -480,7 +483,10 @@ bool init_wayland(struct mako_state *state) {
}

// Second roundtrip to get output metadata
wl_display_roundtrip(state->display);
if (wl_display_roundtrip(state->display) < 0) {
fprintf(stderr, "wl_display_roundtrip() failed\n");
return false;
}

// Set up the cursor. It needs a wl_surface with the cursor loaded into it.
// If one of these fail, mako will work fine without the cursor being able to change.
Expand Down

0 comments on commit 6d6b216

Please sign in to comment.