diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-08-09 17:52:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-09 17:52:31 -0400 |
commit | b109aecff98bfed9a7ae834947ac93cb14bfc8dc (patch) | |
tree | 09d768bc1d337105b8a50d5886aa9f19d497c3d0 /examples | |
parent | 3ce1341e3c0276ef20df5c7b89cc9ce260d05b9e (diff) | |
parent | 4dfc6460f3205152f8f039838b15d2a774a50379 (diff) |
Merge pull request #52 from acrisci/feature/surface-frame-cb
Implement surface frame callback
Diffstat (limited to 'examples')
-rw-r--r-- | examples/compositor/main.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/compositor/main.c b/examples/compositor/main.c index 9d320c97..7ac549e5 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -23,6 +23,13 @@ struct sample_state { struct xdg_shell_state xdg_shell; }; +/* + * Convert timespec to milliseconds + */ +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + void handle_output_frame(struct output_state *output, struct timespec *ts) { struct compositor_state *state = output->compositor; struct sample_state *sample = state->data; @@ -39,6 +46,12 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) { wlr_texture_get_matrix(surface->texture, &matrix, &wlr_output->transform_matrix, 200, 200); wlr_render_with_matrix(sample->renderer, surface->texture, &matrix); + + struct wlr_frame_callback *cb, *cnext; + wl_list_for_each_safe(cb, cnext, &surface->frame_callback_list, link) { + wl_callback_send_done(cb->resource, timespec_to_msec(ts)); + wl_resource_destroy(cb->resource); + } } } |