Android: fixed immediate transition to pause and resume.
authorSylvain Becker <sylvain.becker@gmail.com>
Fri, 04 Jan 2019 23:39:27 +0100
changeset 12501bedfecf09e71
parent 12500 42a61bf08873
child 12503 806492103856
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.
src/video/android/SDL_androidevents.c
     1.1 --- a/src/video/android/SDL_androidevents.c	Fri Jan 04 23:11:21 2019 +0100
     1.2 +++ b/src/video/android/SDL_androidevents.c	Fri Jan 04 23:39:27 2019 +0100
     1.3 @@ -104,8 +104,8 @@
     1.4      } else {
     1.5          if (isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
     1.6              /* We've been signaled to pause, but before we block ourselves,
     1.7 -            we need to make sure that certain key events have reached the app */
     1.8 -            if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) {
     1.9 +            we need to make sure that the very last event have reached the app */
    1.10 +            if (SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND)) {
    1.11                  isPausing = 1;
    1.12              }
    1.13              else {