# HG changeset patch # User Sam Lantinga # Date 1255765005 0 # Node ID 4ec48602f1db653de2f59a121e5212954a5a7d97 # Parent f96615051c8cb7c9493a615df5b870eff810588c iPhone interruption patch / SDL 1.3 Eric Wing to Sam I've been sitting on this too long. I need to push. It's untested because of the unrelated crashing bug I've been experiencing. Also have a fix for SIZEOF_VOIDP in the config for both iPhone and Mac. diff -r f96615051c8c -r 4ec48602f1db include/SDL_config_iphoneos.h --- a/include/SDL_config_iphoneos.h Tue Oct 13 20:17:11 2009 +0000 +++ b/include/SDL_config_iphoneos.h Sat Oct 17 07:36:45 2009 +0000 @@ -35,6 +35,12 @@ typedef unsigned long uintptr_t; #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + #define SDL_HAS_64BIT_TYPE 1 #define HAVE_ALLOCA_H 1 diff -r f96615051c8c -r 4ec48602f1db include/SDL_config_macosx.h --- a/include/SDL_config_macosx.h Tue Oct 13 20:17:11 2009 +0000 +++ b/include/SDL_config_macosx.h Sat Oct 17 07:36:45 2009 +0000 @@ -30,7 +30,12 @@ /* This is a set of defines to configure the SDL features */ -#define SIZEOF_VOIDP 4 +#ifdef __LP64__ + #define SIZEOF_VOIDP 8 +#else + #define SIZEOF_VOIDP 4 +#endif + #define SDL_HAS_64BIT_TYPE 1 /* Useful headers */ diff -r f96615051c8c -r 4ec48602f1db include/SDL_video.h --- a/include/SDL_video.h Tue Oct 13 20:17:11 2009 +0000 +++ b/include/SDL_video.h Sat Oct 17 07:36:45 2009 +0000 @@ -414,8 +414,9 @@ */ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode); + /** - * \fn SDL_DisplayMode *SDL_GetClosestDisplayMode(const SDL_DisplayMode *mode, SDL_DisplayMode *closest) + * \fn SDL_DisplayMode SDL_GetClosestDisplayMode(const SDL_DisplayMode mode, SDL_DisplayMode closest) * * \brief Get the closest match to the requested display mode. * diff -r f96615051c8c -r 4ec48602f1db src/video/cocoa/SDL_cocoawindow.h --- a/src/video/cocoa/SDL_cocoawindow.h Tue Oct 13 20:17:11 2009 +0000 +++ b/src/video/cocoa/SDL_cocoawindow.h Sat Oct 17 07:36:45 2009 +0000 @@ -24,10 +24,16 @@ #ifndef _SDL_cocoawindow_h #define _SDL_cocoawindow_h +#import + typedef struct SDL_WindowData SDL_WindowData; /* *INDENT-OFF* */ -@interface Cocoa_WindowListener:NSResponder { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 +@interface Cocoa_WindowListener : NSResponder { +#else +@interface Cocoa_WindowListener : NSResponder { +#endif SDL_WindowData *_data; } diff -r f96615051c8c -r 4ec48602f1db src/video/uikit/SDL_uikitappdelegate.h --- a/src/video/uikit/SDL_uikitappdelegate.h Tue Oct 13 20:17:11 2009 +0000 +++ b/src/video/uikit/SDL_uikitappdelegate.h Sat Oct 17 07:36:45 2009 +0000 @@ -26,9 +26,11 @@ /* *INDENT-OFF* */ @interface SDLUIKitDelegate:NSObject { UIWindow *window; + SDL_WindowID windowID; } @property (readwrite, retain) UIWindow *window; +@property (readwrite, assign) SDL_WindowID windowID; +(SDLUIKitDelegate *)sharedAppDelegate; diff -r f96615051c8c -r 4ec48602f1db src/video/uikit/SDL_uikitappdelegate.m --- a/src/video/uikit/SDL_uikitappdelegate.m Tue Oct 13 20:17:11 2009 +0000 +++ b/src/video/uikit/SDL_uikitappdelegate.m Sat Oct 17 07:36:45 2009 +0000 @@ -56,6 +56,7 @@ @implementation SDLUIKitDelegate @synthesize window; +@synthesize windowID; /* convenience method */ +(SDLUIKitDelegate *)sharedAppDelegate { @@ -66,6 +67,7 @@ - (id)init { self = [super init]; window = nil; + windowID = 0; return self; } @@ -97,6 +99,20 @@ } +- (void) applicationWillResignActive:(UIApplication*)application +{ +// NSLog(@"%@", NSStringFromSelector(_cmd)); + SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_MINIMIZED, 0, 0); +} + +- (void) applicationDidBecomeActive:(UIApplication*)application +{ +// NSLog(@"%@", NSStringFromSelector(_cmd)); + SDL_SendWindowEvent(self.windowID, SDL_WINDOWEVENT_RESTORED, 0, 0); +} + + + -(void)dealloc { [window release]; [super dealloc]; diff -r f96615051c8c -r 4ec48602f1db src/video/uikit/SDL_uikitwindow.m --- a/src/video/uikit/SDL_uikitwindow.m Tue Oct 13 20:17:11 2009 +0000 +++ b/src/video/uikit/SDL_uikitwindow.m Sat Oct 17 07:36:45 2009 +0000 @@ -82,7 +82,7 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) { - /* iPhone applications are single window only */ + /* We currently only handle single window applications on iPhone */ if (nil != [SDLUIKitDelegate sharedAppDelegate].window) { SDL_SetError("Window already exists, no multi-window support."); return -1; @@ -96,7 +96,10 @@ return -1; } + // This saves the main window in the app delegate so event callbacks can do stuff on the window. + // This assumes a single window application design and needs to be fixed for multiple windows. [SDLUIKitDelegate sharedAppDelegate].window = uiwindow; + [SDLUIKitDelegate sharedAppDelegate].windowID = window->id; [uiwindow release]; /* release the window (the app delegate has retained it) */ return 1; @@ -113,6 +116,7 @@ /* this will also destroy the window */ [SDLUIKitDelegate sharedAppDelegate].window = nil; + [SDLUIKitDelegate sharedAppDelegate].windowID = 0; }