diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2011-08-02 13:48:24 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-08-02 13:48:24 -0400 |
commit | 4f07d0197ad16573fd7dec649daa5234b6c581bd (patch) | |
tree | 2d32bb6f4a323448fdcda6e04f1f33ca10956fb7 | |
parent | 5e76d40437f03b9d850a42dc075512f960fcc29c (diff) |
Stop using the callback helpers and just setup a listenerprotocol-changes
-rw-r--r-- | clients/simple-egl.c | 4 | ||||
-rw-r--r-- | clients/simple-shm.c | 15 | ||||
-rw-r--r-- | compositor/compositor-wayland.c | 13 |
3 files changed, 25 insertions, 7 deletions
diff --git a/clients/simple-egl.c b/clients/simple-egl.c index 63c48afd..1ec097fe 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -279,6 +279,9 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) eglSwapBuffers(window->display->egl.dpy, window->egl_surface); + if (callback) + wl_callback_destroy(callback); + callback = wl_surface_frame(window->surface); wl_callback_add_listener(callback, &frame_listener, window); } @@ -351,6 +354,7 @@ main(int argc, char **argv) display_handle_global, &display); wl_display_get_fd(display.display, event_mask_update, &display); + wl_display_iterate(display.display, WL_DISPLAY_READABLE); init_egl(&display); create_surface(&window); diff --git a/clients/simple-shm.c b/clients/simple-shm.c index 080fe10d..961c5a71 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -112,8 +112,10 @@ create_window(struct display *display, int width, int height) return window; } +static const struct wl_callback_listener frame_listener; + static void -redraw(void *data, uint32_t time) +redraw(void *data, struct wl_callback *callback, uint32_t time) { struct window *window = data; uint32_t *p; @@ -130,9 +132,16 @@ redraw(void *data, uint32_t time) wl_surface_damage(window->surface, 0, 0, window->width, window->height); - wl_surface_frame_callback(window->surface, redraw, window); + if (callback) + wl_callback_destroy(callback); + callback = wl_surface_frame(window->surface); + wl_callback_add_listener(callback, &frame_listener, window); } +static const struct wl_callback_listener frame_listener = { + redraw +}; + static void compositor_handle_visual(void *data, struct wl_compositor *compositor, @@ -207,7 +216,7 @@ main(int argc, char **argv) display = create_display(); window = create_window(display, 250, 250); - redraw(window, 0); + redraw(window, NULL, 0); while (true) wl_display_iterate(display->display, display->mask); diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c index 28cb8950..31fc3c5e 100644 --- a/compositor/compositor-wayland.c +++ b/compositor/compositor-wayland.c @@ -158,13 +158,18 @@ wayland_compositor_init_egl(struct wayland_compositor *c) } static void -frame_callback(void *data, uint32_t time) +frame_callback(void *data, struct wl_callback *callback, uint32_t time) { struct wlsc_output *output = data; wlsc_output_finish_frame(output, time); + wl_callback_destroy(callback); } +static const struct wl_callback_listener frame_listener = { + frame_callback +}; + static int wayland_output_prepare_render(struct wlsc_output *output_base) { @@ -186,14 +191,14 @@ wayland_output_present(struct wlsc_output *output_base) struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_compositor *c = (struct wayland_compositor *) output->base.compositor; + struct wl_callback *callback; if (wayland_output_prepare_render(&output->base)) return -1; eglSwapBuffers(c->base.display, output->egl_surface); - wl_display_frame_callback(c->parent.display, - output->parent.surface, - frame_callback, &output->base); + callback = wl_surface_frame(output->parent.surface); + wl_callback_add_listener(callback, &frame_listener, output); return 0; } |