Mercurial > sdl-ios-xcode
comparison src/events/SDL_quit.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
30 #include "SDL_events.h" | 30 #include "SDL_events.h" |
31 #include "SDL_events_c.h" | 31 #include "SDL_events_c.h" |
32 | 32 |
33 | 33 |
34 #ifdef HAVE_SIGNAL_H | 34 #ifdef HAVE_SIGNAL_H |
35 static void SDL_HandleSIG(int sig) | 35 static void |
36 SDL_HandleSIG (int sig) | |
36 { | 37 { |
37 /* Reset the signal handler */ | 38 /* Reset the signal handler */ |
38 signal(sig, SDL_HandleSIG); | 39 signal (sig, SDL_HandleSIG); |
39 | 40 |
40 /* Signal a quit interrupt */ | 41 /* Signal a quit interrupt */ |
41 SDL_PrivateQuit(); | 42 SDL_PrivateQuit (); |
42 } | 43 } |
43 #endif /* HAVE_SIGNAL_H */ | 44 #endif /* HAVE_SIGNAL_H */ |
44 | 45 |
45 /* Public functions */ | 46 /* Public functions */ |
46 int SDL_QuitInit(void) | 47 int |
48 SDL_QuitInit (void) | |
47 { | 49 { |
48 #ifdef HAVE_SIGNAL_H | 50 #ifdef HAVE_SIGNAL_H |
49 void (*ohandler)(int); | 51 void (*ohandler) (int); |
50 | 52 |
51 /* Both SIGINT and SIGTERM are translated into quit interrupts */ | 53 /* Both SIGINT and SIGTERM are translated into quit interrupts */ |
52 ohandler = signal(SIGINT, SDL_HandleSIG); | 54 ohandler = signal (SIGINT, SDL_HandleSIG); |
53 if ( ohandler != SIG_DFL ) | 55 if (ohandler != SIG_DFL) |
54 signal(SIGINT, ohandler); | 56 signal (SIGINT, ohandler); |
55 ohandler = signal(SIGTERM, SDL_HandleSIG); | 57 ohandler = signal (SIGTERM, SDL_HandleSIG); |
56 if ( ohandler != SIG_DFL ) | 58 if (ohandler != SIG_DFL) |
57 signal(SIGTERM, ohandler); | 59 signal (SIGTERM, ohandler); |
58 #endif /* HAVE_SIGNAL_H */ | 60 #endif /* HAVE_SIGNAL_H */ |
59 | 61 |
60 /* That's it! */ | 62 /* That's it! */ |
61 return(0); | 63 return (0); |
62 } | 64 } |
63 void SDL_QuitQuit(void) | 65 |
66 void | |
67 SDL_QuitQuit (void) | |
64 { | 68 { |
65 #ifdef HAVE_SIGNAL_H | 69 #ifdef HAVE_SIGNAL_H |
66 void (*ohandler)(int); | 70 void (*ohandler) (int); |
67 | 71 |
68 ohandler = signal(SIGINT, SIG_DFL); | 72 ohandler = signal (SIGINT, SIG_DFL); |
69 if ( ohandler != SDL_HandleSIG ) | 73 if (ohandler != SDL_HandleSIG) |
70 signal(SIGINT, ohandler); | 74 signal (SIGINT, ohandler); |
71 ohandler = signal(SIGTERM, SIG_DFL); | 75 ohandler = signal (SIGTERM, SIG_DFL); |
72 if ( ohandler != SDL_HandleSIG ) | 76 if (ohandler != SDL_HandleSIG) |
73 signal(SIGTERM, ohandler); | 77 signal (SIGTERM, ohandler); |
74 #endif /* HAVE_SIGNAL_H */ | 78 #endif /* HAVE_SIGNAL_H */ |
75 } | 79 } |
76 | 80 |
77 /* This function returns 1 if it's okay to close the application window */ | 81 /* This function returns 1 if it's okay to close the application window */ |
78 int SDL_PrivateQuit(void) | 82 int |
83 SDL_PrivateQuit (void) | |
79 { | 84 { |
80 int posted; | 85 int posted; |
81 | 86 |
82 posted = 0; | 87 posted = 0; |
83 if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) { | 88 if (SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE) { |
84 SDL_Event event; | 89 SDL_Event event; |
85 event.type = SDL_QUIT; | 90 event.type = SDL_QUIT; |
86 if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { | 91 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { |
87 posted = 1; | 92 posted = 1; |
88 SDL_PushEvent(&event); | 93 SDL_PushEvent (&event); |
89 } | 94 } |
90 } | 95 } |
91 return(posted); | 96 return (posted); |
92 } | 97 } |
98 | |
99 /* vi: set ts=4 sw=4 expandtab: */ |