From b1cba36aebb6629fc2019360197f34394abaf2ac Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 9 Oct 2017 19:34:56 +0200 Subject: Call frame_callback_list after rendering the cursor --- types/wlr_output.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index cc4022eb..13a6adbd 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -1,7 +1,9 @@ +#define _POSIX_C_SOURCE 199309L #include #include #include #include +#include #include #include #include @@ -171,12 +173,12 @@ bool wlr_output_set_cursor(struct wlr_output *output, return set_cursor(output, buf, stride, width, height, hotspot_x, hotspot_y); } -static void handle_cursor_surface_commit(struct wl_listener *listener, - void *data) { - struct wlr_output *output = wl_container_of(listener, output, - cursor.surface_commit); - struct wlr_surface *surface = data; +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} +static void commit_cursor_surface(struct wlr_output *output, + struct wlr_surface *surface) { struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current->buffer); if (buffer == NULL) { return; @@ -198,6 +200,25 @@ static void handle_cursor_surface_commit(struct wl_listener *listener, wl_shm_buffer_end_access(buffer); } +static void handle_cursor_surface_commit(struct wl_listener *listener, + void *data) { + struct wlr_output *output = wl_container_of(listener, output, + cursor.surface_commit); + struct wlr_surface *surface = data; + + commit_cursor_surface(output, surface); + + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + + struct wlr_frame_callback *cb, *cnext; + wl_list_for_each_safe(cb, cnext, &surface->current->frame_callback_list, + link) { + wl_callback_send_done(cb->resource, timespec_to_msec(&now)); + wl_resource_destroy(cb->resource); + } +} + static void handle_cursor_surface_destroy(struct wl_listener *listener, void *data) { struct wlr_output *output = wl_container_of(listener, output, -- cgit v1.2.3