wayland: only bind to 'presentation' interface if -p,--presentation-timings

This commit is contained in:
Daniel Eklöf 2019-12-31 16:12:48 +01:00
parent 7fe081600a
commit b100a82c2a
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 16 additions and 10 deletions

2
main.c
View file

@ -235,7 +235,7 @@ main(int argc, char *const *argv)
if ((fdm = fdm_init()) == NULL) if ((fdm = fdm_init()) == NULL)
goto out; goto out;
if ((wayl = wayl_init(fdm)) == NULL) if ((wayl = wayl_init(&conf, fdm)) == NULL)
goto out; goto out;
if (!as_server && (term = term_init( if (!as_server && (term = term_init(

View file

@ -21,6 +21,7 @@
#define LOG_ENABLE_DBG 0 #define LOG_ENABLE_DBG 0
#include "log.h" #include "log.h"
#include "config.h"
#include "terminal.h" #include "terminal.h"
#include "input.h" #include "input.h"
#include "render.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) { else if (strcmp(interface, wp_presentation_interface.name) == 0) {
const uint32_t required = 1; if (wayl->conf->presentation_timings) {
if (!verify_iface_version(interface, version, required)) const uint32_t required = 1;
return; if (!verify_iface_version(interface, version, required))
return;
wayl->presentation = wl_registry_bind( wayl->presentation = wl_registry_bind(
wayl->registry, name, &wp_presentation_interface, required); wayl->registry, name, &wp_presentation_interface, required);
wp_presentation_add_listener( wp_presentation_add_listener(
wayl->presentation, &presentation_listener, wayl); wayl->presentation, &presentation_listener, wayl);
}
} }
} }
@ -520,9 +523,10 @@ fdm_repeat(struct fdm *fdm, int fd, int events, void *data)
} }
struct wayland * struct wayland *
wayl_init(struct fdm *fdm) wayl_init(const struct config *conf, struct fdm *fdm)
{ {
struct wayland *wayl = calloc(1, sizeof(*wayl)); struct wayland *wayl = calloc(1, sizeof(*wayl));
wayl->conf = conf;
wayl->fdm = fdm; wayl->fdm = fdm;
wayl->kbd.repeat.fd = -1; wayl->kbd.repeat.fd = -1;

View file

@ -100,8 +100,10 @@ struct wl_window {
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */ tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
}; };
struct config;
struct terminal; struct terminal;
struct wayland { struct wayland {
const struct config *conf;
struct fdm *fdm; struct fdm *fdm;
struct wl_display *display; struct wl_display *display;
struct wl_registry *registry; struct wl_registry *registry;
@ -166,7 +168,7 @@ struct wayland {
struct terminal *moused; 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); void wayl_destroy(struct wayland *wayl);
struct terminal *wayl_terminal_from_surface( struct terminal *wayl_terminal_from_surface(