Mercurial > sdl-ios-xcode
annotate src/SDL.c @ 4139:568c9b3c0167 SDL-1.2
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
* Use XResetScreenSaver() instead of disabling screensaver entirely.
Full discussion summary from Erik on the SDL mailing list:
Current behaviour
=================
SDL changes the user's display power management settings without
permission from the user and without telling the user.
The interface that it uses to do so is DPMSDisable/DPMSEnable, which
should only ever be used by configuration utilities like KControl, never
by normal application programs, let alone by the libraries that they
use. Using an interface that is not at all intended for what SDL tries
to achieve means that it will not work as it should. Firstly, the power
management is completely disabled during the whole lifetime of the SDL
program, not only when it should be. Secondly, it makes SDL
non-reentrant, meaning that things will break when multiple SDL programs
are clients of the same X server simultaneously. Thirdly, no cleanup
mechanism ensures that the setting is restored if the client does not do
that (for example if it crashes).
In addition to that, this interface is broken on xorg,
[http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries
to do does not work at all on that implementation of the X Window
System. (The reason that the DPMSEnable works in KControl is that it
calls DPMSSetTimeout immediately after,
[http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]).
The problems that the current behaviour causes
==============================================
1. Information leak. When the user is away, someone might see what the
user has on the display when the user counts on the screensaver
preventing this. This does not even require physical access to the
workstation, it is enough to see it from a distance.
2. Draining battery. An SDL program that runs on a laptop will quickly
drain the battery while the user is away. The system will soon shut down
and require recharging before being usable again, while it should in
fact have consumed very little energy if the user's settings would have
been obeyed.
3. Wasting energy. Even if battery issues are not considered, energy as
such is wasted.
4. Display wear. The display may be worn out.
The problems that the current behaviour tries to solve
======================================================
1. Preventing screensaver while playing movies.
Many SDL applications are media players. They have reasons to prevent
screensavers from being activated while a movie is being played. When a
user clicks on the play button it can be interpreted as saying "play
this movie, but do not turn off the display while playing it, because I
will watch it even though I do not interact with the system".
2. Preventing screensaver when some input bypasses X.
Sometimes SDL uses input from another source than the X server, so
that the X server is bypassed. This obviously breaks the screensaver
handling. SDL tries to work around that.
3. Preventing screensaver when all input bypasses X.
There is something called Direct Graphics Access mode, where a
program takes control of both the display and the input devices from the
X server. This obviously means that the X server can not handle the
screensaver alone, since screensaver handling depends on input handling.
SDL does not do what it should to help the X server to handle the
screensaver. Nor does SDL take care of screeensaver handling itself. SDL
simply disables the screensaver completely.
How the problems should be solved
=================================
The correct way for an application program to prevent the screensaver
under X is to call XResetScreenSaver. This was recently discovered and
implemented by the mplayer developers,
[http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to
wrap this in an API call (SDL_ResetScreenSaver) and implement it for the
other video targets (if they do not have a corresponding call, SDL
should do what it takes on that particular target, for example sending
fake key events).
1. When a movie is played, the player should reset the screensaver when
the animation is advanced to a new frame. The same applies to anything
similar, like slideshows.
2. When the X server is handling input, it must handle all input
(keyboards, mice, gamepads, ...). This is necessary, not only to be able
to handle the screensaver, but also so that it can send the events to
the correct (the currently active) client. If there is an input device
that the X server can not handle for some reason (such as lack of Plug
and Play capability), the program that handles the device as a
workaround must simulate what would happen if the X server would have
handled the device, by calling XResetScreenSaver when input is received
from the device.
3. When the X server is not handling the input, it depends on the
program that does to call XResetScreenSaver whenever an input event
occurs. Alternatively the program must handle the screensaver countdown
internally and call XActivateScreenSaver.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 29 Feb 2008 13:55:44 +0000 |
parents | 8582c6a5ca16 |
children | a1b03ba2fcd0 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
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 | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1190
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
36
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Initialization code for SDL */ | |
25 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 #include "SDL.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
27 #include "SDL_fatal.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
28 #if !SDL_VIDEO_DISABLED |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
29 #include "video/SDL_leaks.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
30 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #if SDL_THREAD_PTH |
557
0ce5a68278fd
Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
33 #include <pth.h> |
0ce5a68278fd
Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
34 #endif |
0 | 35 |
36 /* Initialization/Cleanup routines */ | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
37 #if !SDL_JOYSTICK_DISABLED |
0 | 38 extern int SDL_JoystickInit(void); |
39 extern void SDL_JoystickQuit(void); | |
40 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
41 #if !SDL_CDROM_DISABLED |
0 | 42 extern int SDL_CDROMInit(void); |
43 extern void SDL_CDROMQuit(void); | |
44 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
45 #if !SDL_TIMERS_DISABLED |
0 | 46 extern void SDL_StartTicks(void); |
47 extern int SDL_TimerInit(void); | |
48 extern void SDL_TimerQuit(void); | |
49 #endif | |
50 | |
51 /* The current SDL version */ | |
52 static SDL_version version = | |
53 { SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL }; | |
54 | |
55 /* The initialized subsystems */ | |
56 static Uint32 SDL_initialized = 0; | |
3976
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
3975
diff
changeset
|
57 #if !SDL_TIMERS_DISABLED |
0 | 58 static Uint32 ticks_started = 0; |
3976
8582c6a5ca16
Added initial support for Nintendo DS, based on the work by Troy Davis (GPF)
Sam Lantinga <slouken@libsdl.org>
parents:
3975
diff
changeset
|
59 #endif |
0 | 60 |
61 #ifdef CHECK_LEAKS | |
62 int surfaces_allocated = 0; | |
63 #endif | |
64 | |
65 int SDL_InitSubSystem(Uint32 flags) | |
66 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
67 #if !SDL_VIDEO_DISABLED |
0 | 68 /* Initialize the video/event subsystem */ |
69 if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
70 if ( SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"), |
0 | 71 (flags&SDL_INIT_EVENTTHREAD)) < 0 ) { |
72 return(-1); | |
73 } | |
74 SDL_initialized |= SDL_INIT_VIDEO; | |
75 } | |
76 #else | |
77 if ( flags & SDL_INIT_VIDEO ) { | |
78 SDL_SetError("SDL not built with video support"); | |
79 return(-1); | |
80 } | |
81 #endif | |
82 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
83 #if !SDL_AUDIO_DISABLED |
0 | 84 /* Initialize the audio subsystem */ |
85 if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1330
diff
changeset
|
86 if ( SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0 ) { |
0 | 87 return(-1); |
88 } | |
89 SDL_initialized |= SDL_INIT_AUDIO; | |
90 } | |
91 #else | |
92 if ( flags & SDL_INIT_AUDIO ) { | |
93 SDL_SetError("SDL not built with audio support"); | |
94 return(-1); | |
95 } | |
96 #endif | |
97 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
98 #if !SDL_TIMERS_DISABLED |
0 | 99 /* Initialize the timer subsystem */ |
100 if ( ! ticks_started ) { | |
101 SDL_StartTicks(); | |
102 ticks_started = 1; | |
103 } | |
104 if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) { | |
105 if ( SDL_TimerInit() < 0 ) { | |
106 return(-1); | |
107 } | |
108 SDL_initialized |= SDL_INIT_TIMER; | |
109 } | |
110 #else | |
111 if ( flags & SDL_INIT_TIMER ) { | |
112 SDL_SetError("SDL not built with timer support"); | |
113 return(-1); | |
114 } | |
115 #endif | |
116 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
117 #if !SDL_JOYSTICK_DISABLED |
0 | 118 /* Initialize the joystick subsystem */ |
119 if ( (flags & SDL_INIT_JOYSTICK) && | |
120 !(SDL_initialized & SDL_INIT_JOYSTICK) ) { | |
121 if ( SDL_JoystickInit() < 0 ) { | |
122 return(-1); | |
123 } | |
124 SDL_initialized |= SDL_INIT_JOYSTICK; | |
125 } | |
126 #else | |
127 if ( flags & SDL_INIT_JOYSTICK ) { | |
128 SDL_SetError("SDL not built with joystick support"); | |
129 return(-1); | |
130 } | |
131 #endif | |
132 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
133 #if !SDL_CDROM_DISABLED |
0 | 134 /* Initialize the CD-ROM subsystem */ |
135 if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) { | |
136 if ( SDL_CDROMInit() < 0 ) { | |
137 return(-1); | |
138 } | |
139 SDL_initialized |= SDL_INIT_CDROM; | |
140 } | |
141 #else | |
142 if ( flags & SDL_INIT_CDROM ) { | |
143 SDL_SetError("SDL not built with cdrom support"); | |
144 return(-1); | |
145 } | |
146 #endif | |
147 return(0); | |
148 } | |
149 | |
150 int SDL_Init(Uint32 flags) | |
151 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
152 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
397 | 153 if (!pth_init()) { |
154 return -1; | |
155 } | |
156 #endif | |
157 | |
0 | 158 /* Clear the error message */ |
159 SDL_ClearError(); | |
160 | |
161 /* Initialize the desired subsystems */ | |
162 if ( SDL_InitSubSystem(flags) < 0 ) { | |
163 return(-1); | |
164 } | |
165 | |
166 /* Everything is initialized */ | |
167 if ( !(flags & SDL_INIT_NOPARACHUTE) ) { | |
168 SDL_InstallParachute(); | |
169 } | |
170 return(0); | |
171 } | |
172 | |
173 void SDL_QuitSubSystem(Uint32 flags) | |
174 { | |
175 /* Shut down requested initialized subsystems */ | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
176 #if !SDL_CDROM_DISABLED |
0 | 177 if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) { |
178 SDL_CDROMQuit(); | |
179 SDL_initialized &= ~SDL_INIT_CDROM; | |
180 } | |
181 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
182 #if !SDL_JOYSTICK_DISABLED |
0 | 183 if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) { |
184 SDL_JoystickQuit(); | |
185 SDL_initialized &= ~SDL_INIT_JOYSTICK; | |
186 } | |
187 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
188 #if !SDL_TIMERS_DISABLED |
0 | 189 if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) { |
190 SDL_TimerQuit(); | |
191 SDL_initialized &= ~SDL_INIT_TIMER; | |
192 } | |
193 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
194 #if !SDL_AUDIO_DISABLED |
0 | 195 if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) { |
196 SDL_AudioQuit(); | |
197 SDL_initialized &= ~SDL_INIT_AUDIO; | |
198 } | |
199 #endif | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
200 #if !SDL_VIDEO_DISABLED |
0 | 201 if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) { |
202 SDL_VideoQuit(); | |
203 SDL_initialized &= ~SDL_INIT_VIDEO; | |
204 } | |
205 #endif | |
206 } | |
207 | |
208 Uint32 SDL_WasInit(Uint32 flags) | |
209 { | |
210 if ( ! flags ) { | |
211 flags = SDL_INIT_EVERYTHING; | |
212 } | |
213 return (SDL_initialized&flags); | |
214 } | |
215 | |
216 void SDL_Quit(void) | |
217 { | |
218 /* Quit all subsystems */ | |
1190 | 219 #ifdef DEBUG_BUILD |
220 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); fflush(stdout); | |
221 #endif | |
0 | 222 SDL_QuitSubSystem(SDL_INIT_EVERYTHING); |
223 | |
224 #ifdef CHECK_LEAKS | |
1190 | 225 #ifdef DEBUG_BUILD |
226 printf("[SDL_Quit] : CHECK_LEAKS\n"); fflush(stdout); | |
227 #endif | |
228 | |
0 | 229 /* Print the number of surfaces not freed */ |
230 if ( surfaces_allocated != 0 ) { | |
231 fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", | |
232 surfaces_allocated); | |
233 } | |
234 #endif | |
1190 | 235 #ifdef DEBUG_BUILD |
236 printf("[SDL_Quit] : SDL_UninstallParachute()\n"); fflush(stdout); | |
237 #endif | |
0 | 238 |
239 /* Uninstall any parachute signal handlers */ | |
240 SDL_UninstallParachute(); | |
397 | 241 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
242 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
397 | 243 pth_kill(); |
244 #endif | |
1190 | 245 #ifdef DEBUG_BUILD |
246 printf("[SDL_Quit] : Returning!\n"); fflush(stdout); | |
247 #endif | |
248 | |
0 | 249 } |
250 | |
251 /* Return the library version number */ | |
252 const SDL_version * SDL_Linked_Version(void) | |
253 { | |
254 return(&version); | |
255 } | |
256 | |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
257 #if defined(__OS2__) |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
258 /* Building for OS/2 */ |
1190 | 259 #ifdef __WATCOMC__ |
260 | |
261 #define INCL_DOSERRORS | |
262 #define INCL_DOSEXCEPTIONS | |
263 #include <os2.h> | |
264 | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
265 /* Exception handler to prevent the Audio thread hanging, making a zombie process! */ |
1190 | 266 ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec, |
267 PEXCEPTIONREGISTRATIONRECORD pERegRec, | |
268 PCONTEXTRECORD pCtxRec, | |
269 PVOID p) | |
270 { | |
271 if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND) | |
272 return XCPT_CONTINUE_SEARCH; | |
273 if (pERepRec->fHandlerFlags & EH_UNWINDING) | |
274 return XCPT_CONTINUE_SEARCH; | |
275 if (pERepRec->fHandlerFlags & EH_NESTED_CALL) | |
276 return XCPT_CONTINUE_SEARCH; | |
277 | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
278 /* Do cleanup at every fatal exception! */ |
1190 | 279 if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) && |
280 (pERepRec->ExceptionNum != XCPT_BREAKPOINT) && | |
281 (pERepRec->ExceptionNum != XCPT_SINGLE_STEP) | |
282 ) | |
283 { | |
284 if (SDL_initialized & SDL_INIT_AUDIO) | |
285 { | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
286 /* This removes the zombie audio thread in case of emergency. */ |
1190 | 287 #ifdef DEBUG_BUILD |
288 printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n"); | |
289 #endif | |
290 SDL_CloseAudio(); | |
291 } | |
292 } | |
293 return (XCPT_CONTINUE_SEARCH); | |
294 } | |
295 | |
296 | |
297 EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler}; | |
298 | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
299 /* The main DLL entry for DLL Initialization and Uninitialization: */ |
1190 | 300 unsigned _System LibMain(unsigned hmod, unsigned termination) |
301 { | |
302 if (termination) | |
303 { | |
304 #ifdef DEBUG_BUILD | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
305 /* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */ |
1190 | 306 #endif |
307 DosUnsetExceptionHandler(&SDL_Main_xcpthand); | |
308 return 1; | |
309 } else | |
310 { | |
311 #ifdef DEBUG_BUILD | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
312 /* Make stdout and stderr unbuffered! */ |
1190 | 313 setbuf(stdout, NULL); |
314 setbuf(stderr, NULL); | |
315 #endif | |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
316 /* Fire up exception handler */ |
1190 | 317 #ifdef DEBUG_BUILD |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
318 /* printf("[SDL DLL Initialization] : Setting exception handler\n"); */ |
1190 | 319 #endif |
1487
dc6b59e925a2
Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
1465
diff
changeset
|
320 /* Set exception handler */ |
1190 | 321 DosSetExceptionHandler(&SDL_Main_xcpthand); |
322 | |
323 return 1; | |
324 } | |
325 } | |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
326 #endif /* __WATCOMC__ */ |
1190 | 327 |
3975 | 328 #elif defined(__WIN32__) && !defined(__SYMBIAN32__) |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
329 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
330 #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
331 /* Need to include DllMain() on Watcom C for some reason.. */ |
1433
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
332 #define WIN32_LEAN_AND_MEAN |
bb6839704ed6
SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
333 #include <windows.h> |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
334 |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
335 BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule, |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
336 DWORD ul_reason_for_call, |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
337 LPVOID lpReserved ) |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
338 { |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
339 switch (ul_reason_for_call) { |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
340 case DLL_PROCESS_ATTACH: |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
341 case DLL_THREAD_ATTACH: |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
342 case DLL_THREAD_DETACH: |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
343 case DLL_PROCESS_DETACH: |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
344 break; |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
345 } |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
346 return TRUE; |
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
347 } |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
348 #endif /* building DLL with Watcom C */ |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
349 |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
350 #endif /* OS/2 elif __WIN32__ */ |