Mercurial > sdl-ios-xcode
diff 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 |
line wrap: on
line diff
--- a/src/events/SDL_quit.c Thu Jul 06 18:01:37 2006 +0000 +++ b/src/events/SDL_quit.c Mon Jul 10 21:04:37 2006 +0000 @@ -32,61 +32,65 @@ #ifdef HAVE_SIGNAL_H -static void SDL_HandleSIG(int sig) +static void +SDL_HandleSIG(int sig) { - /* Reset the signal handler */ - signal(sig, SDL_HandleSIG); + /* Reset the signal handler */ + signal(sig, SDL_HandleSIG); - /* Signal a quit interrupt */ - SDL_PrivateQuit(); + /* Signal a quit interrupt */ + SDL_SendQuit(); } #endif /* HAVE_SIGNAL_H */ /* Public functions */ -int SDL_QuitInit(void) +int +SDL_QuitInit(void) { #ifdef HAVE_SIGNAL_H - void (*ohandler)(int); + void (*ohandler) (int); - /* Both SIGINT and SIGTERM are translated into quit interrupts */ - ohandler = signal(SIGINT, SDL_HandleSIG); - if ( ohandler != SIG_DFL ) - signal(SIGINT, ohandler); - ohandler = signal(SIGTERM, SDL_HandleSIG); - if ( ohandler != SIG_DFL ) - signal(SIGTERM, ohandler); + /* Both SIGINT and SIGTERM are translated into quit interrupts */ + ohandler = signal(SIGINT, SDL_HandleSIG); + if (ohandler != SIG_DFL) + signal(SIGINT, ohandler); + ohandler = signal(SIGTERM, SDL_HandleSIG); + if (ohandler != SIG_DFL) + signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ - /* That's it! */ - return(0); + /* That's it! */ + return (0); } -void SDL_QuitQuit(void) + +void +SDL_QuitQuit(void) { #ifdef HAVE_SIGNAL_H - void (*ohandler)(int); + void (*ohandler) (int); - ohandler = signal(SIGINT, SIG_DFL); - if ( ohandler != SDL_HandleSIG ) - signal(SIGINT, ohandler); - ohandler = signal(SIGTERM, SIG_DFL); - if ( ohandler != SDL_HandleSIG ) - signal(SIGTERM, ohandler); + ohandler = signal(SIGINT, SIG_DFL); + if (ohandler != SDL_HandleSIG) + signal(SIGINT, ohandler); + ohandler = signal(SIGTERM, SIG_DFL); + if (ohandler != SDL_HandleSIG) + signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ } /* This function returns 1 if it's okay to close the application window */ -int SDL_PrivateQuit(void) +int +SDL_SendQuit(void) { - int posted; + int posted; - posted = 0; - if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) { - SDL_Event event; - event.type = SDL_QUIT; - if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { - posted = 1; - SDL_PushEvent(&event); - } - } - return(posted); + posted = 0; + if (SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + posted = (SDL_PushEvent(&event) > 0); + } + return (posted); } + +/* vi: set ts=4 sw=4 expandtab: */