[Android] Fixes Bug 2041 - can't get SDL_QUIT event...

Thanks to Denis Bernard!

Also, changed the Android manifest so the app doesn't quit with orientation
changes, and made testgles.c exit properly on Android.
This commit is contained in:
Gabriel Jacobo
2013-11-06 11:23:24 -03:00
parent e27248c27e
commit 22770a8f40
5 changed files with 18 additions and 5 deletions

View File

@@ -283,9 +283,16 @@ void Java_org_libsdl_app_SDLActivity_nativeLowMemory(
void Java_org_libsdl_app_SDLActivity_nativeQuit(
JNIEnv* env, jclass cls)
{
/* Discard previous events. The user should have handled state storage
* in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no
* events other than SDL_QUIT and SDL_APP_TERMINATING should fire */
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
/* Inject a SDL_QUIT event */
SDL_SendQuit();
SDL_SendAppEvent(SDL_APP_TERMINATING);
/* Resume the event loop so that the app can catch SDL_QUIT which
* should now be the top event in the event queue. */
if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem);
}
/* Pause */