From 87584ef9344eadf44a1925eaddeb2e8ef8a63bdd Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Wed, 15 Dec 2021 23:23:21 +0000 Subject: [PATCH] screencopy: Set upper bounds on protocol version --- include/screencopy.h | 1 - src/main.c | 3 +-- src/screencopy.c | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/screencopy.h b/include/screencopy.h index 0f7aca9..bcc09d3 100644 --- a/include/screencopy.h +++ b/include/screencopy.h @@ -47,7 +47,6 @@ struct screencopy { struct zwlr_screencopy_manager_v1* manager; struct zwlr_screencopy_frame_v1* frame; - int version; void* userdata; void (*on_done)(struct screencopy*); diff --git a/src/main.c b/src/main.c index 0b2aa69..82e5cb3 100644 --- a/src/main.c +++ b/src/main.c @@ -153,8 +153,7 @@ static void registry_add(void* data, struct wl_registry* registry, self->screencopy.manager = wl_registry_bind(registry, id, &zwlr_screencopy_manager_v1_interface, - version); - self->screencopy.version = version; + MIN(3, version)); return; } diff --git a/src/screencopy.c b/src/screencopy.c index 481b214..e3698b2 100644 --- a/src/screencopy.c +++ b/src/screencopy.c @@ -130,7 +130,8 @@ static void screencopy_buffer(void* data, self->wl_shm_height = height; self->wl_shm_stride = stride; - if (self->version < 3) { + int version = zwlr_screencopy_manager_v1_get_version(self->manager); + if (version < 3) { self->have_linux_dmabuf = false; screencopy_buffer_done(data, frame); return;