Call frame_callback_list after rendering the cursor

This commit is contained in:
emersion 2017-10-09 19:34:56 +02:00
parent 8f7962ed44
commit b1cba36aeb
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 26 additions and 5 deletions

View File

@ -1,7 +1,9 @@
#define _POSIX_C_SOURCE 199309L
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <tgmath.h> #include <tgmath.h>
#include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
@ -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); return set_cursor(output, buf, stride, width, height, hotspot_x, hotspot_y);
} }
static void handle_cursor_surface_commit(struct wl_listener *listener, static inline int64_t timespec_to_msec(const struct timespec *a) {
void *data) { return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
struct wlr_output *output = wl_container_of(listener, output, }
cursor.surface_commit);
struct wlr_surface *surface = data;
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); struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current->buffer);
if (buffer == NULL) { if (buffer == NULL) {
return; return;
@ -198,6 +200,25 @@ static void handle_cursor_surface_commit(struct wl_listener *listener,
wl_shm_buffer_end_access(buffer); 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, static void handle_cursor_surface_destroy(struct wl_listener *listener,
void *data) { void *data) {
struct wlr_output *output = wl_container_of(listener, output, struct wlr_output *output = wl_container_of(listener, output,