From 4fe62d0149c582867482b6965c715e914ea2f646 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 31 Oct 2021 20:21:35 +0000 Subject: [PATCH] examples: screencopy: Add option to capture cursor --- examples/screencopy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/screencopy.c b/examples/screencopy.c index 1bb64eb80a..af87e6b051 100644 --- a/examples/screencopy.c +++ b/examples/screencopy.c @@ -48,6 +48,7 @@ struct format { static struct wl_shm *shm = NULL; static struct zext_screencopy_manager_v1 *screencopy_manager = NULL; static struct wl_output *output = NULL; +static bool capture_cursor = false; static struct { struct wl_buffer *wl_buffer; @@ -281,7 +282,11 @@ static void write_image(char *filename, enum wl_shm_format wl_fmt, int width, } int main(int argc, char *argv[]) { - struct wl_display * display = wl_display_connect(NULL); + if (argc >= 2 && strcmp(argv[1], "cursor") == 0) { + capture_cursor = true; + } + + struct wl_display *display = wl_display_connect(NULL); if (display == NULL) { perror("failed to create display"); return EXIT_FAILURE; @@ -304,7 +309,8 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - struct zext_screencopy_surface_v1 *surface = + struct zext_screencopy_surface_v1 *surface = capture_cursor ? + zext_screencopy_manager_v1_capture_output_cursor(screencopy_manager, output) : zext_screencopy_manager_v1_capture_output(screencopy_manager, output); zext_screencopy_surface_v1_add_listener(surface, &frame_listener, NULL);