From 2092a88359b3e6ff948d9ab6383ccdbbf56305ed Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 31 Mar 2017 23:43:53 -0400 Subject: [PATCH] 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index ec7a5bf1a..a49184b42 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -1229,7 +1229,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, SDLActivity.mSDLThread.start(); } - if (SDLActivity.mHasFocus) { + if (SDLActivity.mHasFocus && !SDLActivity.mIsPaused) { SDLActivity.handleResume(); } }