events: Disable all the signal-handling code on platforms without support.

So on Windows, for example, this mostly becomes a few empty functions.
Ryan C. Gordon 2019-03-15 16:13:19 -04:00
parent 8a5a05c168
commit f95ca7bb8e
1 changed files with 31 additions and 19 deletions

View File

@ -31,6 +31,11 @@
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_events_c.h" #include "SDL_events_c.h"
#if defined(HAVE_SIGNAL_H) || defined(HAVE_SIGACTION)
#define HAVE_SIGNAL_SUPPORT 1
#endif
#ifdef HAVE_SIGNAL_SUPPORT
static SDL_bool disable_signals = SDL_FALSE; static SDL_bool disable_signals = SDL_FALSE;
static SDL_bool send_quit_pending = SDL_FALSE; static SDL_bool send_quit_pending = SDL_FALSE;
@ -42,7 +47,6 @@ static SDL_bool send_backgrounding_pending = SDL_FALSE;
static SDL_bool send_foregrounding_pending = SDL_FALSE; static SDL_bool send_foregrounding_pending = SDL_FALSE;
#endif #endif
#ifdef HAVE_SIGNAL_H
static void static void
SDL_HandleSIG(int sig) SDL_HandleSIG(int sig)
{ {
@ -67,7 +71,6 @@ SDL_HandleSIG(int sig)
} }
#endif #endif
} }
#endif /* HAVE_SIGNAL_H */
static void static void
SDL_EventSignal_Init(const int sig) SDL_EventSignal_Init(const int sig)
@ -131,15 +134,6 @@ SDL_QuitInit_Internal(void)
return 0; return 0;
} }
int
SDL_QuitInit(void)
{
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
return SDL_QuitInit_Internal();
}
return 0;
}
static void static void
SDL_QuitQuit_Internal(void) SDL_QuitQuit_Internal(void)
{ {
@ -154,26 +148,33 @@ SDL_QuitQuit_Internal(void)
SDL_EventSignal_Quit(SDL_FOREGROUNDING_SIGNAL); SDL_EventSignal_Quit(SDL_FOREGROUNDING_SIGNAL);
#endif #endif
} }
#endif
int
SDL_QuitInit(void)
{
#ifdef HAVE_SIGNAL_SUPPORT
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
return SDL_QuitInit_Internal();
}
#endif
return 0;
}
void void
SDL_QuitQuit(void) SDL_QuitQuit(void)
{ {
#ifdef HAVE_SIGNAL_SUPPORT
if (!disable_signals) { if (!disable_signals) {
SDL_QuitQuit_Internal(); SDL_QuitQuit_Internal();
} }
} #endif
/* This function returns 1 if it's okay to close the application window */
int
SDL_SendQuit(void)
{
send_quit_pending = SDL_FALSE;
return SDL_SendAppEvent(SDL_QUIT);
} }
void void
SDL_SendPendingSignalEvents(void) SDL_SendPendingSignalEvents(void)
{ {
#ifdef HAVE_SIGNAL_SUPPORT
if (send_quit_pending) { if (send_quit_pending) {
SDL_SendQuit(); SDL_SendQuit();
SDL_assert(!send_quit_pending); SDL_assert(!send_quit_pending);
@ -192,6 +193,17 @@ SDL_SendPendingSignalEvents(void)
SDL_OnApplicationDidBecomeActive(); SDL_OnApplicationDidBecomeActive();
} }
#endif #endif
#endif
}
/* This function returns 1 if it's okay to close the application window */
int
SDL_SendQuit(void)
{
#ifdef HAVE_SIGNAL_SUPPORT
send_quit_pending = SDL_FALSE;
#endif
return SDL_SendAppEvent(SDL_QUIT);
} }
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */