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. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404102
This commit is contained in:
parent
f22214ce9b
commit
f2ae715bf4
7 changed files with 44 additions and 4 deletions
|
@ -35,6 +35,12 @@ typedef unsigned int uint32_t;
|
||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
#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 SDL_HAS_64BIT_TYPE 1
|
||||||
|
|
||||||
#define HAVE_ALLOCA_H 1
|
#define HAVE_ALLOCA_H 1
|
||||||
|
|
|
@ -30,7 +30,12 @@
|
||||||
|
|
||||||
/* This is a set of defines to configure the SDL features */
|
/* 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
|
#define SDL_HAS_64BIT_TYPE 1
|
||||||
|
|
||||||
/* Useful headers */
|
/* Useful headers */
|
||||||
|
|
|
@ -414,8 +414,9 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode);
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
|
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.
|
* \brief Get the closest match to the requested display mode.
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,10 +24,16 @@
|
||||||
#ifndef _SDL_cocoawindow_h
|
#ifndef _SDL_cocoawindow_h
|
||||||
#define _SDL_cocoawindow_h
|
#define _SDL_cocoawindow_h
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
typedef struct SDL_WindowData SDL_WindowData;
|
typedef struct SDL_WindowData SDL_WindowData;
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
@interface Cocoa_WindowListener:NSResponder {
|
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
|
||||||
|
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
|
||||||
|
#else
|
||||||
|
@interface Cocoa_WindowListener : NSResponder {
|
||||||
|
#endif
|
||||||
SDL_WindowData *_data;
|
SDL_WindowData *_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
|
@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
|
||||||
UIWindow *window;
|
UIWindow *window;
|
||||||
|
SDL_WindowID windowID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (readwrite, retain) UIWindow *window;
|
@property (readwrite, retain) UIWindow *window;
|
||||||
|
@property (readwrite, assign) SDL_WindowID windowID;
|
||||||
|
|
||||||
+(SDLUIKitDelegate *)sharedAppDelegate;
|
+(SDLUIKitDelegate *)sharedAppDelegate;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ int main(int argc, char **argv) {
|
||||||
@implementation SDLUIKitDelegate
|
@implementation SDLUIKitDelegate
|
||||||
|
|
||||||
@synthesize window;
|
@synthesize window;
|
||||||
|
@synthesize windowID;
|
||||||
|
|
||||||
/* convenience method */
|
/* convenience method */
|
||||||
+(SDLUIKitDelegate *)sharedAppDelegate {
|
+(SDLUIKitDelegate *)sharedAppDelegate {
|
||||||
|
@ -66,6 +67,7 @@ int main(int argc, char **argv) {
|
||||||
- (id)init {
|
- (id)init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
window = nil;
|
window = nil;
|
||||||
|
windowID = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +99,20 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (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 {
|
-(void)dealloc {
|
||||||
[window release];
|
[window release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
|
|
@ -82,7 +82,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
||||||
|
|
||||||
int UIKit_CreateWindow(_THIS, SDL_Window *window) {
|
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) {
|
if (nil != [SDLUIKitDelegate sharedAppDelegate].window) {
|
||||||
SDL_SetError("Window already exists, no multi-window support.");
|
SDL_SetError("Window already exists, no multi-window support.");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -96,7 +96,10 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) {
|
||||||
return -1;
|
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].window = uiwindow;
|
||||||
|
[SDLUIKitDelegate sharedAppDelegate].windowID = window->id;
|
||||||
[uiwindow release]; /* release the window (the app delegate has retained it) */
|
[uiwindow release]; /* release the window (the app delegate has retained it) */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -113,6 +116,7 @@ void UIKit_DestroyWindow(_THIS, SDL_Window * window) {
|
||||||
|
|
||||||
/* this will also destroy the window */
|
/* this will also destroy the window */
|
||||||
[SDLUIKitDelegate sharedAppDelegate].window = nil;
|
[SDLUIKitDelegate sharedAppDelegate].window = nil;
|
||||||
|
[SDLUIKitDelegate sharedAppDelegate].windowID = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue