src/video/uikit/SDL_uikitevents.m
author Sam Lantinga
Fri, 11 Feb 2011 22:37:15 -0800
changeset 5262 b530ef003506
parent 5131 7b7da52e8775
child 5535 96594ac5fd1a
permissions -rw-r--r--
Happy 2011! :)
slouken@2765
     1
/*
slouken@2765
     2
    SDL - Simple DirectMedia Layer
slouken@5262
     3
    Copyright (C) 1997-2011 Sam Lantinga
slouken@2765
     4
slouken@2765
     5
    This library is free software; you can redistribute it and/or
slouken@2765
     6
    modify it under the terms of the GNU Lesser General Public
slouken@2765
     7
    License as published by the Free Software Foundation; either
slouken@2765
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@2765
     9
slouken@2765
    10
    This library is distributed in the hope that it will be useful,
slouken@2765
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2765
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2765
    13
    Lesser General Public License for more details.
slouken@2765
    14
slouken@2765
    15
    You should have received a copy of the GNU Lesser General Public
slouken@2765
    16
    License along with this library; if not, write to the Free Software
slouken@2765
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2765
    18
slouken@2765
    19
    Sam Lantinga
slouken@2765
    20
    slouken@libsdl.org
slouken@2765
    21
*/
slouken@2765
    22
#include "SDL_config.h"
slouken@2765
    23
slouken@2765
    24
#include "../../events/SDL_events_c.h"
slouken@2765
    25
slouken@2765
    26
#include "SDL_uikitvideo.h"
slouken@2765
    27
#include "SDL_uikitevents.h"
slouken@2765
    28
slouken@2765
    29
#import <Foundation/Foundation.h>
slouken@2765
    30
#include "jumphack.h"
slouken@2765
    31
slouken@2765
    32
void
slouken@2765
    33
UIKit_PumpEvents(_THIS)
slouken@2765
    34
{
slouken@5131
    35
    /* 
slouken@5131
    36
        When the user presses the 'home' button on the iPod
slouken@5131
    37
        the application exits -- immediatly.
slouken@5131
    38
     
slouken@5131
    39
        Unlike in Mac OS X, it appears there is no way to cancel the termination.
slouken@5131
    40
     
slouken@5131
    41
        This doesn't give the SDL user's application time to respond to an SDL_Quit event.
slouken@5131
    42
        So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate),
slouken@5131
    43
        when the delegate receives the ApplicationWillTerminate message, we execute
slouken@5131
    44
        a longjmp statement to get back here, preventing an immediate exit.
slouken@5131
    45
     */    
slouken@5131
    46
    if (setjmp(*jump_env()) == 0) {
slouken@5131
    47
        /* if we're setting the jump, rather than jumping back */
slouken@5131
    48
        SInt32 result;
slouken@5131
    49
        do {
slouken@5131
    50
            result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
slouken@5131
    51
        } while(result == kCFRunLoopRunHandledSource);
slouken@5131
    52
    }
slouken@2765
    53
}
slouken@2765
    54
slouken@2765
    55
/* vi: set ts=4 sw=4 expandtab: */