diff --git a/wayland.c b/wayland.c index 88bcca3..b0a56f6 100644 --- a/wayland.c +++ b/wayland.c @@ -101,12 +101,16 @@ static void wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) { printf("FRAME CALLBACK 🐷🐷\n"); + struct surface *surface = data; + struct client_state *state = surface->state; + /* Destroy this callback */ wl_callback_destroy(cb); - struct surface *surface = data; surface->dirty = true; - //struct client_state *state = surface->state; + + // Don't make it stuck. + //wl_display_dispatch(state->wl_display); } static const struct wl_callback_listener wl_surface_frame_listener = { @@ -377,7 +381,7 @@ struct event wait_for_event(struct client_state *state) { // do here if (next->data.dirty) { next->data.dirty = false; - state->surface_list->next = next->next; + state->surface_list_next = next->next; printf("dirty %p\n", &next->data); @@ -434,8 +438,8 @@ void swap_buffers(struct client_state *state, struct surface *surface) { //wl_display_dispatch(state->wl_display); /* Request another frame */ - //struct wl_callback *cb = wl_surface_frame(surface->wl_surface); - //wl_callback_add_listener(cb, &wl_surface_frame_listener, surface); + struct wl_callback *cb = wl_surface_frame(surface->wl_surface); + wl_callback_add_listener(cb, &wl_surface_frame_listener, surface); printf("done swapping\n"); return; } diff --git a/wayland.h b/wayland.h index f6edbb5..30f4cee 100644 --- a/wayland.h +++ b/wayland.h @@ -11,6 +11,9 @@ #define DEFAULT_WIDTH 400 #define DEFAULT_HEIGHT 400 + +struct client_state; + struct surface { int width, height; @@ -25,6 +28,9 @@ struct surface { struct wl_output *wl_output; EGLSurface egl_surface; + + /// We need a back-pointer for callbacks. + struct client_state *state; }; struct surface_list {