From: Pekka Paalanen <pekka.paala...@collabora.co.uk> Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> --- Makefile.am | 3 ++ clients/weston-info.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+)
diff --git a/Makefile.am b/Makefile.am index 998dc54..79e6a7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -547,6 +547,9 @@ weston_simple_im_LDADD = $(CLIENT_LIBS) weston_simple_im_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) weston_info_SOURCES = clients/weston-info.c +nodist_weston_info_SOURCES = \ + protocol/presentation_timing-protocol.c \ + protocol/presentation_timing-client-protocol.h weston_info_LDADD = $(WESTON_INFO_LIBS) libshared.la weston_info_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) diff --git a/clients/weston-info.c b/clients/weston-info.c index 147dc48..12710a8 100644 --- a/clients/weston-info.c +++ b/clients/weston-info.c @@ -27,10 +27,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <wayland-client.h> #include "../shared/os-compatibility.h" +#include "presentation_timing-client-protocol.h" + +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) typedef void (*print_info_t)(void *info); typedef void (*destroy_info_t)(void *info); @@ -92,6 +96,13 @@ struct seat_info { char *name; }; +struct presentation_info { + struct global_info global; + struct presentation *presentation; + + clockid_t clk_id; +}; + struct weston_info { struct wl_display *display; struct wl_registry *registry; @@ -467,6 +478,74 @@ add_output_info(struct weston_info *info, uint32_t id, uint32_t version) } static void +destroy_presentation_info(void *info) +{ + struct presentation_info *prinfo = info; + + presentation_destroy(prinfo->presentation); +} + +static const char * +clock_name(clockid_t clk_id) +{ + static const char *names[] = { + [CLOCK_REALTIME] = "CLOCK_REALTIME", + [CLOCK_MONOTONIC] = "CLOCK_MONOTONIC", + [CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW", + [CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE", + [CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE", + [CLOCK_BOOTTIME] = "CLOCK_BOOTTIME", + }; + + if (clk_id < 0 || (unsigned)clk_id >= ARRAY_LENGTH(names)) + return "unknown"; + + return names[clk_id]; +} + +static void +print_presentation_info(void *info) +{ + struct presentation_info *prinfo = info; + + print_global_info(info); + + printf("\tpresentation clock id: %d (%s)\n", + prinfo->clk_id, clock_name(prinfo->clk_id)); +} + +static void +presentation_handle_clock_id(void *data, struct presentation *presentation, + uint32_t clk_id) +{ + struct presentation_info *prinfo = data; + + prinfo->clk_id = clk_id; +} + +static const struct presentation_listener presentation_listener = { + presentation_handle_clock_id +}; + +static void +add_presentation_info(struct weston_info *info, uint32_t id, uint32_t version) +{ + struct presentation_info *prinfo = xzalloc(sizeof *prinfo); + + init_global_info(info, &prinfo->global, id, "presentation", version); + prinfo->global.print = print_presentation_info; + prinfo->global.destroy = destroy_presentation_info; + + prinfo->clk_id = -1; + prinfo->presentation = wl_registry_bind(info->registry, id, + &presentation_interface, 1); + presentation_add_listener(prinfo->presentation, &presentation_listener, + prinfo); + + info->roundtrip_needed = true; +} + +static void destroy_global_info(void *data) { } @@ -494,6 +573,8 @@ global_handler(void *data, struct wl_registry *registry, uint32_t id, add_shm_info(info, id, version); else if (!strcmp(interface, "wl_output")) add_output_info(info, id, version); + else if (!strcmp(interface, "presentation")) + add_presentation_info(info, id, version); else add_global_info(info, id, interface, version); } -- 1.8.3.2 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel