diff options
author | emersion <contact@emersion.fr> | 2018-10-01 11:07:58 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-10-04 21:56:38 +0200 |
commit | 26b9d6dbb1f060405c02b6b66527b0272f79d495 (patch) | |
tree | eafc3eaae5736ed8ae325f51c12a1fb60b70a94f | |
parent | 78389fe72225f9baf7def744825323f54ac4ee8e (diff) |
output: send present event from all backends
-rw-r--r-- | backend/headless/output.c | 1 | ||||
-rw-r--r-- | backend/wayland/output.c | 10 | ||||
-rw-r--r-- | backend/x11/output.c | 7 | ||||
-rw-r--r-- | types/wlr_output.c | 12 |
4 files changed, 27 insertions, 3 deletions
diff --git a/backend/headless/output.c b/backend/headless/output.c index 143900d4..ad0050d8 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -67,6 +67,7 @@ static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age) static bool output_swap_buffers(struct wlr_output *wlr_output, pixman_region32_t *damage) { + wlr_output_send_present(wlr_output, NULL, 0, 0); return true; // No-op } diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 4eb99a3b..4fbfe9d2 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -66,8 +66,14 @@ static bool output_swap_buffers(struct wlr_output *wlr_output, output->frame_callback = wl_surface_frame(output->surface); wl_callback_add_listener(output->frame_callback, &frame_listener, output); - return wlr_egl_swap_buffers(&output->backend->egl, output->egl_surface, - damage); + if (!wlr_egl_swap_buffers(&output->backend->egl, + output->egl_surface, damage)) { + return false; + } + + // TODO: if available, use the presentation-time protocol + wlr_output_send_present(wlr_output, NULL, 0, 0); + return true; } static void output_transform(struct wlr_output *wlr_output, diff --git a/backend/x11/output.c b/backend/x11/output.c index e0210b1a..8cd8ee33 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -102,7 +102,12 @@ static bool output_swap_buffers(struct wlr_output *wlr_output, struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output; struct wlr_x11_backend *x11 = output->x11; - return wlr_egl_swap_buffers(&x11->egl, output->surf, damage); + if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) { + return false; + } + + wlr_output_send_present(wlr_output, NULL, 0, 0); + return true; } static const struct wlr_output_impl output_impl = { diff --git a/types/wlr_output.c b/types/wlr_output.c index 99d769e3..4ffe561a 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -18,6 +18,8 @@ #define OUTPUT_VERSION 3 +#define DEFAULT_PRESENT_CLOCK CLOCK_MONOTONIC + static void output_send_to_resource(struct wl_resource *resource) { struct wlr_output *output = wlr_output_from_resource(resource); const uint32_t version = wl_resource_get_version(resource); @@ -562,6 +564,16 @@ void wlr_output_schedule_frame(struct wlr_output *output) { void wlr_output_send_present(struct wlr_output *output, struct timespec *when, unsigned seq, uint32_t flags) { + struct timespec now; + if (when == NULL) { + if (!clock_gettime(DEFAULT_PRESENT_CLOCK, &now)) { + wlr_log_errno(WLR_ERROR, "failed to send output present event: " + "failed to read clock"); + return; + } + when = &now; + } + struct wlr_output_event_present event = { .output = output, .when = when, |