From dec2e6e30c53341a0d0db615e5ed8c26217977b9 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Mon, 23 Sep 2019 15:37:05 +0100
Subject: [PATCH] showimage: Add a -quit option
This allows showimage to be used as a non-interactive smoke-test to
check that the SDL2_image library can be linked against successfully,
for example as used in the Steam Runtime:
xvfb-run ./showimage -quit -save debian-logo.bmp /usr/share/pixmaps/debian-logo.png
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
showimage.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/showimage.c b/showimage.c
index 6b668ea..109a3d2 100644
--- a/showimage.c
+++ b/showimage.c
@@ -54,7 +54,8 @@ int main(int argc, char *argv[])
SDL_Renderer *renderer;
SDL_Texture *texture;
Uint32 flags;
- int i, w, h, done;
+ int i, w, h;
+ int done = 0;
SDL_Event event;
const char *saveFile = NULL;
@@ -87,6 +88,11 @@ int main(int argc, char *argv[])
continue;
}
+ if ( SDL_strcmp(argv[i], "-quit") == 0 ) {
+ done = 1;
+ continue;
+ }
+
if ( SDL_strcmp(argv[i], "-save") == 0 && argv[i+1] ) {
++i;
saveFile = argv[i];
@@ -127,7 +133,6 @@ int main(int argc, char *argv[])
SDL_SetWindowSize(window, w, h);
SDL_ShowWindow(window);
- done = 0;
while ( ! done ) {
while ( SDL_PollEvent(&event) ) {
switch (event.type) {