Commit 2a885eb0364418846efedcebfe773cec5205e191

Sylvain Becker 2019-01-04T23:39:27

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c
index 8e8ecd6..d692968 100644
--- a/src/video/android/SDL_androidevents.c
+++ b/src/video/android/SDL_androidevents.c
@@ -104,8 +104,8 @@ Android_PumpEvents(_THIS)
     } else {
         if (isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
             /* We've been signaled to pause, but before we block ourselves,
-            we need to make sure that certain key events have reached the app */
-            if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) {
+            we need to make sure that the very last event have reached the app */
+            if (SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND)) {
                 isPausing = 1;
             }
             else {