comparison src/events/SDL_quit.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents d910939febfa
children 99210400e8b9
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
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_SendQuit();
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_SendQuit(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 posted = (SDL_PushEvent(&event) > 0);
87 posted = 1; 92 }
88 SDL_PushEvent(&event); 93 return (posted);
89 }
90 }
91 return(posted);
92 } 94 }
95
96 /* vi: set ts=4 sw=4 expandtab: */