[Spice-devel] [PATCH spice-gtk 3/4] spicy-screenshot: Returns success only if image is grabbed

Frediano Ziglio fziglio at redhat.com
Wed Dec 19 13:25:14 UTC 2018


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tools/spicy-screenshot.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/spicy-screenshot.c b/tools/spicy-screenshot.c
index 0bfd3ca2..13b319d2 100644
--- a/tools/spicy-screenshot.c
+++ b/tools/spicy-screenshot.c
@@ -33,6 +33,8 @@ enum SpiceSurfaceFmt d_format;
 gint                 d_width, d_height, d_stride;
 gpointer             d_data;
 
+static bool image_grabbed = false;
+
 /* ------------------------------------------------------------------ */
 
 static void primary_create(SpiceChannel *channel, gint format,
@@ -93,8 +95,10 @@ static void invalidate(SpiceChannel *channel,
         rc = -1;
         break;
     }
-    if (rc == 0)
+    if (rc == 0) {
         fprintf(stderr, "wrote screen shot to %s\n", outf);
+        image_grabbed = true;
+    }
     g_main_loop_quit(mainloop);
 }
 
@@ -190,5 +194,5 @@ int main(int argc, char *argv[])
     }
 
     g_main_loop_run(mainloop);
-    return 0;
+    return image_grabbed ? 0 : 1;
 }
-- 
2.17.2



More information about the Spice-devel mailing list