Skip to content

Commit

Permalink
Send SDL_VIDEORESIZE event when app restored from background
Browse files Browse the repository at this point in the history
  • Loading branch information
pelya committed Mar 9, 2011
1 parent 90691c4 commit 15d39e1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion project/jni/application/ballfield/AndroidAppSettings.cfg
Expand Up @@ -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=''
Expand Down
8 changes: 8 additions & 0 deletions project/jni/application/ballfield/ballfield.cpp
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion project/jni/application/src
Binary file removed project/jni/application/ufoai/AndroidData/base.zip
Binary file not shown.
13 changes: 13 additions & 0 deletions project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Expand Up @@ -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.

Expand Down

0 comments on commit 15d39e1

Please sign in to comment.