aboutsummaryrefslogtreecommitdiff
path: root/wayland.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-12-31 14:39:40 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-12-31 14:39:40 +0000
commit5a074190960130b6136a398d83da43fd1e8ec7e2 (patch)
tree77a5b8ce40d8749c405958c398d26b6c22d07070 /wayland.c
parentmain: let getopt_long() print error message (diff)
wayland: optionally use the presentation time protocol to measure input lag
This adds a flag, -p,--presentation-timings, that enables input lag measuring using the presentation time Wayland protocol. When enabled, we store a timestamp when we *send* a key to the slave. Then, when we commit a frame for rendering to the compositor, we request presentation feedback. We also store a timestamp for when the frame was committed. The 'presented' callback then looks at the input and commit timestamps, and compares it with the presented timestamp. The delay is logged at INFO when the delay was less than one frame interval, at WARN when it was one frame interval, and at ERR when it was two or more frame intervals. We also update statistic counters that we log when foot is shut down.
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/wayland.c b/wayland.c
index 147d5f68..6b4287bf 100644
--- a/wayland.c
+++ b/wayland.c
@@ -199,6 +199,20 @@ static struct zxdg_output_v1_listener xdg_output_listener = {
.description = xdg_output_handle_description,
};
+static void
+clock_id(void *data, struct wp_presentation *wp_presentation, uint32_t clk_id)
+{
+ struct wayland *wayl = data;
+ wayl->presentation_clock_id = clk_id;
+
+ LOG_DBG("presentation clock ID: %u", clk_id);
+}
+
+static const struct wp_presentation_listener presentation_listener = {
+ .clock_id = &clock_id,
+};
+
+
static bool
verify_iface_version(const char *iface, uint32_t version, uint32_t wanted)
{
@@ -326,6 +340,17 @@ handle_global(void *data, struct wl_registry *registry,
wayl->registry, name,
&zwp_primary_selection_device_manager_v1_interface, required);
}
+
+ else if (strcmp(interface, wp_presentation_interface.name) == 0) {
+ const uint32_t required = 1;
+ if (!verify_iface_version(interface, version, required))
+ return;
+
+ wayl->presentation = wl_registry_bind(
+ wayl->registry, name, &wp_presentation_interface, required);
+ wp_presentation_add_listener(
+ wayl->presentation, &presentation_listener, wayl);
+ }
}
static void
@@ -658,6 +683,9 @@ wayl_destroy(struct wayland *wayl)
if (wayl->xdg_decoration_manager != NULL)
zxdg_decoration_manager_v1_destroy(wayl->xdg_decoration_manager);
+ if (wayl->presentation != NULL)
+ wp_presentation_destroy(wayl->presentation);
+
if (wayl->kbd.xkb_compose_state != NULL)
xkb_compose_state_unref(wayl->kbd.xkb_compose_state);
if (wayl->kbd.xkb_compose_table != NULL)