Skip to content

Commit

Permalink
android: fix wrong events when locking device in landscape (thanks, J…
Browse files Browse the repository at this point in the history
…oshua!).

"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."
  • Loading branch information
icculus committed Apr 1, 2017
1 parent 7891e72 commit 2092a88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -1229,7 +1229,7 @@ public void run(){
SDLActivity.mSDLThread.start();
}

if (SDLActivity.mHasFocus) {
if (SDLActivity.mHasFocus && !SDLActivity.mIsPaused) {
SDLActivity.handleResume();
}
}
Expand Down

0 comments on commit 2092a88

Please sign in to comment.