|
@@ -291,9 +291,8 @@ static void DrawSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
|
|
|
SDL_RenderPresent(renderer);
|
|
SDL_RenderPresent(renderer);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void loop()
|
|
|
|
|
|
|
+static void update()
|
|
|
{
|
|
{
|
|
|
- int i;
|
|
|
|
|
SDL_Event event;
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
/* Check for events */
|
|
/* Check for events */
|
|
@@ -310,13 +309,31 @@ static void loop()
|
|
|
SDLTest_CommonEvent(state, &event, &done);
|
|
SDLTest_CommonEvent(state, &event, &done);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
+ fillerup();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void draw()
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
|
if (state->windows[i] == NULL) {
|
|
if (state->windows[i] == NULL) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
DrawSprites(state->renderers[i], sprites[i]);
|
|
DrawSprites(state->renderers[i], sprites[i]);
|
|
|
}
|
|
}
|
|
|
- fillerup();
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static bool SDLCALL GDKEventWatch(void* userdata, SDL_Event* event)
|
|
|
|
|
+{
|
|
|
|
|
+ bool *suppressdraw = (bool *)userdata;
|
|
|
|
|
+ SDL_assert(suppressdraw != NULL);
|
|
|
|
|
+ if (event->type == SDL_EVENT_DID_ENTER_BACKGROUND) {
|
|
|
|
|
+ *suppressdraw = true;
|
|
|
|
|
+ SDL_GDKSuspendComplete();
|
|
|
|
|
+ } else if (event->type == SDL_EVENT_WILL_ENTER_FOREGROUND) {
|
|
|
|
|
+ *suppressdraw = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
@@ -324,6 +341,7 @@ int main(int argc, char *argv[])
|
|
|
int i;
|
|
int i;
|
|
|
const char *icon = "icon.bmp";
|
|
const char *icon = "icon.bmp";
|
|
|
char *soundname = NULL;
|
|
char *soundname = NULL;
|
|
|
|
|
+ bool suppressdraw = false;
|
|
|
|
|
|
|
|
/* Initialize parameters */
|
|
/* Initialize parameters */
|
|
|
num_sprites = NUM_SPRITES;
|
|
num_sprites = NUM_SPRITES;
|
|
@@ -390,6 +408,9 @@ int main(int argc, char *argv[])
|
|
|
quit(2);
|
|
quit(2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /* By this point the renderers are made, so we can now add this watcher */
|
|
|
|
|
+ SDL_AddEventWatch(GDKEventWatch, &suppressdraw);
|
|
|
|
|
+
|
|
|
/* Create the windows, initialize the renderers, and load the textures */
|
|
/* Create the windows, initialize the renderers, and load the textures */
|
|
|
sprites =
|
|
sprites =
|
|
|
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
|
|
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
|
|
@@ -441,7 +462,10 @@ int main(int argc, char *argv[])
|
|
|
AddUserSilent();
|
|
AddUserSilent();
|
|
|
|
|
|
|
|
while (!done) {
|
|
while (!done) {
|
|
|
- loop();
|
|
|
|
|
|
|
+ update();
|
|
|
|
|
+ if (!suppressdraw) {
|
|
|
|
|
+ draw();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
quit(0);
|
|
quit(0);
|