Don't block Android event loop until all relevant events reach the app.
This commit is contained in:
parent
7c835f8560
commit
d36e0cf8b9
1 changed files with 22 additions and 1 deletions
|
@ -23,11 +23,15 @@
|
||||||
#if SDL_VIDEO_DRIVER_ANDROID
|
#if SDL_VIDEO_DRIVER_ANDROID
|
||||||
|
|
||||||
#include "SDL_androidevents.h"
|
#include "SDL_androidevents.h"
|
||||||
|
#include "SDL_events.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
Android_PumpEvents(_THIS)
|
Android_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
static int isPaused = 0;
|
static int isPaused = 0;
|
||||||
|
#if SDL_ANDROID_BLOCK_ON_PAUSE
|
||||||
|
static int isPausing = 0;
|
||||||
|
#endif
|
||||||
/* No polling necessary */
|
/* No polling necessary */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,10 +40,12 @@ Android_PumpEvents(_THIS)
|
||||||
* When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
|
* When the resume semaphore is signaled, SDL_GL_CreateContext is called which in turn calls Java code
|
||||||
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
|
* SDLActivity::createGLContext -> SDLActivity:: initEGL -> SDLActivity::createEGLSurface -> SDLActivity::createEGLContext
|
||||||
*/
|
*/
|
||||||
if (isPaused) {
|
|
||||||
#if SDL_ANDROID_BLOCK_ON_PAUSE
|
#if SDL_ANDROID_BLOCK_ON_PAUSE
|
||||||
|
if (isPaused && !isPausing) {
|
||||||
if(SDL_SemWait(Android_ResumeSem) == 0) {
|
if(SDL_SemWait(Android_ResumeSem) == 0) {
|
||||||
#else
|
#else
|
||||||
|
if (isPaused) {
|
||||||
if(SDL_SemTryWait(Android_ResumeSem) == 0) {
|
if(SDL_SemTryWait(Android_ResumeSem) == 0) {
|
||||||
#endif
|
#endif
|
||||||
isPaused = 0;
|
isPaused = 0;
|
||||||
|
@ -53,10 +59,25 @@ Android_PumpEvents(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if SDL_ANDROID_BLOCK_ON_PAUSE
|
||||||
|
if( isPausing || SDL_SemTryWait(Android_PauseSem) == 0 ) {
|
||||||
|
/* We've been signaled to pause, but before we block ourselves, we need to make sure that
|
||||||
|
SDL_WINDOWEVENT_FOCUS_LOST and SDL_WINDOWEVENT_MINIMIZED have reached the app */
|
||||||
|
if (SDL_HasEvent(SDL_WINDOWEVENT)) {
|
||||||
|
isPausing = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isPausing = 0;
|
||||||
|
isPaused = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if(SDL_SemTryWait(Android_PauseSem) == 0) {
|
if(SDL_SemTryWait(Android_PauseSem) == 0) {
|
||||||
/* If we fall in here, the system is/was paused */
|
/* If we fall in here, the system is/was paused */
|
||||||
isPaused = 1;
|
isPaused = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue