From 15d39e1af5d18092c61c96ac519eae304b64fbbe Mon Sep 17 00:00:00 2001 From: pelya Date: Wed, 9 Mar 2011 19:06:04 +0200 Subject: [PATCH] Send SDL_VIDEORESIZE event when app restored from background --- .../application/ballfield/AndroidAppSettings.cfg | 2 +- project/jni/application/ballfield/ballfield.cpp | 8 ++++++++ project/jni/application/src | 2 +- .../jni/application/ufoai/AndroidData/base.zip | Bin 160 -> 0 bytes .../src/video/android/SDL_androidvideo-1.2.c | 13 +++++++++++++ readme.txt | 3 ++- 6 files changed, 25 insertions(+), 3 deletions(-) delete mode 100644 project/jni/application/ufoai/AndroidData/base.zip diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index bf049c5c7..a61f74995 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -25,7 +25,7 @@ RedefinedKeysScreenKb="1 2 3 4 5 6 1 2 3 4" MultiABI=n AppVersionCode=101 AppVersionName="1.01" -CompiledLibraries="sdl_mixer sdl_image curl" +CompiledLibraries="sdl_mixer sdl_image" CustomBuildScript=n AppCflags='-O2 -finline-functions' AppLdflags='' diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index 8bc83ba6c..32a12fe0b 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -465,6 +465,14 @@ int main(int argc, char* argv[]) break; __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: state %d key %d mod %d unicode %d", event.key.state, (int)event.key.keysym.sym, (int)event.key.keysym.mod, (int)event.key.keysym.unicode); } + if(event.type & SDL_VIDEORESIZE) + { + __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL resize event: %d x %d", event.resize.w, event.resize.h); + } + if(event.type & SDL_ACTIVEEVENT) + { + __android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL active event: gain %d", event.active.gain); + } } /* Timing */ diff --git a/project/jni/application/src b/project/jni/application/src index 92362c4db..104f796a6 120000 --- a/project/jni/application/src +++ b/project/jni/application/src @@ -1 +1 @@ -ufoai \ No newline at end of file +ballfield \ No newline at end of file diff --git a/project/jni/application/ufoai/AndroidData/base.zip b/project/jni/application/ufoai/AndroidData/base.zip deleted file mode 100644 index 990032ff2944a0700d76a369858a44262a827c97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmWIWW@h1H0D+J!M>`M=!>kN43`vQ_srsQIoD9qc93H-g93H-<72FJrEH9WD7{Ek; sHzSiAGcE%ppk@g$ymbUIp~kU7jKeUBl?|kbk%5uHn}LDB9>ie)09`~At^fc4 diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index 0f82d6fd4..28d61cbc6 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -27,6 +27,7 @@ #include "SDL_thread.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" #include "SDL_pixels.h" #include "SDL_video-1.3.h" @@ -934,6 +935,18 @@ void SDL_ANDROID_VideoContextLost() void SDL_ANDROID_VideoContextRecreated() { + __android_log_print(ANDROID_LOG_INFO, "libSDL", "Sending SDL_VIDEORESIZE event %dx%d", SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight); + //SDL_PrivateResize(SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight); + if ( SDL_ProcessEvents[SDL_VIDEORESIZE] == SDL_ENABLE ) { + SDL_Event event; + event.type = SDL_VIDEORESIZE; + event.resize.w = SDL_ANDROID_sFakeWindowWidth; + event.resize.h = SDL_ANDROID_sFakeWindowHeight; + if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { + SDL_PushEvent(&event); + } + } + if( ! sdl_opengl ) { int i; diff --git a/readme.txt b/readme.txt index a05096cdd..68ca345b6 100644 --- a/readme.txt +++ b/readme.txt @@ -201,7 +201,8 @@ where callback_t is function pointer of type "void (*) void". The default callbacks will call another Android-specific functions: SDL_ANDROID_PauseAudioPlayback() and SDL_ANDROID_ResumeAudioPlayback() which will pause and resume audio from HW layer, so appplication does not need to destroy and re-init audio. -Also, the usual event SDL_ACTIVEEVENT with flag SDL_APPACTIVE will be sent when that happens. +Also, the usual event SDL_ACTIVEEVENT with flag SDL_APPACTIVE will be sent when that happens, +and also SDL_VIDEORESIZE event will be sent (the same behavior as in MacOsX SDL implementation). If you're using OpenAL for an audio playback you have to call functions al_android_pause_playback() and al_android_resume_playback() by yourself when SDL calls your callbacks.