2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2006 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
24 /* General quit handling code for SDL */
30 #include "SDL_events.h"
31 #include "SDL_events_c.h"
35 static void SDL_HandleSIG(int sig
)
37 /* Reset the signal handler */
38 signal(sig
, SDL_HandleSIG
);
40 /* Signal a quit interrupt */
43 #endif /* HAVE_SIGNAL_H */
45 /* Public functions */
46 int SDL_QuitInit(void)
49 void (*ohandler
)(int);
51 /* Both SIGINT and SIGTERM are translated into quit interrupts */
52 ohandler
= signal(SIGINT
, SDL_HandleSIG
);
53 if ( ohandler
!= SIG_DFL
)
54 signal(SIGINT
, ohandler
);
55 ohandler
= signal(SIGTERM
, SDL_HandleSIG
);
56 if ( ohandler
!= SIG_DFL
)
57 signal(SIGTERM
, ohandler
);
58 #endif /* HAVE_SIGNAL_H */
63 void SDL_QuitQuit(void)
66 void (*ohandler
)(int);
68 ohandler
= signal(SIGINT
, SIG_DFL
);
69 if ( ohandler
!= SDL_HandleSIG
)
70 signal(SIGINT
, ohandler
);
71 ohandler
= signal(SIGTERM
, SIG_DFL
);
72 if ( ohandler
!= SDL_HandleSIG
)
73 signal(SIGTERM
, ohandler
);
74 #endif /* HAVE_SIGNAL_H */
77 /* This function returns 1 if it's okay to close the application window */
78 int SDL_PrivateQuit(void)
83 if ( SDL_ProcessEvents
[SDL_QUIT
] == SDL_ENABLE
) {
85 event
.type
= SDL_QUIT
;
86 if ( (SDL_EventOK
== NULL
) || (*SDL_EventOK
)(&event
) ) {
88 SDL_PushEvent(&event
);