diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-06-20 17:54:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-20 17:54:33 -0400 |
commit | 33f2c66fca6e8a628fe3f36d1abacf87226042de (patch) | |
tree | 1381f243d1bb9df41691e2b92593a8495bb80f37 /example/shared.c | |
parent | 2f03ea0a6bea6c099f148eb745a725ca77813885 (diff) | |
parent | b9d36c8149536cff1aa229f59337dcfa2f70a37b (diff) |
Merge pull request #17 from nyorain/wayland-backend
Basic Wayland backend
Diffstat (limited to 'example/shared.c')
-rw-r--r-- | example/shared.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/example/shared.c b/example/shared.c index be1bdee7..6af3042b 100644 --- a/example/shared.c +++ b/example/shared.c @@ -383,7 +383,9 @@ static void output_add_notify(struct wl_listener *listener, void *data) { fprintf(stderr, "Output '%s' added\n", output->name); fprintf(stderr, "%s %s %"PRId32"mm x %"PRId32"mm\n", output->make, output->model, output->phys_width, output->phys_height); - wlr_output_set_mode(output, output->modes->items[0]); + if (output->modes->length > 0) { + wlr_output_set_mode(output, output->modes->items[0]); + } struct output_state *ostate = calloc(1, sizeof(struct output_state)); clock_gettime(CLOCK_MONOTONIC, &ostate->last_frame); ostate->output = output; @@ -418,8 +420,6 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { } void compositor_init(struct compositor_state *state) { - memset(state, 0, sizeof(struct compositor_state)); - state->display = wl_display_create(); state->event_loop = wl_display_get_event_loop(state->display); state->session = wlr_session_start(state->display); @@ -457,14 +457,14 @@ void compositor_init(struct compositor_state *state) { state->backend = wlr; clock_gettime(CLOCK_MONOTONIC, &state->last_frame); -} -void compositor_run(struct compositor_state *state) { if (!wlr_backend_init(state->backend)) { fprintf(stderr, "Failed to initialize backend\n"); exit(1); } +} +void compositor_run(struct compositor_state *state) { while (!state->exit) { wl_event_loop_dispatch(state->event_loop, 0); } |