From b100a82c2a1aa75bb8a27e2d2a1235b36359a161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 31 Dec 2019 16:12:48 +0100 Subject: [PATCH] wayland: only bind to 'presentation' interface if -p,--presentation-timings --- main.c | 2 +- wayland.c | 20 ++++++++++++-------- wayland.h | 4 +++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index 7f5f935c..ec44b8b3 100644 --- a/main.c +++ b/main.c @@ -235,7 +235,7 @@ main(int argc, char *const *argv) if ((fdm = fdm_init()) == NULL) goto out; - if ((wayl = wayl_init(fdm)) == NULL) + if ((wayl = wayl_init(&conf, fdm)) == NULL) goto out; if (!as_server && (term = term_init( diff --git a/wayland.c b/wayland.c index 7ac4399d..30c224d5 100644 --- a/wayland.c +++ b/wayland.c @@ -21,6 +21,7 @@ #define LOG_ENABLE_DBG 0 #include "log.h" +#include "config.h" #include "terminal.h" #include "input.h" #include "render.h" @@ -341,14 +342,16 @@ handle_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, wp_presentation_interface.name) == 0) { - const uint32_t required = 1; - if (!verify_iface_version(interface, version, required)) - return; + if (wayl->conf->presentation_timings) { + 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); + wayl->presentation = wl_registry_bind( + wayl->registry, name, &wp_presentation_interface, required); + wp_presentation_add_listener( + wayl->presentation, &presentation_listener, wayl); + } } } @@ -520,9 +523,10 @@ fdm_repeat(struct fdm *fdm, int fd, int events, void *data) } struct wayland * -wayl_init(struct fdm *fdm) +wayl_init(const struct config *conf, struct fdm *fdm) { struct wayland *wayl = calloc(1, sizeof(*wayl)); + wayl->conf = conf; wayl->fdm = fdm; wayl->kbd.repeat.fd = -1; diff --git a/wayland.h b/wayland.h index 575254e9..d10f10e3 100644 --- a/wayland.h +++ b/wayland.h @@ -100,8 +100,10 @@ struct wl_window { tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */ }; +struct config; struct terminal; struct wayland { + const struct config *conf; struct fdm *fdm; struct wl_display *display; struct wl_registry *registry; @@ -166,7 +168,7 @@ struct wayland { struct terminal *moused; }; -struct wayland *wayl_init(struct fdm *fdm); +struct wayland *wayl_init(const struct config *conf, struct fdm *fdm); void wayl_destroy(struct wayland *wayl); struct terminal *wayl_terminal_from_surface(