Android: fixed immediate transition to pause and resume.

"Pause" transition will add events:
 SDL_WINDOWEVENT_ENTER
 SDL_WINDOWEVENT_FOCUS_LOST
 SDL_WINDOWEVENT_MINIMIZED
 SDL_APP_WILL ENTER BACKGROUND
 SDL_APP_DID ENTER BACKGROUND

"Resume" transition will add events:
 SDL_APP_WILL ENTER FOREGROUND
 SDL_APP_DID ENTER FOREGROUND
 SDL_WINDOWEVENT_FOCUS_GAINED
 SDL_WINDOWEVENT_RESTORED

If Android application doesn't empty the event loop in between, it enters in
"paused" state when SDL_WINDOWEVENT_RESTORED is fetched.

See bug 3250 for pratical case.
This commit is contained in:
Sylvain Becker 2019-01-04 23:39:27 +01:00
parent cf12234454
commit 2a885eb036
1 changed files with 2 additions and 2 deletions

View File

@ -104,8 +104,8 @@ Android_PumpEvents(_THIS)
} else { } else {
if (isPausing || SDL_SemTryWait(Android_PauseSem) == 0) { if (isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
/* We've been signaled to pause, but before we block ourselves, /* We've been signaled to pause, but before we block ourselves,
we need to make sure that certain key events have reached the app */ we need to make sure that the very last event have reached the app */
if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) { if (SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND)) {
isPausing = 1; isPausing = 1;
} }
else { else {