Send SDL_VIDEORESIZE event when app restored from background

This commit is contained in:
pelya
2011-03-09 19:06:04 +02:00
parent 90691c4579
commit 15d39e1af5
6 changed files with 25 additions and 3 deletions

View File

@@ -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=''

View File

@@ -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 */

View File

@@ -1 +1 @@
ufoai
ballfield

View File

@@ -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;

View File

@@ -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.