diff options
author | Chris West <therealchriswest@hotmail.com> | 2013-01-13 22:04:26 +0000 |
---|---|---|
committer | Chris West <therealchriswest@hotmail.com> | 2013-01-19 16:46:47 +0000 |
commit | 50c2852ae77174fcd6272bb4326c6ceab2633fc2 (patch) | |
tree | 06ab1faaf67eded97193f30c72964ec3df437c55 /crawl-ref/source/libutil.cc | |
parent | b72183a640caeb04b1d800ab1eb2233d8ce9dc47 (diff) | |
download | crawl-ref-50c2852ae77174fcd6272bb4326c6ceab2633fc2.tar.gz crawl-ref-50c2852ae77174fcd6272bb4326c6ceab2633fc2.zip |
fixed issue with crawl not closing when sent to background in Android
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r-- | crawl-ref/source/libutil.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index f28d77a52d..63b884c66c 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -1193,7 +1193,7 @@ void text_popup(const string& text, const wchar_t *caption) MessageBoxW(0, OUTW(text), caption, MB_OK); } #else -# ifdef USE_CURSES +# if defined(USE_CURSES) || defined(__ANDROID__) /* [ds] This SIGHUP handling is primitive and far from safe, but it * should be better than nothing. Feel free to get rigorous on this. @@ -1202,7 +1202,13 @@ static void handle_hangup(int) { if (crawl_state.seen_hups++) return; - +#ifdef __ANDROID__ + // for android, we're currently using SIGHUP to immediately close + // the app, as cleanly as possible. The 'correct' thing to do is + // completely reconstitute the OpenGL state, from scratch, which is + // somewhat more complicated + sighup_save_and_exit(); +#else // When using Curses, closing stdin will cause any Curses call blocking // on key-presses to immediately return, including any call that was // still blocking in the main thread when the HUP signal was caught. @@ -1217,6 +1223,7 @@ static void handle_hangup(int) // the hack of avoiding excomunication consesquences because of the // more() after "You have lost your religion!" fclose(stdin); +#endif } # endif @@ -1238,9 +1245,16 @@ void init_signals() #endif # ifdef USE_TILE_LOCAL +# ifdef __ANDROID__ + // Currently Android will SIGHUP the app when it's sent into the background + // ... because the alternative (of resetting OpenGL state and reloading all + // the textures is *super* complicated + signal(SIGHUP, handle_hangup); +# else // Losing the controlling terminal doesn't matter, we continue and will // shut down only when the actual window is closed. signal(SIGHUP, SIG_IGN); +# endif # else signal(SIGHUP, handle_hangup); # endif |