src/video/uikit/SDL_uikitappdelegate.m
author Sam Lantinga <slouken@libsdl.org>
Mon, 31 Oct 2011 05:56:58 -0400
changeset 6044 35448a5ea044
parent 6006 889d89332de4
child 6090 687400b595ab
permissions -rw-r--r--
Lots of fixes importing SDL source wholesale into a new iOS project
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     2
  Simple DirectMedia Layer
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5251
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     7
  arising from the use of this software.
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5251
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    11
  freely, subject to the following restrictions:
5262
b530ef003506 Happy 2011! :)
Sam Lantinga <slouken@libsdl.org>
parents: 5251
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5532
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6006
diff changeset
    21
#include "SDL_config.h"
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6006
diff changeset
    22
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6006
diff changeset
    23
#if SDL_VIDEO_DRIVER_UIKIT
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
    25
#import "../SDL_sysvideo.h"
5555
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    26
#import "SDL_assert.h"
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    27
#import "SDL_hints.h"
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    28
#import "../../SDL_hints_c.h"
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
    29
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#import "SDL_uikitappdelegate.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#import "SDL_uikitopenglview.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#import "SDL_events_c.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#import "jumphack.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#ifdef main
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#undef main
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
extern int SDL_main(int argc, char *argv[]);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
static int forward_argc;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
static char **forward_argv;
6006
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    42
static int exit_status;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    44
int main(int argc, char **argv)
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    45
{
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    46
    int i;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    47
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
    48
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    49
    /* store arguments */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    50
    forward_argc = argc;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    51
    forward_argv = (char **)malloc((argc+1) * sizeof(char *));
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    52
    for (i = 0; i < argc; i++) {
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    53
        forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    54
        strcpy(forward_argv[i], argv[i]);
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    55
    }
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    56
    forward_argv[i] = NULL;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    58
    /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
5532
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    59
    UIApplicationMain(argc, argv, NULL, [SDLUIKitDelegate getAppDelegateClassName]);
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
    60
6006
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    61
    /* free the memory we used to hold copies of argc and argv */
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    62
    for (i = 0; i < forward_argc; i++) {
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    63
        free(forward_argv[i]);
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    64
    }
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    65
    free(forward_argv);
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    66
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    67
    [pool release];
6006
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    68
    return exit_status;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    71
static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue)
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    72
{
5555
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    73
    SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0);
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
    74
5555
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    75
    BOOL disable = (*newValue != '0');
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    76
    [UIApplication sharedApplication].idleTimerDisabled = disable;
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    77
}
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
    78
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
@implementation SDLUIKitDelegate
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
/* convenience method */
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    82
+ (SDLUIKitDelegate *)sharedAppDelegate
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    83
{
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    84
    /* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    85
    return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    88
+ (NSString *)getAppDelegateClassName
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    89
{
5532
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    90
    /* subclassing notice: when you subclass this appdelegate, make sure to add a category to override
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    91
       this method and return the actual name of the delegate */
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    92
    return @"SDLUIKitDelegate";
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    93
}
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
    94
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    95
- (id)init
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    96
{
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    97
    self = [super init];
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
    98
    return self;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   101
- (void)postFinishLaunch
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   102
{
5555
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
   103
    /* register a callback for the idletimer hint */
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
   104
    SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "0");
3ecad5e5dbe4 * SDL_IOS_IDLE_TIMER_DISABLED hint
Tim Angus <tim@blackcompanystudios.co.uk>
parents: 5535
diff changeset
   105
    SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);
3422
ec4db979dddb Fixed bug #847
Sam Lantinga <slouken@libsdl.org>
parents: 3400
diff changeset
   106
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   107
    /* run the user's application, passing argc and argv */
6006
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
   108
    exit_status = SDL_main(forward_argc, forward_argv);
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
   109
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   110
    /* exit, passing the return status from the user's application */
6006
889d89332de4 Do not exit in (uikit) postFinishLaunch but store the exit status and use that to return from main()
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
   111
    // exit(exit_status);
3422
ec4db979dddb Fixed bug #847
Sam Lantinga <slouken@libsdl.org>
parents: 3400
diff changeset
   112
}
ec4db979dddb Fixed bug #847
Sam Lantinga <slouken@libsdl.org>
parents: 3400
diff changeset
   113
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   114
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   115
{
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   116
    /* Set working directory to resource path */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   117
    [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
   118
5532
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
   119
    [self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
5487
ad3abbbe0381 Delegate should use application: didFinishLaunchingWithOptions:
Sam Lantinga <slouken@libsdl.org>
parents: 5332
diff changeset
   120
ad3abbbe0381 Delegate should use application: didFinishLaunchingWithOptions:
Sam Lantinga <slouken@libsdl.org>
parents: 5332
diff changeset
   121
    return YES;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   124
- (void)applicationWillTerminate:(UIApplication *)application
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   125
{
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   126
    SDL_SendQuit();
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   127
     /* hack to prevent automatic termination.  See SDL_uikitevents.m for details */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 4489
diff changeset
   128
    longjmp(*(jump_env()), 1);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
3400
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   131
- (void) applicationWillResignActive:(UIApplication*)application
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   132
{
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   133
    //NSLog(@"%@", NSStringFromSelector(_cmd));
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   134
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   135
    // Send every window on every screen a MINIMIZED event.
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   136
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   137
    if (!_this) {
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   138
        return;
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   139
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
   140
5532
8a04b596b472 Allow overriding the app delegate on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5487
diff changeset
   141
    SDL_Window *window;
5251
1b0de3574c58 Fixed compile in Xcode
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
   142
    for (window = _this->windows; window != nil; window = window->next) {
1b0de3574c58 Fixed compile in Xcode
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
   143
        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   144
    }
3400
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   145
}
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   146
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   147
- (void) applicationDidBecomeActive:(UIApplication*)application
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   148
{
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   149
    //NSLog(@"%@", NSStringFromSelector(_cmd));
3400
4ec48602f1db iPhone interruption patch / SDL 1.3
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   150
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   151
    // Send every window on every screen a RESTORED event.
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   152
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   153
    if (!_this) {
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   154
        return;
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   155
    }
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5614
diff changeset
   156
5614
50bf98210aae Convert a few TABs into spaces
Kees Bakker <kees@tweeler.com>
parents: 5555
diff changeset
   157
    SDL_Window *window;
5251
1b0de3574c58 Fixed compile in Xcode
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
   158
    for (window = _this->windows; window != nil; window = window->next) {
5614
50bf98210aae Convert a few TABs into spaces
Kees Bakker <kees@tweeler.com>
parents: 5555
diff changeset
   159
        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 3685
diff changeset
   160
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
@end
5132
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5131
diff changeset
   164
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6006
diff changeset
   165
#endif /* SDL_VIDEO_DRIVER_UIKIT */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6006
diff changeset
   166
5132
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5131
diff changeset
   167
/* vi: set ts=4 sw=4 expandtab: */