events: Disable all the signal-handling code on platforms without support. So on Windows, for example, this mostly becomes a few empty functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c
index 78864f2..9528ed8 100644
--- a/src/events/SDL_quit.c
+++ b/src/events/SDL_quit.c
@@ -31,6 +31,11 @@
#include "SDL_events.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 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;
#endif
-#ifdef HAVE_SIGNAL_H
static void
SDL_HandleSIG(int sig)
{
@@ -67,7 +71,6 @@ SDL_HandleSIG(int sig)
}
#endif
}
-#endif /* HAVE_SIGNAL_H */
static void
SDL_EventSignal_Init(const int sig)
@@ -131,15 +134,6 @@ SDL_QuitInit_Internal(void)
return 0;
}
-int
-SDL_QuitInit(void)
-{
- if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
- return SDL_QuitInit_Internal();
- }
- return 0;
-}
-
static void
SDL_QuitQuit_Internal(void)
{
@@ -154,26 +148,33 @@ SDL_QuitQuit_Internal(void)
SDL_EventSignal_Quit(SDL_FOREGROUNDING_SIGNAL);
#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
SDL_QuitQuit(void)
{
+#ifdef HAVE_SIGNAL_SUPPORT
if (!disable_signals) {
SDL_QuitQuit_Internal();
}
-}
-
-/* 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);
+#endif
}
void
SDL_SendPendingSignalEvents(void)
{
+#ifdef HAVE_SIGNAL_SUPPORT
if (send_quit_pending) {
SDL_SendQuit();
SDL_assert(!send_quit_pending);
@@ -192,6 +193,17 @@ SDL_SendPendingSignalEvents(void)
SDL_OnApplicationDidBecomeActive();
}
#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: */