android: fix wrong events when locking device in landscape (thanks, Joshua!).
authorRyan C. Gordon <icculus@icculus.org>
Fri, 31 Mar 2017 23:43:53 -0400
changeset 109518625e527f0f0
parent 10950 fd1b8fd3b937
child 10952 fabcc99bb455
android: fix wrong events when locking device in landscape (thanks, Joshua!).

"Using an application in portrait orientation, turning off the device would
dispatch SDL_APP_WILLENTERBACKGROUND, then SDL_APP_DIDENTERBACKGROUND then
lock the screen.

However, rotating the application the application to landscape, then turning
off the device would incorrectly dispatch SDL_APP_WILLENTERBACKGROUND,
SDL_APP_WILLENTERBACKGROUND, SDL_APP_WILLENTERFOREGROUND and then
SDL_APP_DIDENTERFOREGROUND before locking the screen. You can imagine how
this created trouble :)

It appears this occurs because (on this application) turning off a device
when in landscape is triggering a resize. The resize logic in SDLActivity
triggers a resume.

This patch has resolved the issue on my device:

It prevents the dispatch of (improper) FOREGROUND events when locking
the device, but we get still events when the device is turned back on
and unlocked."
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Mar 30 06:52:34 2017 -0700
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Fri Mar 31 23:43:53 2017 -0400
     1.3 @@ -1229,7 +1229,7 @@
     1.4              SDLActivity.mSDLThread.start();
     1.5          }
     1.6  
     1.7 -        if (SDLActivity.mHasFocus) {
     1.8 +        if (SDLActivity.mHasFocus && !SDLActivity.mIsPaused) {
     1.9              SDLActivity.handleResume();
    1.10          }
    1.11      }