src/video/uikit/SDL_uikitevents.m
author Sam Lantinga
Fri, 08 Apr 2011 13:03:26 -0700
changeset 5535 96594ac5fd1a
parent 5262 b530ef003506
child 6001 3ae3d1e58d59
permissions -rw-r--r--
SDL 1.3 is now under the zlib license.
slouken@2765
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@5535
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@2765
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2765
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2765
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2765
    20
*/
slouken@2765
    21
#include "SDL_config.h"
slouken@2765
    22
slouken@2765
    23
#include "../../events/SDL_events_c.h"
slouken@2765
    24
slouken@2765
    25
#include "SDL_uikitvideo.h"
slouken@2765
    26
#include "SDL_uikitevents.h"
slouken@2765
    27
slouken@2765
    28
#import <Foundation/Foundation.h>
slouken@2765
    29
#include "jumphack.h"
slouken@2765
    30
slouken@2765
    31
void
slouken@2765
    32
UIKit_PumpEvents(_THIS)
slouken@2765
    33
{
slouken@5131
    34
    /* 
slouken@5131
    35
        When the user presses the 'home' button on the iPod
slouken@5131
    36
        the application exits -- immediatly.
slouken@5131
    37
     
slouken@5131
    38
        Unlike in Mac OS X, it appears there is no way to cancel the termination.
slouken@5131
    39
     
slouken@5131
    40
        This doesn't give the SDL user's application time to respond to an SDL_Quit event.
slouken@5131
    41
        So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
slouken@5131
    42
        when the delegate receives the ApplicationWillTerminate message, we execute
slouken@5131
    43
        a longjmp statement to get back here, preventing an immediate exit.
slouken@5131
    44
     */    
slouken@5131
    45
    if (setjmp(*jump_env()) == 0) {
slouken@5131
    46
        /* if we're setting the jump, rather than jumping back */
slouken@5131
    47
        SInt32 result;
slouken@5131
    48
        do {
slouken@5131
    49
            result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
slouken@5131
    50
        } while(result == kCFRunLoopRunHandledSource);
slouken@5131
    51
    }
slouken@2765
    52
}
slouken@2765
    53
slouken@2765
    54
/* vi: set ts=4 sw=4 expandtab: */