Mercurial > sdl-ios-xcode
annotate src/events/SDL_quit.c @ 1168:045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
This allows you to run an SDL program on a system without Xlib, since it'll
just report the x11 target unavailable at runtime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 05 Nov 2005 19:53:37 +0000 |
parents | 51a8702d8ecd |
children | c9b51268668f |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* General quit handling code for SDL */ | |
29 | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1123
diff
changeset
|
30 #if defined (_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1123
diff
changeset
|
31 #define NO_SIGNAL_H |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1123
diff
changeset
|
32 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1123
diff
changeset
|
33 |
0 | 34 #include <stdio.h> |
35 #ifndef NO_SIGNAL_H | |
36 #include <signal.h> | |
37 #endif | |
38 | |
39 #include "SDL_events.h" | |
40 #include "SDL_events_c.h" | |
41 | |
42 | |
43 #ifndef NO_SIGNAL_H | |
44 static void SDL_HandleSIG(int sig) | |
45 { | |
46 /* Reset the signal handler */ | |
47 signal(sig, SDL_HandleSIG); | |
48 | |
49 /* Signal a quit interrupt */ | |
50 SDL_PrivateQuit(); | |
51 } | |
52 #endif /* NO_SIGNAL_H */ | |
53 | |
54 /* Public functions */ | |
55 int SDL_QuitInit(void) | |
56 { | |
57 #ifndef NO_SIGNAL_H | |
58 void (*ohandler)(int); | |
59 | |
60 /* Both SIGINT and SIGTERM are translated into quit interrupts */ | |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
61 ohandler = signal(SIGINT, SDL_HandleSIG); |
0 | 62 if ( ohandler != SIG_DFL ) |
63 signal(SIGINT, ohandler); | |
64 ohandler = signal(SIGTERM, SDL_HandleSIG); | |
65 if ( ohandler != SIG_DFL ) | |
66 signal(SIGTERM, ohandler); | |
67 #endif /* NO_SIGNAL_H */ | |
68 | |
69 /* That's it! */ | |
70 return(0); | |
71 } | |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
72 void SDL_QuitQuit(void) |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
73 { |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
74 #ifndef NO_SIGNAL_H |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
75 void (*ohandler)(int); |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
77 ohandler = signal(SIGINT, SIG_DFL); |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
78 if ( ohandler != SDL_HandleSIG ) |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
79 signal(SIGINT, ohandler); |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
80 ohandler = signal(SIGTERM, SIG_DFL); |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
81 if ( ohandler != SDL_HandleSIG ) |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
82 signal(SIGTERM, ohandler); |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
83 #endif /* NO_SIGNAL_H */ |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
84 } |
0 | 85 |
86 /* This function returns 1 if it's okay to close the application window */ | |
87 int SDL_PrivateQuit(void) | |
88 { | |
89 int posted; | |
90 | |
91 posted = 0; | |
92 if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) { | |
93 SDL_Event event; | |
94 event.type = SDL_QUIT; | |
95 if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { | |
96 posted = 1; | |
97 SDL_PushEvent(&event); | |
98 } | |
99 } | |
100 return(posted); | |
101 } |