From 2541754f6c607acfd1304af38280b534f7a8e0d7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 7 Nov 2012 15:44:26 +0300 Subject: Fix termination on Android by using "home" key. --- src/client.cpp | 17 +++++++++++++++++ src/game.cpp | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index a73dc6806..fe5ec8e16 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -883,6 +883,7 @@ int Client::gameExec() { case SDL_QUIT: mState = STATE_EXIT; + logger->log("force exit"); break; case SDL_KEYDOWN: @@ -907,7 +908,21 @@ int Client::gameExec() inputManager.handleAssignKey(event, INPUT_JOYSTICK); break; +#ifdef ANDROID + case SDL_ACTIVEEVENT: + if ((event.active.state & SDL_APPACTIVE) + && !event.active.gain) + { + mState = STATE_EXIT; + logger->log("exit on lost focus"); + } + break; +#endif + case SDL_MOUSEMOTION: + break; + default: +// logger->log("unknown event: %d", event.type); break; case SDL_VIDEORESIZE: @@ -924,6 +939,8 @@ int Client::gameExec() } #endif } + if (mState == STATE_EXIT) + continue; BLOCK_END("Client::gameExec 2") } diff --git a/src/game.cpp b/src/game.cpp index 3cf000229..df23a0146 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -871,12 +871,16 @@ void Game::handleActive(const SDL_Event &event) } else { // window minimisation +#ifdef ANDROID + Client::setState(STATE_EXIT); +#else Client::setIsMinimized(true); if (player_node && !player_node->getAway()) { fpsLimit = config.getIntValue("altfpslimit"); player_node->setHalfAway(true); } +#endif } if (player_node) player_node->updateStatus(); -- cgit v1.2.3-70-g09d2