aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/backend.c6
-rw-r--r--backend/drm/backend.c4
-rw-r--r--backend/multi/backend.c17
-rw-r--r--include/wlr/backend.h2
-rw-r--r--include/wlr/backend/interface.h2
-rw-r--r--include/wlr/types/wlr_presentation_time.h5
-rw-r--r--types/wlr_output.c2
-rw-r--r--types/wlr_presentation_time.c9
8 files changed, 34 insertions, 13 deletions
diff --git a/backend/backend.c b/backend/backend.c
index b8cf8797..4b186767 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -64,9 +64,9 @@ struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend) {
return NULL;
}
-clockid_t wlr_backend_get_present_clock(struct wlr_backend *backend) {
- if (backend->impl->get_present_clock) {
- return backend->impl->get_present_clock(backend);
+clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
+ if (backend->impl->get_presentation_clock) {
+ return backend->impl->get_presentation_clock(backend);
}
return CLOCK_MONOTONIC;
}
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index b230613d..a9082077 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -65,7 +65,7 @@ static struct wlr_renderer *backend_get_renderer(
}
}
-static clockid_t backend_get_present_clock(struct wlr_backend *backend) {
+static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
return drm->clock;
}
@@ -74,7 +74,7 @@ static struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
- .get_present_clock = backend_get_present_clock,
+ .get_presentation_clock = backend_get_presentation_clock,
};
bool wlr_backend_is_drm(struct wlr_backend *b) {
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index 2f4b929f..cefaa361 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -1,6 +1,8 @@
+#define _POSIX_C_SOURCE 199309L
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <time.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/session.h>
#include <wlr/util/log.h>
@@ -77,11 +79,26 @@ static struct wlr_session *multi_backend_get_session(
return backend->session;
}
+static clockid_t multi_backend_get_presentation_clock(
+ struct wlr_backend *backend) {
+ struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
+
+ struct subbackend_state *sub;
+ wl_list_for_each(sub, &multi->backends, link) {
+ if (sub->backend->impl->get_presentation_clock) {
+ return wlr_backend_get_presentation_clock(sub->backend);
+ }
+ }
+
+ return CLOCK_MONOTONIC;
+}
+
struct wlr_backend_impl backend_impl = {
.start = multi_backend_start,
.destroy = multi_backend_destroy,
.get_renderer = multi_backend_get_renderer,
.get_session = multi_backend_get_session,
+ .get_presentation_clock = multi_backend_get_presentation_clock,
};
static void handle_display_destroy(struct wl_listener *listener, void *data) {
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index aee45b73..54f2b5e8 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -65,6 +65,6 @@ struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend);
/**
* Returns the clock used by the backend for presentation feedback.
*/
-clockid_t wlr_backend_get_present_clock(struct wlr_backend *backend);
+clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend);
#endif
diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
index a930c241..4a6a5cbb 100644
--- a/include/wlr/backend/interface.h
+++ b/include/wlr/backend/interface.h
@@ -19,7 +19,7 @@ struct wlr_backend_impl {
void (*destroy)(struct wlr_backend *backend);
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
struct wlr_session *(*get_session)(struct wlr_backend *backend);
- clockid_t (*get_present_clock)(struct wlr_backend *backend);
+ clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
};
/**
diff --git a/include/wlr/types/wlr_presentation_time.h b/include/wlr/types/wlr_presentation_time.h
index 71bf5977..9f9f0e87 100644
--- a/include/wlr/types/wlr_presentation_time.h
+++ b/include/wlr/types/wlr_presentation_time.h
@@ -47,7 +47,10 @@ struct wlr_presentation_event {
uint32_t flags; // wp_presentation_feedback_kind
};
-struct wlr_presentation *wlr_presentation_create(struct wl_display *display);
+struct wlr_backend;
+
+struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
+ struct wlr_backend *backend);
void wlr_presentation_destroy(struct wlr_presentation *presentation);
void wlr_presentation_send_surface_presented(
struct wlr_presentation *presentation, struct wlr_surface *surface,
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 6ff06fd6..25cd0734 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -565,7 +565,7 @@ void wlr_output_send_present(struct wlr_output *output, struct timespec *when,
unsigned seq, uint32_t flags) {
struct timespec now;
if (when == NULL) {
- clockid_t clock = wlr_backend_get_present_clock(output->backend);
+ clockid_t clock = wlr_backend_get_presentation_clock(output->backend);
errno = 0;
if (clock_gettime(clock, &now) != 0) {
wlr_log_errno(WLR_ERROR, "failed to send output present event: "
diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c
index 710aa4b9..c83b5e99 100644
--- a/types/wlr_presentation_time.c
+++ b/types/wlr_presentation_time.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_surface.h>
+#include <wlr/backend.h>
#include "presentation-time-protocol.h"
#include "util/signal.h"
@@ -147,7 +148,7 @@ static void presentation_bind(struct wl_client *client, void *data,
presentation_handle_resource_destroy);
wl_list_insert(&presentation->resources, wl_resource_get_link(resource));
- wp_presentation_send_clock_id(resource, presentation->clock);
+ wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
@@ -156,7 +157,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
wlr_presentation_destroy(presentation);
}
-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_presentation *presentation =
calloc(1, sizeof(struct wlr_presentation));
if (presentation == NULL) {
@@ -170,8 +172,7 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display) {
return NULL;
}
- // TODO: get clock from backend
- presentation->clock = CLOCK_MONOTONIC;
+ presentation->clock = wlr_backend_get_presentation_clock(backend);
wl_list_init(&presentation->resources);
wl_list_init(&presentation->feedbacks);