Add support for (scaled down) high resolution modes.
[SDL.s60v3.git] / src / events / SDL_quit.c
blob591f3274abd4c0e3c238a4abad4edba072b32fce
1 /*
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
19 Sam Lantinga
20 slouken@libsdl.org
22 #include "SDL_config.h"
24 /* General quit handling code for SDL */
26 #ifdef HAVE_SIGNAL_H
27 #include <signal.h>
28 #endif
30 #include "SDL_events.h"
31 #include "SDL_events_c.h"
34 #ifdef HAVE_SIGNAL_H
35 static void SDL_HandleSIG(int sig)
37 /* Reset the signal handler */
38 signal(sig, SDL_HandleSIG);
40 /* Signal a quit interrupt */
41 SDL_PrivateQuit();
43 #endif /* HAVE_SIGNAL_H */
45 /* Public functions */
46 int SDL_QuitInit(void)
48 #ifdef HAVE_SIGNAL_H
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 */
60 /* That's it! */
61 return(0);
63 void SDL_QuitQuit(void)
65 #ifdef HAVE_SIGNAL_H
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)
80 int posted;
82 posted = 0;
83 if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) {
84 SDL_Event event;
85 event.type = SDL_QUIT;
86 if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
87 posted = 1;
88 SDL_PushEvent(&event);
91 return(posted);