From ab82afab7f8da81fbd6445a0b65fb70ecba898b8 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Sun, 24 Mar 2019 20:18:59 +0100 Subject: wayland: implement a proper repaint cycle --- lib/renderers/wayland/window.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/renderers/wayland/window.c') diff --git a/lib/renderers/wayland/window.c b/lib/renderers/wayland/window.c index 1890a60..2141eff 100644 --- a/lib/renderers/wayland/window.c +++ b/lib/renderers/wayland/window.c @@ -197,17 +197,29 @@ frame_callback(void *data, struct wl_callback *callback, uint32_t time) struct window *window = data; wl_callback_destroy(callback); window->frame_cb = NULL; + window->render_pending = true; } static const struct wl_callback_listener listener = { frame_callback }; +void +bm_wl_window_schedule_render(struct window *window) +{ + assert(window); + if (window->frame_cb) + return; + + window->frame_cb = wl_surface_frame(window->surface); + wl_callback_add_listener(window->frame_cb, &listener, window); + wl_surface_commit(window->surface); +} + void bm_wl_window_render(struct window *window, struct wl_display *display, const struct bm_menu *menu) { assert(window && menu); - struct buffer *buffer; for (int tries = 0; tries < 2; ++tries) { if (!(buffer = next_buffer(window))) { @@ -232,13 +244,11 @@ bm_wl_window_render(struct window *window, struct wl_display *display, const str destroy_buffer(buffer); } - window->frame_cb = wl_surface_frame(window->surface); - wl_callback_add_listener(window->frame_cb, &listener, window); - wl_surface_damage(window->surface, 0, 0, buffer->width, buffer->height); wl_surface_attach(window->surface, buffer->buffer, 0, 0); wl_surface_commit(window->surface); buffer->busy = true; + window->render_pending = false; } void -- cgit v1.2.3-70-g09d2