presentation-time: bump protocol version to v2

We've actually been doing the wrong thing this whole time, for v1 of the
protocol, we should set the refresh_nsec field to 0 if the output does
not have a constant refresh rate. However we've been setting it to the
fastest rate instead since eac7c2ad2f
which is incidentally exactly what v2 of the protocol proposes.

So allow advertising v2, and fix v1 to set refresh_nsec to 0.
This commit is contained in:
llyyr 2024-10-15 22:10:49 +05:30
parent e8e76dc295
commit 4c74a8843a
3 changed files with 12 additions and 5 deletions

View File

@ -56,7 +56,7 @@ struct wlr_presentation_event {
struct wlr_backend; struct wlr_backend;
struct wlr_presentation *wlr_presentation_create(struct wl_display *display, struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
struct wlr_backend *backend); struct wlr_backend *backend, int version);
/** /**
* Mark the current surface's buffer as sampled. * Mark the current surface's buffer as sampled.
* *

View File

@ -1,5 +1,5 @@
wayland_protos = dependency('wayland-protocols', wayland_protos = dependency('wayland-protocols',
version: '>=1.35', version: '>=1.38',
fallback: 'wayland-protocols', fallback: 'wayland-protocols',
default_options: ['tests=false'], default_options: ['tests=false'],
) )

View File

@ -7,7 +7,7 @@
#include <wlr/util/addon.h> #include <wlr/util/addon.h>
#include "presentation-time-protocol.h" #include "presentation-time-protocol.h"
#define PRESENTATION_VERSION 1 #define PRESENTATION_VERSION 2
struct wlr_presentation_surface_state { struct wlr_presentation_surface_state {
struct wlr_presentation_feedback *feedback; struct wlr_presentation_feedback *feedback;
@ -172,14 +172,16 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_presentation *wlr_presentation_create(struct wl_display *display, struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
struct wlr_backend *backend) { struct wlr_backend *backend, int version) {
assert(version <= PRESENTATION_VERSION);
struct wlr_presentation *presentation = calloc(1, sizeof(*presentation)); struct wlr_presentation *presentation = calloc(1, sizeof(*presentation));
if (presentation == NULL) { if (presentation == NULL) {
return NULL; return NULL;
} }
presentation->global = wl_global_create(display, &wp_presentation_interface, presentation->global = wl_global_create(display, &wp_presentation_interface,
PRESENTATION_VERSION, NULL, presentation_bind); version, NULL, presentation_bind);
if (presentation->global == NULL) { if (presentation->global == NULL) {
free(presentation); free(presentation);
return NULL; return NULL;
@ -283,6 +285,11 @@ static void feedback_handle_output_present(struct wl_listener *listener,
if (output_event->presented) { if (output_event->presented) {
struct wlr_presentation_event event = {0}; struct wlr_presentation_event event = {0};
wlr_presentation_event_from_output(&event, output_event); wlr_presentation_event_from_output(&event, output_event);
struct wl_resource *resource = wl_resource_from_link(feedback->resources.next);
if (wl_resource_get_version(resource) == 1 &&
event.output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) {
event.refresh = 0;
}
if (!feedback->zero_copy) { if (!feedback->zero_copy) {
event.flags &= ~WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY; event.flags &= ~WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY;
} }