From 655622dc62a9952caa8caa37febc3e83a1c693df Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 25 Jun 2012 11:10:34 -0400 Subject: [PATCH] Disable the SDL event pump after the SDL main routine returns, since events will be dispatched by the Cocoa event loop. --- include/SDL_system.h | 1 + src/video/uikit/SDL_uikitappdelegate.m | 3 +++ src/video/uikit/SDL_uikitevents.m | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/include/SDL_system.h b/include/SDL_system.h index 0ff5ced56..feb4d36c4 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -43,6 +43,7 @@ extern "C" { #include "SDL_video.h" extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); +extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardShow(SDL_Window * window); extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardHide(SDL_Window * window); diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index f0998ec8b..abc7a26b6 100755 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -26,6 +26,7 @@ #import "SDL_assert.h" #import "SDL_hints.h" #import "../../SDL_hints_c.h" +#import "SDL_system.h" #import "SDL_uikitappdelegate.h" #import "SDL_uikitopenglview.h" @@ -105,7 +106,9 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged); /* run the user's application, passing argc and argv */ + SDL_iPhoneSetEventPump(SDL_TRUE); exit_status = SDL_main(forward_argc, forward_argv); + SDL_iPhoneSetEventPump(SDL_FALSE); /* exit, passing the return status from the user's application */ // We don't actually exit to support applications that do setup in diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index 4dea87f8b..ddd6b3d02 100755 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -30,9 +30,20 @@ #import #include "jumphack.h" +static BOOL UIKit_EventPumpEnabled = YES; + +void +SDL_iPhoneSetEventPump(SDL_bool enabled) +{ + UIKit_EventPumpEnabled = enabled; +} + void UIKit_PumpEvents(_THIS) { + if (!UIKit_EventPumpEnabled) + return; + /* When the user presses the 'home' button on the iPod the application exits -- immediatly.