From 9e9ef5ad3181b4f72098a5162944cd0d37032ca7 Mon Sep 17 00:00:00 2001
From: David Ludwig <dludwig@pobox.com>
Date: Sun, 27 Dec 2015 17:55:45 -0500
Subject: [PATCH] Fixed bug 3202 - Fix renderer visibility on a window
 maximized directly from the minimized state

Many thanks to id.zeta for details on the bug, and for the fix!
---
 src/events/SDL_windowevents.c | 2 ++
 src/render/SDL_render.c       | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c
index 0e480f276..26f43abc5 100644
--- a/src/events/SDL_windowevents.c
+++ b/src/events/SDL_windowevents.c
@@ -127,6 +127,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
         if (window->flags & SDL_WINDOW_MINIMIZED) {
             return 0;
         }
+        window->flags &= ~SDL_WINDOW_MAXIMIZED;
         window->flags |= SDL_WINDOW_MINIMIZED;
         SDL_OnWindowMinimized(window);
         break;
@@ -134,6 +135,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
         if (window->flags & SDL_WINDOW_MAXIMIZED) {
             return 0;
         }
+        window->flags &= ~SDL_WINDOW_MINIMIZED;
         window->flags |= SDL_WINDOW_MAXIMIZED;
         break;
     case SDL_WINDOWEVENT_RESTORED:
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index f00688b05..bb0113bae 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -158,7 +158,8 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
                 }
             } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
                 renderer->hidden = SDL_TRUE;
-            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
+            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED || 
+                       event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
                 if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) {
                     renderer->hidden = SDL_FALSE;
                 }