From 66df00cee2dc0acb3cb71919ac4cf32b4112c3f3 Mon Sep 17 00:00:00 2001
From: Jonathan Rubenstein <jrubcop@gmail.com>
Date: Sun, 19 Jul 2020 00:29:29 -0400
Subject: [PATCH] Add option to skip splash screen fade out

---
 client/include/interface/renderer.h |  1 +
 client/renderers/EGL/egl.c          |  7 ++++++-
 client/renderers/OpenGL/opengl.c    | 10 ++++++++--
 client/src/config.c                 |  8 ++++++++
 client/src/main.c                   |  3 ++-
 client/src/main.h                   |  1 +
 6 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/client/include/interface/renderer.h b/client/include/interface/renderer.h
index b2b81a92..b89eb770 100644
--- a/client/include/interface/renderer.h
+++ b/client/include/interface/renderer.h
@@ -47,6 +47,7 @@ typedef struct LG_RendererParams
 //  TTF_Font * font;
 //  TTF_Font * alertFont;
   bool       showFPS;
+  bool       quickSplash;
 }
 LG_RendererParams;
 
diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c
index cd410690..efb60bf3 100644
--- a/client/renderers/EGL/egl.c
+++ b/client/renderers/EGL/egl.c
@@ -549,7 +549,12 @@ bool egl_render(void * opaque, SDL_Window * window)
         this->useNearest))
   {
     if (!this->waitFadeTime)
-      this->waitFadeTime = microtime() + SPLASH_FADE_TIME;
+    {
+      if (!this->params.quickSplash)
+        this->waitFadeTime = microtime() + SPLASH_FADE_TIME;
+      else
+        this->waitDone = true;
+    }
     egl_cursor_render(this->cursor);
   }
 
diff --git a/client/renderers/OpenGL/opengl.c b/client/renderers/OpenGL/opengl.c
index 9108f50b..61507b64 100644
--- a/client/renderers/OpenGL/opengl.c
+++ b/client/renderers/OpenGL/opengl.c
@@ -413,8 +413,14 @@ bool opengl_on_frame_event(void * opaque, const LG_RendererFormat format, const
 
   if (this->waiting)
   {
-    this->waiting      = false;
-    this->waitFadeTime = microtime() + FADE_TIME;
+    this->waiting = false;
+    if (!this->params.quickSplash)
+      this->waitFadeTime = microtime() + FADE_TIME;
+    else
+    {
+      glDisable(GL_MULTISAMPLE);
+      this->waitDone = true;
+    }
   }
 
   return true;
diff --git a/client/src/config.c b/client/src/config.c
index d12185c2..1843c7cb 100644
--- a/client/src/config.c
+++ b/client/src/config.c
@@ -213,6 +213,13 @@ static struct Option options[] =
     .type           = OPTION_TYPE_BOOL,
     .value.x_bool   = true,
   },
+  {
+    .module         = "win",
+    .name           = "quickSplash",
+    .description    = "Skip fading out the splash screen when a connection is established",
+    .type           = OPTION_TYPE_BOOL,
+    .value.x_bool   = false,
+  },
 
   // input options
   {
@@ -401,6 +408,7 @@ bool config_load(int argc, char * argv[])
   params.ignoreQuit    = option_get_bool  ("win", "ignoreQuit"   );
   params.noScreensaver = option_get_bool  ("win", "noScreensaver");
   params.showAlerts    = option_get_bool  ("win", "alerts"       );
+  params.quickSplash   = option_get_bool  ("win", "quickSplash"  );
 
   params.grabKeyboard  = option_get_bool  ("input", "grabKeyboard");
   params.escapeKey     = option_get_int   ("input", "escapeKey"   );
diff --git a/client/src/main.c b/client/src/main.c
index 7a406999..e0da904c 100644
--- a/client/src/main.c
+++ b/client/src/main.c
@@ -1284,7 +1284,8 @@ static int lg_run()
 
   // select and init a renderer
   LG_RendererParams lgrParams;
-  lgrParams.showFPS = params.showFPS;
+  lgrParams.showFPS     = params.showFPS;
+  lgrParams.quickSplash = params.quickSplash;
   Uint32 sdlFlags;
 
   if (params.forceRenderer)
diff --git a/client/src/main.h b/client/src/main.h
index 2fd0b56f..68c13ba6 100644
--- a/client/src/main.h
+++ b/client/src/main.h
@@ -151,6 +151,7 @@ struct AppParams
   SDL_Scancode escapeKey;
   bool         showAlerts;
   bool         captureOnStart;
+  bool         quickSplash;
 
   unsigned int cursorPollInterval;
   unsigned int framePollInterval;