src/events/SDL_quit.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9998 f67cf37e9cd4
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5501
diff changeset
     2
  Simple DirectMedia Layer
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9720
diff changeset
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5501
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: 5501
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: 5501
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5501
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: 5501
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: 5501
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5501
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: 5501
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: 5501
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: 5501
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5501
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: 5501
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: 5501
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7190
diff changeset
    21
#include "../SDL_internal.h"
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    22
#include "SDL_hints.h"
9720
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    23
#include "SDL_assert.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    24
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    25
/* General quit handling code for SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
    27
#ifdef HAVE_SIGNAL_H
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    28
#include <signal.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    29
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    31
#include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    32
#include "SDL_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    33
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    34
static SDL_bool disable_signals = SDL_FALSE;
9720
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    35
static SDL_bool send_quit_pending = SDL_FALSE;
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    36
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
    37
#ifdef HAVE_SIGNAL_H
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    38
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    39
SDL_HandleSIG(int sig)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    40
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    41
    /* Reset the signal handler */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    42
    signal(sig, SDL_HandleSIG);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    43
9720
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    44
    /* Send a quit event next time the event loop pumps. */
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    45
    /* We can't send it in signal handler; malloc() might be interrupted! */
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
    46
    send_quit_pending = SDL_TRUE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    47
}
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
    48
#endif /* HAVE_SIGNAL_H */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    49
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    50
/* Public functions */
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    51
static int
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    52
SDL_QuitInit_Internal(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    53
{
5493
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    54
#ifdef HAVE_SIGACTION
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    55
    struct sigaction action;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    56
    sigaction(SIGINT, NULL, &action);
5577
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    57
#ifdef HAVE_SA_SIGACTION
5501
f48c1e0ca9ae Fixed compiler warning
Sam Lantinga <slouken@libsdl.org>
parents: 5493
diff changeset
    58
    if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) {
5577
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    59
#else
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    60
    if ( action.sa_handler == SIG_DFL ) {
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    61
#endif
5493
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    62
        action.sa_handler = SDL_HandleSIG;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    63
        sigaction(SIGINT, &action, NULL);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    64
    }
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    65
    sigaction(SIGTERM, NULL, &action);
5577
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    66
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    67
#ifdef HAVE_SA_SIGACTION
5501
f48c1e0ca9ae Fixed compiler warning
Sam Lantinga <slouken@libsdl.org>
parents: 5493
diff changeset
    68
    if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) {
5577
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    69
#else
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    70
    if ( action.sa_handler == SIG_DFL ) {
ced8a6788629 Work on systems without sa_sigaction.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
    71
#endif
5493
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    72
        action.sa_handler = SDL_HandleSIG;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    73
        sigaction(SIGTERM, &action, NULL);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    74
    }
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    75
#elif HAVE_SIGNAL_H
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    76
    void (*ohandler) (int);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    77
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    78
    /* Both SIGINT and SIGTERM are translated into quit interrupts */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    79
    ohandler = signal(SIGINT, SDL_HandleSIG);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    80
    if (ohandler != SIG_DFL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    81
        signal(SIGINT, ohandler);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    82
    ohandler = signal(SIGTERM, SDL_HandleSIG);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    83
    if (ohandler != SIG_DFL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    84
        signal(SIGTERM, ohandler);
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
    85
#endif /* HAVE_SIGNAL_H */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    86
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    87
    /* That's it! */
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    88
    return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    89
}
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    90
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    91
int
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    92
SDL_QuitInit(void)
1123
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
    93
{
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    94
    const char *hint = SDL_GetHint(SDL_HINT_NO_SIGNAL_HANDLERS);
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    95
    disable_signals = hint && (SDL_atoi(hint) == 1);
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    96
    if (!disable_signals) {
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    97
        return SDL_QuitInit_Internal();
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
    98
    }
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
    99
    return 0;
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   100
}
9434
0a695c9c3c71 Added a hint to prevent SDL from installing signal handlers.
Ryan C. Gordon <icculus@icculus.org>
parents: 8149
diff changeset
   101
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   102
static void
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   103
SDL_QuitQuit_Internal(void)
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   104
{
5493
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   105
#ifdef HAVE_SIGACTION
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   106
    struct sigaction action;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   107
    sigaction(SIGINT, NULL, &action);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   108
    if ( action.sa_handler == SDL_HandleSIG ) {
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   109
        action.sa_handler = SIG_DFL;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   110
        sigaction(SIGINT, &action, NULL);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   111
    }
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   112
    sigaction(SIGTERM, NULL, &action);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   113
    if ( action.sa_handler == SDL_HandleSIG ) {
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   114
        action.sa_handler = SIG_DFL;
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   115
        sigaction(SIGTERM, &action, NULL);
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   116
    }
a8849b1193c3 Do not break application's signal handler installed with SA_SIGINFO
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   117
#elif HAVE_SIGNAL_H
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   118
    void (*ohandler) (int);
1123
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   119
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   120
    ohandler = signal(SIGINT, SIG_DFL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   121
    if (ohandler != SDL_HandleSIG)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   122
        signal(SIGINT, ohandler);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   123
    ohandler = signal(SIGTERM, SIG_DFL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   124
    if (ohandler != SDL_HandleSIG)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   125
        signal(SIGTERM, ohandler);
1330
450721ad5436 It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
   126
#endif /* HAVE_SIGNAL_H */
1123
28ac87a38c17 Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
   127
}
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   128
9436
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   129
void
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   130
SDL_QuitQuit(void)
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   131
{
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   132
    if (!disable_signals) {
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   133
        SDL_QuitQuit_Internal();
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   134
    }
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   135
}
0af69dab9bb6 Patched to compile on C89 compilers.
Ryan C. Gordon <icculus@icculus.org>
parents: 9435
diff changeset
   136
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   137
/* This function returns 1 if it's okay to close the application window */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   138
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   139
SDL_SendQuit(void)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   140
{
9720
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   141
    send_quit_pending = SDL_FALSE;
7190
11612d544fcd Added mobile application events, with implementations for iOS and Android
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   142
    return SDL_SendAppEvent(SDL_QUIT);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   143
}
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   144
9720
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   145
void
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   146
SDL_SendPendingQuit(void)
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   147
{
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   148
    if (send_quit_pending) {
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   149
        SDL_SendQuit();
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   150
        SDL_assert(!send_quit_pending);
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   151
    }
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   152
}
fd60d77139fc Unix: Don't send quit events during signal handler.
Ryan C. Gordon <icculus@icculus.org>
parents: 9619
diff changeset
   153
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   154
/* vi: set ts=4 sw=4 expandtab: */