src/render/SDL_render.c
changeset 6060 59d398ac031e
parent 6044 35448a5ea044
child 6138 4c64952a58fb
--- a/src/render/SDL_render.c	Mon Nov 07 02:24:52 2011 -0500
+++ b/src/render/SDL_render.c	Mon Nov 07 23:07:00 2011 -0500
@@ -111,6 +111,10 @@
                 viewport.w = renderer->viewport.w;
                 viewport.h = renderer->viewport.h;
                 SDL_RenderSetViewport(renderer, &viewport);
+            } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
+                renderer->minimized = SDL_TRUE;
+            } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) {
+                renderer->minimized = SDL_FALSE;
             }
         }
     }
@@ -189,6 +193,12 @@
         renderer->magic = &renderer_magic;
         renderer->window = window;
 
+        if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) {
+            renderer->minimized = SDL_TRUE;
+        } else {
+            renderer->minimized = SDL_FALSE;
+        }
+
         SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer);
 
         SDL_RenderSetViewport(renderer, NULL);
@@ -873,6 +883,10 @@
 {
     CHECK_RENDERER_MAGIC(renderer, -1);
 
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     return renderer->RenderClear(renderer);
 }
 
@@ -899,6 +913,10 @@
     if (count < 1) {
         return 0;
     }
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     return renderer->RenderDrawPoints(renderer, points, count);
 }
 
@@ -927,6 +945,10 @@
     if (count < 2) {
         return 0;
     }
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     return renderer->RenderDrawLines(renderer, points, count);
 }
 
@@ -976,6 +998,10 @@
         return 0;
     }
 
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     for (i = 0; i < count; ++i) {
         if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) {
             return -1;
@@ -1015,6 +1041,10 @@
     if (count < 1) {
         return 0;
     }
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     return renderer->RenderFillRects(renderer, rects, count);
 }
 
@@ -1072,6 +1102,10 @@
         texture = texture->native;
     }
 
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return 0;
+    }
     return renderer->RenderCopy(renderer, texture, &real_srcrect,
                                 &real_dstrect);
 }
@@ -1121,6 +1155,10 @@
 {
     CHECK_RENDERER_MAGIC(renderer, );
 
+    /* Don't draw while we're minimized */
+    if (renderer->minimized) {
+        return;
+    }
     renderer->RenderPresent(renderer);
 }