Merge with latest, official SDL code
authorDavidLudwig <dludwig@pobox.com>
Sun, 04 Nov 2012 09:46:59 -0500
changeset 83374a67a3cca43d
parent 8336 0b9aa42be7ae
parent 6644 eacc8b228cef
child 8339 aee5d42068ac
Merge with latest, official SDL code
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
include/SDL_config.h
include/SDL_stdinc.h
src/SDL_assert.c
src/SDL_log.c
src/file/SDL_rwops.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/uikit/SDL_uikitview.m
     1.1 --- a/Makefile.in	Sun Nov 04 09:02:58 2012 -0500
     1.2 +++ b/Makefile.in	Sun Nov 04 09:46:59 2012 -0500
     1.3 @@ -60,6 +60,7 @@
     1.4  	SDL_loadso.h \
     1.5  	SDL_log.h \
     1.6  	SDL_main.h \
     1.7 +	SDL_messagebox.h \
     1.8  	SDL_mouse.h \
     1.9  	SDL_mutex.h \
    1.10  	SDL_name.h \
     2.1 --- a/README.Platforms	Sun Nov 04 09:02:58 2012 -0500
     2.2 +++ b/README.Platforms	Sun Nov 04 09:46:59 2012 -0500
     2.3 @@ -11,13 +11,12 @@
     2.4  Mac OS X 10.4+
     2.5  Linux 2.6+
     2.6  iOS 3.1.3+
     2.7 -Android 1.6+
     2.8 +Android 2.1+
     2.9  
    2.10  Unofficially supported platforms
    2.11  ================================
    2.12  (code compiles, but not thoroughly tested)
    2.13  ================================
    2.14 -Windows CE
    2.15  FreeBSD
    2.16  NetBSD
    2.17  OpenBSD
     3.1 --- a/README.android	Sun Nov 04 09:02:58 2012 -0500
     3.2 +++ b/README.android	Sun Nov 04 09:46:59 2012 -0500
     3.3 @@ -39,18 +39,16 @@
     3.4  
     3.5  Instructions:
     3.6  1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project.
     3.7 -2. Move this SDL directory into the <project>/jni directory and then copy
     3.8 -SDL_config_android.h to SDL_config.h inside the include folder
     3.9 -3. Place your application source files in the <project>/jni/src directory
    3.10 -4. Edit <project>/jni/src/Android.mk to include your source files
    3.11 -5. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
    3.12 +2. Move or symlink this SDL directory into the <project>/jni directory
    3.13 +3. Edit <project>/jni/src/Android.mk to include your source files
    3.14 +4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
    3.15  
    3.16  If you want to use the Eclipse IDE, skip to the Eclipse section below.
    3.17  
    3.18 -6. Edit <project>/local.properties to point to the Android SDK directory
    3.19 -7. Run 'ant debug' in android/project. This compiles the .java and eventually 
    3.20 +5. Edit <project>/local.properties to point to the Android SDK directory
    3.21 +6. Run 'ant debug' in android/project. This compiles the .java and eventually 
    3.22  creates a .apk with the native code embedded
    3.23 -8. 'ant install' will push the apk to the device or emulator (if connected)
    3.24 +7. 'ant install' will push the apk to the device or emulator (if connected)
    3.25  
    3.26  Here's an explanation of the files in the Android project, so you can customize them:
    3.27  
    3.28 @@ -74,6 +72,58 @@
    3.29  
    3.30  
    3.31  ================================================================================
    3.32 + Customizing your application name
    3.33 +================================================================================
    3.34 +
    3.35 +To customize your application name, edit AndroidManifest.xml and replace
    3.36 +"org.libsdl.app" with an identifier for your product package.
    3.37 +
    3.38 +Then create a Java class extending SDLActivity and place it in a directory
    3.39 +under src matching your package, e.g.
    3.40 +	src/com/gamemaker/game/MyGame.java
    3.41 +
    3.42 +Here's an example of a minimal class file:
    3.43 +--- MyGame.java --------------------------
    3.44 +package com.gamemaker.game;
    3.45 +
    3.46 +import org.libsdl.app.SDLActivity; 
    3.47 +import android.os.*; 
    3.48 +
    3.49 +/* 
    3.50 + * A sample wrapper class that just calls SDLActivity 
    3.51 + */ 
    3.52 +
    3.53 +public class MyGame extends SDLActivity { 
    3.54 +    protected void onCreate(Bundle savedInstanceState) { 
    3.55 +	super.onCreate(savedInstanceState); 
    3.56 +    } 
    3.57 +   
    3.58 +    protected void onDestroy() { 
    3.59 +	super.onDestroy(); 
    3.60 +    } 
    3.61 +}
    3.62 +------------------------------------------
    3.63 +
    3.64 +Then replace "SDLActivity" in AndroidManifest.xml with the name of your
    3.65 +class, .e.g. "MyGame"
    3.66 +
    3.67 +================================================================================
    3.68 + Customizing your application icon
    3.69 +================================================================================
    3.70 +
    3.71 +Conceptually changing your icon is just replacing the icon.png files in the
    3.72 +drawable directories under the res directory.
    3.73 +
    3.74 +The easiest way to create a set of icons for your project is to remove all
    3.75 +the existing icon.png files, and then use the Eclipse IDE to create a dummy
    3.76 +project.  During the process of doing this Eclipse will prompt you to create
    3.77 +an icon. Then just copy the drawable directories it creates over to your
    3.78 +res directory.
    3.79 +
    3.80 +You may need to change the name of your icon in AndroidManifest.xml to match
    3.81 +the filename used by Eclipse.
    3.82 +
    3.83 +================================================================================
    3.84   Pause / Resume behaviour
    3.85  ================================================================================
    3.86  
    3.87 @@ -106,6 +156,16 @@
    3.88  detach it.
    3.89  
    3.90  ================================================================================
    3.91 + Using STL
    3.92 +================================================================================
    3.93 +
    3.94 +You can use STL in your project by creating an Application.mk file in the jni
    3.95 +folder and adding the following line:
    3.96 +APP_STL := stlport_static
    3.97 +
    3.98 +For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
    3.99 +
   3.100 +================================================================================
   3.101   Additional documentation
   3.102  ================================================================================
   3.103  
     4.1 --- a/VisualC/SDL/SDL_VS2008.vcproj	Sun Nov 04 09:02:58 2012 -0500
     4.2 +++ b/VisualC/SDL/SDL_VS2008.vcproj	Sun Nov 04 09:46:59 2012 -0500
     4.3 @@ -1217,6 +1217,14 @@
     4.4  			>
     4.5  		</File>
     4.6  		<File
     4.7 +			RelativePath="..\..\src\video\windows\SDL_windowsmessagebox.c"
     4.8 +			>
     4.9 +		</File>
    4.10 +		<File
    4.11 +			RelativePath="..\..\src\video\windows\SDL_windowsmessagebox.h"
    4.12 +			>
    4.13 +		</File>
    4.14 +		<File
    4.15  			RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
    4.16  			>
    4.17  		</File>
     5.1 --- a/VisualC/SDL/SDL_VS2010.vcxproj	Sun Nov 04 09:02:58 2012 -0500
     5.2 +++ b/VisualC/SDL/SDL_VS2010.vcxproj	Sun Nov 04 09:46:59 2012 -0500
     5.3 @@ -317,6 +317,7 @@
     5.4      <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
     5.5      <ClInclude Include="..\..\src\video\windows\SDL_windowsframebuffer.h" />
     5.6      <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
     5.7 +    <ClInclude Include="..\..\src\video\windows\SDL_windowsmessagebox.h" />
     5.8      <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
     5.9      <ClInclude Include="..\..\src\video\windows\SDL_windowsmouse.h" />
    5.10      <ClInclude Include="..\..\src\video\windows\SDL_windowsopengl.h" />
    5.11 @@ -432,6 +433,7 @@
    5.12      <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
    5.13      <ClCompile Include="..\..\src\video\windows\SDL_windowsframebuffer.c" />
    5.14      <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
    5.15 +    <ClCompile Include="..\..\src\video\windows\SDL_windowsmessagebox.c" />
    5.16      <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
    5.17      <ClCompile Include="..\..\src\video\windows\SDL_windowsmouse.c" />
    5.18      <ClCompile Include="..\..\src\video\windows\SDL_windowsopengl.c" />
     6.1 --- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Sun Nov 04 09:02:58 2012 -0500
     6.2 +++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Sun Nov 04 09:46:59 2012 -0500
     6.3 @@ -156,6 +156,9 @@
     6.4  		AA7558C91595D55500BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7558961595D55500BBD41B /* SDL_video.h */; };
     6.5  		AA7558CA1595D55500BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7558971595D55500BBD41B /* SDL.h */; };
     6.6  		AA9781C91576A7FA00472542 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD6526630DE8FCCB002AD96B /* libSDL2.a */; };
     6.7 +		AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9501637C6E5000DF050 /* SDL_messagebox.h */; };
     6.8 +		AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */; };
     6.9 +		AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */; };
    6.10  		FD3F4A760DEA620800C5B771 /* SDL_getenv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A700DEA620800C5B771 /* SDL_getenv.c */; };
    6.11  		FD3F4A770DEA620800C5B771 /* SDL_iconv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A710DEA620800C5B771 /* SDL_iconv.c */; };
    6.12  		FD3F4A780DEA620800C5B771 /* SDL_malloc.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A720DEA620800C5B771 /* SDL_malloc.c */; };
    6.13 @@ -410,6 +413,9 @@
    6.14  		AA7558951595D55500BBD41B /* SDL_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_version.h; sourceTree = "<group>"; };
    6.15  		AA7558961595D55500BBD41B /* SDL_video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_video.h; sourceTree = "<group>"; };
    6.16  		AA7558971595D55500BBD41B /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL.h; sourceTree = "<group>"; };
    6.17 +		AA9FF9501637C6E5000DF050 /* SDL_messagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_messagebox.h; sourceTree = "<group>"; };
    6.18 +		AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmessagebox.h; sourceTree = "<group>"; };
    6.19 +		AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmessagebox.m; sourceTree = "<group>"; };
    6.20  		FD0BBFEF0E3933DD00D833B1 /* SDL_uikitview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitview.h; sourceTree = "<group>"; };
    6.21  		FD3F4A700DEA620800C5B771 /* SDL_getenv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_getenv.c; sourceTree = "<group>"; };
    6.22  		FD3F4A710DEA620800C5B771 /* SDL_iconv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_iconv.c; sourceTree = "<group>"; };
    6.23 @@ -853,6 +859,8 @@
    6.24  				FD689FCC0E26E9D400F90B21 /* SDL_uikitappdelegate.m */,
    6.25  				FD689F0C0E26E5D900F90B21 /* SDL_uikitevents.h */,
    6.26  				FD689F0D0E26E5D900F90B21 /* SDL_uikitevents.m */,
    6.27 +				AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */,
    6.28 +				AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */,
    6.29  				AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */,
    6.30  				AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */,
    6.31  				FD689F0E0E26E5D900F90B21 /* SDL_uikitopengles.h */,
    6.32 @@ -894,13 +902,14 @@
    6.33  			children = (
    6.34  				AA7558651595D55500BBD41B /* begin_code.h */,
    6.35  				AA7558661595D55500BBD41B /* close_code.h */,
    6.36 +				AA7558971595D55500BBD41B /* SDL.h */,
    6.37  				AA7558671595D55500BBD41B /* SDL_assert.h */,
    6.38  				AA7558681595D55500BBD41B /* SDL_atomic.h */,
    6.39  				AA7558691595D55500BBD41B /* SDL_audio.h */,
    6.40  				AA75586A1595D55500BBD41B /* SDL_blendmode.h */,
    6.41  				AA75586B1595D55500BBD41B /* SDL_clipboard.h */,
    6.42 +				AA75586D1595D55500BBD41B /* SDL_config.h */,
    6.43  				AA75586C1595D55500BBD41B /* SDL_config_iphoneos.h */,
    6.44 -				AA75586D1595D55500BBD41B /* SDL_config.h */,
    6.45  				AA75586E1595D55500BBD41B /* SDL_copying.h */,
    6.46  				AA75586F1595D55500BBD41B /* SDL_cpuinfo.h */,
    6.47  				AA7558701595D55500BBD41B /* SDL_endian.h */,
    6.48 @@ -916,6 +925,7 @@
    6.49  				AA75587A1595D55500BBD41B /* SDL_loadso.h */,
    6.50  				AA75587B1595D55500BBD41B /* SDL_log.h */,
    6.51  				AA75587C1595D55500BBD41B /* SDL_main.h */,
    6.52 +				AA9FF9501637C6E5000DF050 /* SDL_messagebox.h */,
    6.53  				AA75587D1595D55500BBD41B /* SDL_mouse.h */,
    6.54  				AA75587E1595D55500BBD41B /* SDL_mutex.h */,
    6.55  				AA75587F1595D55500BBD41B /* SDL_name.h */,
    6.56 @@ -942,7 +952,6 @@
    6.57  				AA7558941595D55500BBD41B /* SDL_types.h */,
    6.58  				AA7558951595D55500BBD41B /* SDL_version.h */,
    6.59  				AA7558961595D55500BBD41B /* SDL_video.h */,
    6.60 -				AA7558971595D55500BBD41B /* SDL.h */,
    6.61  			);
    6.62  			name = "Public Headers";
    6.63  			path = ../../include;
    6.64 @@ -1249,6 +1258,8 @@
    6.65  				AA7558CA1595D55500BBD41B /* SDL.h in Headers */,
    6.66  				AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */,
    6.67  				AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
    6.68 +				AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
    6.69 +				AABCC3941640643D00AB8930 /* SDL_uikitmessagebox.h in Headers */,
    6.70  			);
    6.71  			runOnlyForDeploymentPostprocessing = 0;
    6.72  		};
    6.73 @@ -1467,6 +1478,7 @@
    6.74  				AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */,
    6.75  				AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */,
    6.76  				AA704DD7162AA90A0076D1C1 /* SDL_dropevents.c in Sources */,
    6.77 +				AABCC3951640643D00AB8930 /* SDL_uikitmessagebox.m in Sources */,
    6.78  			);
    6.79  			runOnlyForDeploymentPostprocessing = 0;
    6.80  		};
     7.1 --- a/Xcode/SDL/Info-Framework.plist	Sun Nov 04 09:02:58 2012 -0500
     7.2 +++ b/Xcode/SDL/Info-Framework.plist	Sun Nov 04 09:46:59 2012 -0500
     7.3 @@ -4,14 +4,12 @@
     7.4  <dict>
     7.5  	<key>CFBundleDevelopmentRegion</key>
     7.6  	<string>English</string>
     7.7 -	<key>CFBundleExecutable</key>
     7.8 -	<string>SDL</string>
     7.9  	<key>CFBundleGetInfoString</key>
    7.10  	<string>http://www.libsdl.org</string>
    7.11  	<key>CFBundleIconFile</key>
    7.12  	<string></string>
    7.13  	<key>CFBundleIdentifier</key>
    7.14 -	<string>SDL</string>
    7.15 +	<string>org.libsdl.SDL2</string>
    7.16  	<key>CFBundleInfoDictionaryVersion</key>
    7.17  	<string>6.0</string>
    7.18  	<key>CFBundleName</key>
    7.19 @@ -19,10 +17,10 @@
    7.20  	<key>CFBundlePackageType</key>
    7.21  	<string>FMWK</string>
    7.22  	<key>CFBundleShortVersionString</key>
    7.23 -	<string>1.3.0</string>
    7.24 +	<string>2.0.0</string>
    7.25  	<key>CFBundleSignature</key>
    7.26  	<string>SDLX</string>
    7.27  	<key>CFBundleVersion</key>
    7.28 -	<string>1.3.0</string>
    7.29 +	<string>2.0.0</string>
    7.30  </dict>
    7.31  </plist>
     8.1 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Nov 04 09:02:58 2012 -0500
     8.2 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Nov 04 09:46:59 2012 -0500
     8.3 @@ -539,6 +539,13 @@
     8.4  		AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F81595D4D800BBD41B /* SDL_video.h */; };
     8.5  		AA75585E1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; };
     8.6  		AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; };
     8.7 +		AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; };
     8.8 +		AA9E4094163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; };
     8.9 +		AA9FF95A1637CBF9000DF050 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; };
    8.10 +		AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; };
    8.11 +		AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */; };
    8.12 +		AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
    8.13 +		AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */; };
    8.14  /* End PBXBuildFile section */
    8.15  
    8.16  /* Begin PBXContainerItemProxy section */
    8.17 @@ -880,6 +887,10 @@
    8.18  		AA7557F71595D4D800BBD41B /* SDL_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_version.h; sourceTree = "<group>"; };
    8.19  		AA7557F81595D4D800BBD41B /* SDL_video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_video.h; sourceTree = "<group>"; };
    8.20  		AA7557F91595D4D800BBD41B /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL.h; sourceTree = "<group>"; };
    8.21 +		AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11messagebox.c; sourceTree = "<group>"; };
    8.22 +		AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_messagebox.h; sourceTree = "<group>"; };
    8.23 +		AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamessagebox.h; sourceTree = "<group>"; };
    8.24 +		AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamessagebox.m; sourceTree = "<group>"; };
    8.25  		BECDF66B0761BA81005FE872 /* Info-Framework.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Framework.plist"; sourceTree = "<group>"; };
    8.26  		BECDF66C0761BA81005FE872 /* SDL2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDL2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    8.27  		BECDF6B30761BA81005FE872 /* libSDL2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.a; sourceTree = BUILT_PRODUCTS_DIR; };
    8.28 @@ -1053,13 +1064,14 @@
    8.29  			children = (
    8.30  				AA7557C71595D4D800BBD41B /* begin_code.h */,
    8.31  				AA7557C81595D4D800BBD41B /* close_code.h */,
    8.32 +				AA7557F91595D4D800BBD41B /* SDL.h */,
    8.33  				AA7557C91595D4D800BBD41B /* SDL_assert.h */,
    8.34  				AA7557CA1595D4D800BBD41B /* SDL_atomic.h */,
    8.35  				AA7557CB1595D4D800BBD41B /* SDL_audio.h */,
    8.36  				AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */,
    8.37  				AA7557CD1595D4D800BBD41B /* SDL_clipboard.h */,
    8.38 +				AA7557CF1595D4D800BBD41B /* SDL_config.h */,
    8.39  				AA7557CE1595D4D800BBD41B /* SDL_config_macosx.h */,
    8.40 -				AA7557CF1595D4D800BBD41B /* SDL_config.h */,
    8.41  				AA7557D01595D4D800BBD41B /* SDL_copying.h */,
    8.42  				AA7557D11595D4D800BBD41B /* SDL_cpuinfo.h */,
    8.43  				AA7557D21595D4D800BBD41B /* SDL_endian.h */,
    8.44 @@ -1075,6 +1087,7 @@
    8.45  				AA7557DC1595D4D800BBD41B /* SDL_loadso.h */,
    8.46  				AA7557DD1595D4D800BBD41B /* SDL_log.h */,
    8.47  				AA7557DE1595D4D800BBD41B /* SDL_main.h */,
    8.48 +				AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */,
    8.49  				AA7557DF1595D4D800BBD41B /* SDL_mouse.h */,
    8.50  				AA7557E01595D4D800BBD41B /* SDL_mutex.h */,
    8.51  				AA7557E11595D4D800BBD41B /* SDL_name.h */,
    8.52 @@ -1101,7 +1114,6 @@
    8.53  				AA7557F61595D4D800BBD41B /* SDL_types.h */,
    8.54  				AA7557F71595D4D800BBD41B /* SDL_version.h */,
    8.55  				AA7557F81595D4D800BBD41B /* SDL_video.h */,
    8.56 -				AA7557F91595D4D800BBD41B /* SDL.h */,
    8.57  			);
    8.58  			name = "Public Headers";
    8.59  			path = ../../include;
    8.60 @@ -1467,6 +1479,8 @@
    8.61  				04BDFEC512E6671800899322 /* SDL_cocoaevents.m */,
    8.62  				04BDFEC612E6671800899322 /* SDL_cocoakeyboard.h */,
    8.63  				04BDFEC712E6671800899322 /* SDL_cocoakeyboard.m */,
    8.64 +				AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */,
    8.65 +				AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */,
    8.66  				04BDFEC812E6671800899322 /* SDL_cocoamodes.h */,
    8.67  				04BDFEC912E6671800899322 /* SDL_cocoamodes.m */,
    8.68  				04BDFECA12E6671800899322 /* SDL_cocoamouse.h */,
    8.69 @@ -1511,6 +1525,7 @@
    8.70  				0442EC5912FE1C60004C9285 /* SDL_x11framebuffer.h */,
    8.71  				04BDFFC212E6671800899322 /* SDL_x11keyboard.c */,
    8.72  				04BDFFC312E6671800899322 /* SDL_x11keyboard.h */,
    8.73 +				AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */,
    8.74  				04BDFFC412E6671800899322 /* SDL_x11modes.c */,
    8.75  				04BDFFC512E6671800899322 /* SDL_x11modes.h */,
    8.76  				04BDFFC612E6671800899322 /* SDL_x11mouse.c */,
    8.77 @@ -1670,6 +1685,7 @@
    8.78  				AA7558241595D4D800BBD41B /* SDL_loadso.h in Headers */,
    8.79  				AA7558261595D4D800BBD41B /* SDL_log.h in Headers */,
    8.80  				AA7558281595D4D800BBD41B /* SDL_main.h in Headers */,
    8.81 +				AA9FF95A1637CBF9000DF050 /* SDL_messagebox.h in Headers */,
    8.82  				AA75582A1595D4D800BBD41B /* SDL_mouse.h in Headers */,
    8.83  				AA75582C1595D4D800BBD41B /* SDL_mutex.h in Headers */,
    8.84  				AA75582E1595D4D800BBD41B /* SDL_name.h in Headers */,
    8.85 @@ -1782,6 +1798,7 @@
    8.86  				566CDE8F148F0AC200C5A9BB /* SDL_dropevents_c.h in Headers */,
    8.87  				AA628ACC159367B7005138DD /* SDL_rotate.h in Headers */,
    8.88  				AA628AD3159367F2005138DD /* SDL_x11xinput2.h in Headers */,
    8.89 +				AABCC38D164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */,
    8.90  			);
    8.91  			runOnlyForDeploymentPostprocessing = 0;
    8.92  		};
    8.93 @@ -1924,6 +1941,7 @@
    8.94  				AA75585B1595D4D800BBD41B /* SDL_version.h in Headers */,
    8.95  				AA75585D1595D4D800BBD41B /* SDL_video.h in Headers */,
    8.96  				AA75585F1595D4D800BBD41B /* SDL.h in Headers */,
    8.97 +				AABCC38E164063D200AB8930 /* SDL_cocoamessagebox.h in Headers */,
    8.98  			);
    8.99  			runOnlyForDeploymentPostprocessing = 0;
   8.100  		};
   8.101 @@ -2253,6 +2271,8 @@
   8.102  				566CDE90148F0AC200C5A9BB /* SDL_dropevents.c in Sources */,
   8.103  				AA628ACA159367B7005138DD /* SDL_rotate.c in Sources */,
   8.104  				AA628AD1159367F2005138DD /* SDL_x11xinput2.c in Sources */,
   8.105 +				AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */,
   8.106 +				AABCC38F164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */,
   8.107  			);
   8.108  			runOnlyForDeploymentPostprocessing = 0;
   8.109  		};
   8.110 @@ -2366,6 +2386,8 @@
   8.111  				043567401303160F00BA5428 /* SDL_shaders_gl.c in Sources */,
   8.112  				AA628ACB159367B7005138DD /* SDL_rotate.c in Sources */,
   8.113  				AA628AD2159367F2005138DD /* SDL_x11xinput2.c in Sources */,
   8.114 +				AA9E4094163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */,
   8.115 +				AABCC390164063D200AB8930 /* SDL_cocoamessagebox.m in Sources */,
   8.116  			);
   8.117  			runOnlyForDeploymentPostprocessing = 0;
   8.118  		};
   8.119 @@ -2433,7 +2455,7 @@
   8.120  				FRAMEWORK_VERSION = A;
   8.121  				HEADER_SEARCH_PATHS = /usr/X11R6/include;
   8.122  				INFOPLIST_FILE = "Info-Framework.plist";
   8.123 -				INSTALL_PATH = "@rpath";
   8.124 +				INSTALL_PATH = "@executable_path/../Frameworks";
   8.125  				OTHER_LDFLAGS = "-liconv";
   8.126  				PRODUCT_NAME = SDL2;
   8.127  				WRAPPER_EXTENSION = framework;
   8.128 @@ -2453,6 +2475,7 @@
   8.129  				GCC_SYMBOLS_PRIVATE_EXTERN = YES;
   8.130  				HEADER_SEARCH_PATHS = /usr/X11R6/include;
   8.131  				PRODUCT_NAME = SDL2;
   8.132 +				SKIP_INSTALL = YES;
   8.133  			};
   8.134  			name = Release;
   8.135  		};
   8.136 @@ -2493,7 +2516,7 @@
   8.137  				FRAMEWORK_VERSION = A;
   8.138  				HEADER_SEARCH_PATHS = /usr/X11R6/include;
   8.139  				INFOPLIST_FILE = "Info-Framework.plist";
   8.140 -				INSTALL_PATH = "@rpath";
   8.141 +				INSTALL_PATH = "@executable_path/../Frameworks";
   8.142  				OTHER_LDFLAGS = "-liconv";
   8.143  				PRODUCT_NAME = SDL2;
   8.144  				WRAPPER_EXTENSION = framework;
   8.145 @@ -2513,6 +2536,7 @@
   8.146  				GCC_SYMBOLS_PRIVATE_EXTERN = YES;
   8.147  				HEADER_SEARCH_PATHS = /usr/X11R6/include;
   8.148  				PRODUCT_NAME = SDL2;
   8.149 +				SKIP_INSTALL = YES;
   8.150  			};
   8.151  			name = Debug;
   8.152  		};
     9.1 --- a/acinclude/libtool.m4	Sun Nov 04 09:02:58 2012 -0500
     9.2 +++ b/acinclude/libtool.m4	Sun Nov 04 09:46:59 2012 -0500
     9.3 @@ -2364,13 +2364,15 @@
     9.4      case $host_os in
     9.5      cygwin*)
     9.6        # Cygwin DLLs use 'cyg' prefix rather than 'lib'
     9.7 -      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
     9.8 +      #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
     9.9 +      soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
    9.10  m4_if([$1], [],[
    9.11        sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
    9.12        ;;
    9.13      mingw* | cegcc*)
    9.14        # MinGW DLLs use traditional 'lib' prefix
    9.15 -      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
    9.16 +      #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
    9.17 +      soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
    9.18        ;;
    9.19      pw32*)
    9.20        # pw32 DLLs use 'pw' prefix rather than 'lib'
    10.1 --- a/aclocal.m4	Sun Nov 04 09:02:58 2012 -0500
    10.2 +++ b/aclocal.m4	Sun Nov 04 09:46:59 2012 -0500
    10.3 @@ -3061,13 +3061,15 @@
    10.4      case $host_os in
    10.5      cygwin*)
    10.6        # Cygwin DLLs use 'cyg' prefix rather than 'lib'
    10.7 -      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
    10.8 +      #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
    10.9 +      soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
   10.10  m4_if([$1], [],[
   10.11        sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
   10.12        ;;
   10.13      mingw* | cegcc*)
   10.14        # MinGW DLLs use traditional 'lib' prefix
   10.15 -      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
   10.16 +      #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
   10.17 +      soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
   10.18        ;;
   10.19      pw32*)
   10.20        # pw32 DLLs use 'pw' prefix rather than 'lib'
    11.1 --- a/android-project/AndroidManifest.xml	Sun Nov 04 09:02:58 2012 -0500
    11.2 +++ b/android-project/AndroidManifest.xml	Sun Nov 04 09:46:59 2012 -0500
    11.3 @@ -1,12 +1,25 @@
    11.4  <?xml version="1.0" encoding="utf-8"?>
    11.5  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    11.6 +    <!-- Replace org.libsdl.app with the identifier of your game, e.g.
    11.7 +         com.gamemaker.game
    11.8 +     -->
    11.9        package="org.libsdl.app"
   11.10        android:versionCode="1"
   11.11 -      android:versionName="1.0">
   11.12 +      android:versionName="1.0"
   11.13 +      android:installLocation="auto">
   11.14  
   11.15 -    <uses-sdk android:minSdkVersion="5" />
   11.16 +    <!-- Create a Java class extending SDLActivity and place it in a
   11.17 +         directory under src matching the package, e.g.
   11.18 +         	src/com/gamemaker/game/MyGame.java
   11.19  
   11.20 -    <application android:label="@string/app_name" android:icon="@drawable/icon">
   11.21 +         then replace "SDLActivity" with the name of your class (e.g. "MyGame")
   11.22 +         in the XML below.
   11.23 +
   11.24 +         An example Java class can be found in README.android
   11.25 +    -->
   11.26 +    <application android:label="@string/app_name"
   11.27 +                 android:icon="@drawable/icon"
   11.28 +	         android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
   11.29          <activity android:name="SDLActivity"
   11.30                    android:label="@string/app_name">
   11.31              <intent-filter>
   11.32 @@ -15,4 +28,13 @@
   11.33              </intent-filter>
   11.34          </activity>
   11.35      </application>
   11.36 +
   11.37 +    <!-- Android 2.1 -->
   11.38 +    <uses-sdk android:minSdkVersion="10" /> 
   11.39 +
   11.40 +    <!-- OpenGL ES 2.0 -->
   11.41 +    <uses-feature android:glEsVersion="0x00020000" /> 
   11.42 +
   11.43 +    <!-- Allow writing to external storage -->
   11.44 +    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
   11.45  </manifest> 
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/android-project/ant.properties	Sun Nov 04 09:46:59 2012 -0500
    12.3 @@ -0,0 +1,17 @@
    12.4 +# This file is used to override default values used by the Ant build system.
    12.5 +#
    12.6 +# This file must be checked into Version Control Systems, as it is
    12.7 +# integral to the build system of your project.
    12.8 +
    12.9 +# This file is only used by the Ant script.
   12.10 +
   12.11 +# You can use this to override default values such as
   12.12 +#  'source.dir' for the location of your java source folder and
   12.13 +#  'out.dir' for the location of your output folder.
   12.14 +
   12.15 +# You can also use it define how the release builds are signed by declaring
   12.16 +# the following properties:
   12.17 +#  'key.store' for the location of your keystore and
   12.18 +#  'key.alias' for the name of the key to use.
   12.19 +# The password will be asked during the build when you use the 'release' target.
   12.20 +
    13.1 --- a/android-project/build.xml	Sun Nov 04 09:02:58 2012 -0500
    13.2 +++ b/android-project/build.xml	Sun Nov 04 09:46:59 2012 -0500
    13.3 @@ -1,67 +1,93 @@
    13.4  <?xml version="1.0" encoding="UTF-8"?>
    13.5 -<project name="SDLApp" default="help">
    13.6 +<!-- This should be changed to the name of your project -->
    13.7 +<project name="SDLActivity" default="help">
    13.8  
    13.9      <!-- The local.properties file is created and updated by the 'android' tool.
   13.10 -         It contains the path to the SDK. It should *NOT* be checked in in Version
   13.11 -         Control Systems. -->
   13.12 +         It contains the path to the SDK. It should *NOT* be checked into
   13.13 +         Version Control Systems. -->
   13.14      <property file="local.properties" />
   13.15  
   13.16 -    <!-- The build.properties file can be created by you and is never touched
   13.17 -         by the 'android' tool. This is the place to change some of the default property values
   13.18 -         used by the Ant rules.
   13.19 +    <!-- The ant.properties file can be created by you. It is only edited by the
   13.20 +         'android' tool to add properties to it.
   13.21 +         This is the place to change some Ant specific build properties.
   13.22           Here are some properties you may want to change/update:
   13.23  
   13.24 -         application.package
   13.25 -             the name of your application package as defined in the manifest. Used by the
   13.26 -             'uninstall' rule.
   13.27           source.dir
   13.28 -             the name of the source directory. Default is 'src'.
   13.29 +             The name of the source directory. Default is 'src'.
   13.30           out.dir
   13.31 -             the name of the output directory. Default is 'bin'.
   13.32 +             The name of the output directory. Default is 'bin'.
   13.33  
   13.34 -         Properties related to the SDK location or the project target should be updated
   13.35 -          using the 'android' tool with the 'update' action.
   13.36 +         For other overridable properties, look at the beginning of the rules
   13.37 +         files in the SDK, at tools/ant/build.xml
   13.38  
   13.39 -         This file is an integral part of the build system for your application and
   13.40 -         should be checked in in Version Control Systems.
   13.41 +         Properties related to the SDK location or the project target should
   13.42 +         be updated using the 'android' tool with the 'update' action.
   13.43 +
   13.44 +         This file is an integral part of the build system for your
   13.45 +         application and should be checked into Version Control Systems.
   13.46  
   13.47           -->
   13.48 -    <property file="build.properties" />
   13.49 +    <property file="ant.properties" />
   13.50  
   13.51 -    <!-- The default.properties file is created and updated by the 'android' tool, as well
   13.52 -         as ADT.
   13.53 -         This file is an integral part of the build system for your application and
   13.54 -         should be checked in in Version Control Systems. -->
   13.55 -    <property file="default.properties" />
   13.56 +    <!-- if sdk.dir was not set from one of the property file, then
   13.57 +         get it from the ANDROID_HOME env var.
   13.58 +         This must be done before we load project.properties since
   13.59 +         the proguard config can use sdk.dir -->
   13.60 +    <property environment="env" />
   13.61 +    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
   13.62 +        <isset property="env.ANDROID_HOME" />
   13.63 +    </condition>
   13.64  
   13.65 -    <!-- Custom Android task to deal with the project target, and import the proper rules.
   13.66 -         This requires ant 1.6.0 or above. -->
   13.67 -    <path id="android.antlibs">
   13.68 -        <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
   13.69 -        <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
   13.70 -        <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
   13.71 -        <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
   13.72 -        <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
   13.73 -    </path>
   13.74 +    <!-- The project.properties file is created and updated by the 'android'
   13.75 +         tool, as well as ADT.
   13.76  
   13.77 -    <taskdef name="setup"
   13.78 -        classname="com.android.ant.SetupTask"
   13.79 -        classpathref="android.antlibs" />
   13.80 +         This contains project specific properties such as project target, and library
   13.81 +         dependencies. Lower level build properties are stored in ant.properties
   13.82 +         (or in .classpath for Eclipse projects).
   13.83  
   13.84 -    <!-- Execute the Android Setup task that will setup some properties specific to the target,
   13.85 -         and import the build rules files.
   13.86 +         This file is an integral part of the build system for your
   13.87 +         application and should be checked into Version Control Systems. -->
   13.88 +    <loadproperties srcFile="project.properties" />
   13.89  
   13.90 -         The rules file is imported from
   13.91 -            <SDK>/platforms/<target_platform>/templates/android_rules.xml
   13.92 +    <!-- quick check on sdk.dir -->
   13.93 +    <fail
   13.94 +            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
   13.95 +            unless="sdk.dir"
   13.96 +    />
   13.97  
   13.98 -         To customize some build steps for your project:
   13.99 -         - copy the content of the main node <project> from android_rules.xml
  13.100 -         - paste it in this build.xml below the <setup /> task.
  13.101 -         - disable the import by changing the setup task below to <setup import="false" />
  13.102 +    <!--
  13.103 +        Import per project custom build rules if present at the root of the project.
  13.104 +        This is the place to put custom intermediary targets such as:
  13.105 +            -pre-build
  13.106 +            -pre-compile
  13.107 +            -post-compile (This is typically used for code obfuscation.
  13.108 +                           Compiled code location: ${out.classes.absolute.dir}
  13.109 +                           If this is not done in place, override ${out.dex.input.absolute.dir})
  13.110 +            -post-package
  13.111 +            -post-build
  13.112 +            -pre-clean
  13.113 +    -->
  13.114 +    <import file="custom_rules.xml" optional="true" />
  13.115  
  13.116 -         This will ensure that the properties are setup correctly but that your customized
  13.117 -         build steps are used.
  13.118 +    <!-- Import the actual build file.
  13.119 +
  13.120 +         To customize existing targets, there are two options:
  13.121 +         - Customize only one target:
  13.122 +             - copy/paste the target into this file, *before* the
  13.123 +               <import> task.
  13.124 +             - customize it to your needs.
  13.125 +         - Customize the whole content of build.xml
  13.126 +             - copy/paste the content of the rules files (minus the top node)
  13.127 +               into this file, replacing the <import> task.
  13.128 +             - customize to your needs.
  13.129 +
  13.130 +         ***********************
  13.131 +         ****** IMPORTANT ******
  13.132 +         ***********************
  13.133 +         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
  13.134 +         in order to avoid having your file be overridden by tools such as "android update project"
  13.135      -->
  13.136 -    <setup />
  13.137 +    <!-- version-tag: 1 -->
  13.138 +    <import file="${sdk.dir}/tools/ant/build.xml" />
  13.139  
  13.140  </project>
    14.1 --- a/android-project/default.properties	Sun Nov 04 09:02:58 2012 -0500
    14.2 +++ b/android-project/default.properties	Sun Nov 04 09:46:59 2012 -0500
    14.3 @@ -8,4 +8,4 @@
    14.4  # project structure.
    14.5  
    14.6  # Project target.
    14.7 -target=android-5
    14.8 +target=android-7
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/android-project/jni/Application.mk	Sun Nov 04 09:46:59 2012 -0500
    15.3 @@ -0,0 +1,4 @@
    15.4 +
    15.5 +# Uncomment this if you're using STL in your project
    15.6 +# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
    15.7 +# APP_STL := stlport_static 
    16.1 --- a/android-project/local.properties	Sun Nov 04 09:02:58 2012 -0500
    16.2 +++ b/android-project/local.properties	Sun Nov 04 09:46:59 2012 -0500
    16.3 @@ -7,4 +7,4 @@
    16.4  # location of the SDK. This is only used by Ant
    16.5  # For customization when using a Version Control System, please read the
    16.6  # header note.
    16.7 -sdk.dir=/Users/hercules/eclipse/android-sdk-mac_86
    16.8 +sdk.dir=/Users/slouken/android-sdk-macosx
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/android-project/proguard-project.txt	Sun Nov 04 09:46:59 2012 -0500
    17.3 @@ -0,0 +1,20 @@
    17.4 +# To enable ProGuard in your project, edit project.properties
    17.5 +# to define the proguard.config property as described in that file.
    17.6 +#
    17.7 +# Add project specific ProGuard rules here.
    17.8 +# By default, the flags in this file are appended to flags specified
    17.9 +# in ${sdk.dir}/tools/proguard/proguard-android.txt
   17.10 +# You can edit the include path and order by changing the ProGuard
   17.11 +# include property in project.properties.
   17.12 +#
   17.13 +# For more details, see
   17.14 +#   http://developer.android.com/guide/developing/tools/proguard.html
   17.15 +
   17.16 +# Add any project specific keep options here:
   17.17 +
   17.18 +# If your project uses WebView with JS, uncomment the following
   17.19 +# and specify the fully qualified class name to the JavaScript interface
   17.20 +# class:
   17.21 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
   17.22 +#   public *;
   17.23 +#}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/android-project/project.properties	Sun Nov 04 09:46:59 2012 -0500
    18.3 @@ -0,0 +1,14 @@
    18.4 +# This file is automatically generated by Android Tools.
    18.5 +# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
    18.6 +#
    18.7 +# This file must be checked in Version Control Systems.
    18.8 +#
    18.9 +# To customize properties used by the Ant build system edit
   18.10 +# "ant.properties", and override values to adapt the script to your
   18.11 +# project structure.
   18.12 +#
   18.13 +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
   18.14 +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
   18.15 +
   18.16 +# Project target.
   18.17 +target=android-10
    19.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 09:02:58 2012 -0500
    19.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 09:46:59 2012 -0500
    19.3 @@ -734,7 +734,7 @@
    19.4          ic = new SDLInputConnection(this, true);
    19.5  
    19.6          outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
    19.7 -                | EditorInfo.IME_FLAG_NO_FULLSCREEN;
    19.8 +                | 33554432 /* API 11: EditorInfo.IME_FLAG_NO_FULLSCREEN */;
    19.9  
   19.10          return ic;
   19.11      }
    20.1 --- a/configure	Sun Nov 04 09:02:58 2012 -0500
    20.2 +++ b/configure	Sun Nov 04 09:46:59 2012 -0500
    20.3 @@ -10244,13 +10244,15 @@
    20.4      case $host_os in
    20.5      cygwin*)
    20.6        # Cygwin DLLs use 'cyg' prefix rather than 'lib'
    20.7 -      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
    20.8 +      #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
    20.9 +      soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
   20.10  
   20.11        sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
   20.12        ;;
   20.13      mingw* | cegcc*)
   20.14        # MinGW DLLs use traditional 'lib' prefix
   20.15 -      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
   20.16 +      #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
   20.17 +      soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
   20.18        ;;
   20.19      pw32*)
   20.20        # pw32 DLLs use 'pw' prefix rather than 'lib'
   20.21 @@ -14919,12 +14921,14 @@
   20.22      case $host_os in
   20.23      cygwin*)
   20.24        # Cygwin DLLs use 'cyg' prefix rather than 'lib'
   20.25 -      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
   20.26 +      #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
   20.27 +      soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}'
   20.28  
   20.29        ;;
   20.30      mingw* | cegcc*)
   20.31        # MinGW DLLs use traditional 'lib' prefix
   20.32 -      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
   20.33 +      #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
   20.34 +      soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}'
   20.35        ;;
   20.36      pw32*)
   20.37        # pw32 DLLs use 'pw' prefix rather than 'lib'
   20.38 @@ -16684,7 +16688,7 @@
   20.39  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   20.40  fi
   20.41  
   20.42 -    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep sysconf sysctlbyname
   20.43 +    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname
   20.44  do :
   20.45    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   20.46  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   20.47 @@ -16930,6 +16934,7 @@
   20.48  SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   20.49  SOURCES="$SOURCES $srcdir/src/events/*.c"
   20.50  SOURCES="$SOURCES $srcdir/src/file/*.c"
   20.51 +SOURCES="$SOURCES $srcdir/src/libm/*.c"
   20.52  SOURCES="$SOURCES $srcdir/src/render/*.c"
   20.53  SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   20.54  SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
    21.1 --- a/configure.in	Sun Nov 04 09:02:58 2012 -0500
    21.2 +++ b/configure.in	Sun Nov 04 09:46:59 2012 -0500
    21.3 @@ -237,7 +237,7 @@
    21.4          AC_DEFINE(HAVE_MPROTECT, 1, [ ])
    21.5          ]),
    21.6      )
    21.7 -    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep sysconf sysctlbyname)
    21.8 +    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname)
    21.9  
   21.10      AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
   21.11      AC_CHECK_FUNCS(atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
   21.12 @@ -297,6 +297,7 @@
   21.13  SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   21.14  SOURCES="$SOURCES $srcdir/src/events/*.c"
   21.15  SOURCES="$SOURCES $srcdir/src/file/*.c"
   21.16 +SOURCES="$SOURCES $srcdir/src/libm/*.c"
   21.17  SOURCES="$SOURCES $srcdir/src/render/*.c"
   21.18  SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   21.19  SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
    22.1 --- a/include/SDL.h	Sun Nov 04 09:02:58 2012 -0500
    22.2 +++ b/include/SDL.h	Sun Nov 04 09:46:59 2012 -0500
    22.3 @@ -82,6 +82,7 @@
    22.4  #include "SDL_hints.h"
    22.5  #include "SDL_loadso.h"
    22.6  #include "SDL_log.h"
    22.7 +#include "SDL_messagebox.h"
    22.8  #include "SDL_mutex.h"
    22.9  #include "SDL_power.h"
   22.10  #include "SDL_render.h"
    23.1 --- a/include/SDL_config.h	Sun Nov 04 09:02:58 2012 -0500
    23.2 +++ b/include/SDL_config.h	Sun Nov 04 09:46:59 2012 -0500
    23.3 @@ -1,6 +1,6 @@
    23.4  /*
    23.5    Simple DirectMedia Layer
    23.6 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    23.7 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    23.8  
    23.9    This software is provided 'as-is', without any express or implied
   23.10    warranty.  In no event will the authors be held liable for any damages
    24.1 --- a/include/SDL_config.h.in	Sun Nov 04 09:02:58 2012 -0500
    24.2 +++ b/include/SDL_config.h.in	Sun Nov 04 09:46:59 2012 -0500
    24.3 @@ -139,6 +139,8 @@
    24.4  #undef HAVE_SIN
    24.5  #undef HAVE_SINF
    24.6  #undef HAVE_SQRT
    24.7 +#undef HAVE_FSEEKO
    24.8 +#undef HAVE_FSEEKO64
    24.9  #undef HAVE_SIGACTION
   24.10  #undef HAVE_SA_SIGACTION
   24.11  #undef HAVE_SETJMP
    25.1 --- a/include/SDL_config_windows.h	Sun Nov 04 09:02:58 2012 -0500
    25.2 +++ b/include/SDL_config_windows.h	Sun Nov 04 09:46:59 2012 -0500
    25.3 @@ -142,14 +142,21 @@
    25.4  
    25.5  /* Enable various audio drivers */
    25.6  #define SDL_AUDIO_DRIVER_DSOUND	1
    25.7 +#ifndef __GNUC__
    25.8  #define SDL_AUDIO_DRIVER_XAUDIO2	1
    25.9 +#endif
   25.10  #define SDL_AUDIO_DRIVER_WINMM	1
   25.11  #define SDL_AUDIO_DRIVER_DISK	1
   25.12  #define SDL_AUDIO_DRIVER_DUMMY	1
   25.13  
   25.14  /* Enable various input drivers */
   25.15  #define SDL_JOYSTICK_DINPUT	1
   25.16 +#ifdef __GNUC__
   25.17 +/* There isn't a compatible dinput.h for mingw as far as I know */
   25.18 +#define SDL_HAPTIC_DISABLED	1
   25.19 +#else
   25.20  #define SDL_HAPTIC_DINPUT	1
   25.21 +#endif
   25.22  
   25.23  /* Enable various shared object loading systems */
   25.24  #define SDL_LOADSO_WINDOWS	1
    26.1 --- a/include/SDL_events.h	Sun Nov 04 09:02:58 2012 -0500
    26.2 +++ b/include/SDL_events.h	Sun Nov 04 09:46:59 2012 -0500
    26.3 @@ -336,7 +336,7 @@
    26.4      SDL_TouchID touchId;        /**< The touch device index */
    26.5      float dTheta;
    26.6      float dDist;
    26.7 -    float x;  //currently 0...1. Change to screen coords?
    26.8 +    float x;  /* currently 0...1. Change to screen coords? */
    26.9      float y;  
   26.10      Uint16 numFingers;
   26.11      Uint16 padding;
   26.12 @@ -438,6 +438,15 @@
   26.13      SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */
   26.14      SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */
   26.15      SDL_DropEvent drop;             /**< Drag and drop event data */
   26.16 +
   26.17 +    /* This is necessary for ABI compatibility between Visual C++ and GCC
   26.18 +       Visual C++ will respect the push pack pragma and use 52 bytes for
   26.19 +       this structure, and GCC will use the alignment of the largest datatype
   26.20 +       within the union, which is 8 bytes.
   26.21 +
   26.22 +       So... we'll add padding to force the size to be 56 bytes for both.
   26.23 +    */
   26.24 +    Uint8 padding[56];
   26.25  } SDL_Event;
   26.26  
   26.27  
    27.1 --- a/include/SDL_log.h	Sun Nov 04 09:02:58 2012 -0500
    27.2 +++ b/include/SDL_log.h	Sun Nov 04 09:46:59 2012 -0500
    27.3 @@ -59,12 +59,14 @@
    27.4   *  \brief The predefined log categories
    27.5   *
    27.6   *  By default the application category is enabled at the INFO level,
    27.7 - *  and all other categories are enabled at the CRITICAL level.
    27.8 + *  the assert category is enabled at the WARN level, and all other
    27.9 + *  categories are enabled at the CRITICAL level.
   27.10   */
   27.11  enum
   27.12  {
   27.13      SDL_LOG_CATEGORY_APPLICATION,
   27.14      SDL_LOG_CATEGORY_ERROR,
   27.15 +    SDL_LOG_CATEGORY_ASSERT,
   27.16      SDL_LOG_CATEGORY_SYSTEM,
   27.17      SDL_LOG_CATEGORY_AUDIO,
   27.18      SDL_LOG_CATEGORY_VIDEO,
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/include/SDL_messagebox.h	Sun Nov 04 09:46:59 2012 -0500
    28.3 @@ -0,0 +1,147 @@
    28.4 +/*
    28.5 +  Simple DirectMedia Layer
    28.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    28.7 +
    28.8 +  This software is provided 'as-is', without any express or implied
    28.9 +  warranty.  In no event will the authors be held liable for any damages
   28.10 +  arising from the use of this software.
   28.11 +
   28.12 +  Permission is granted to anyone to use this software for any purpose,
   28.13 +  including commercial applications, and to alter it and redistribute it
   28.14 +  freely, subject to the following restrictions:
   28.15 +
   28.16 +  1. The origin of this software must not be misrepresented; you must not
   28.17 +     claim that you wrote the original software. If you use this software
   28.18 +     in a product, an acknowledgment in the product documentation would be
   28.19 +     appreciated but is not required.
   28.20 +  2. Altered source versions must be plainly marked as such, and must not be
   28.21 +     misrepresented as being the original software.
   28.22 +  3. This notice may not be removed or altered from any source distribution.
   28.23 +*/
   28.24 +
   28.25 +#ifndef _SDL_messagebox_h
   28.26 +#define _SDL_messagebox_h
   28.27 +
   28.28 +#include "SDL_stdinc.h"
   28.29 +#include "SDL_video.h"      /* For SDL_Window */
   28.30 +
   28.31 +#include "begin_code.h"
   28.32 +/* Set up for C function definitions, even when using C++ */
   28.33 +#ifdef __cplusplus
   28.34 +/* *INDENT-OFF* */
   28.35 +extern "C" {
   28.36 +/* *INDENT-ON* */
   28.37 +#endif
   28.38 +
   28.39 +/**
   28.40 + * \brief SDL_MessageBox flags. If supported will display warning icon, etc.
   28.41 + */
   28.42 +typedef enum
   28.43 +{
   28.44 +    SDL_MESSAGEBOX_ERROR        = 0x00000010,   /**< error dialog */
   28.45 +    SDL_MESSAGEBOX_WARNING      = 0x00000020,   /**< warning dialog */
   28.46 +    SDL_MESSAGEBOX_INFORMATION  = 0x00000040,   /**< informational dialog */
   28.47 +} SDL_MessageBoxFlags;
   28.48 +
   28.49 +/**
   28.50 + * \brief Flags for SDL_MessageBoxButtonData.
   28.51 + */
   28.52 +typedef enum
   28.53 +{
   28.54 +    SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,  /**< Marks the default button when return is hit */
   28.55 +    SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002,  /**< Marks the default button when escape is hit */
   28.56 +} SDL_MessageBoxButtonFlags;
   28.57 +
   28.58 +/**
   28.59 + *  \brief Individual button data.
   28.60 + */
   28.61 +typedef struct
   28.62 +{
   28.63 +    Uint32 flags;       /**< ::SDL_MessageBoxButtonFlags */
   28.64 +    int buttonid;       /**< User defined button id (value returned via SDL_MessageBox) */
   28.65 +    const char * text;  /**< The UTF-8 button text */
   28.66 +} SDL_MessageBoxButtonData;
   28.67 +
   28.68 +/**
   28.69 + * \brief RGB value used in a message box color scheme
   28.70 + */
   28.71 +typedef struct
   28.72 +{
   28.73 +    Uint8 r, g, b;
   28.74 +} SDL_MessageBoxColor;
   28.75 +
   28.76 +typedef enum
   28.77 +{
   28.78 +	SDL_MESSAGEBOX_COLOR_BACKGROUND,
   28.79 +	SDL_MESSAGEBOX_COLOR_TEXT,
   28.80 +	SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
   28.81 +	SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
   28.82 +	SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
   28.83 +	SDL_MESSAGEBOX_COLOR_MAX
   28.84 +} SDL_MessageBoxColorType;
   28.85 +
   28.86 +/**
   28.87 + * \brief A set of colors to use for message box dialogs
   28.88 + */
   28.89 +typedef struct
   28.90 +{
   28.91 +    SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX];
   28.92 +} SDL_MessageBoxColorScheme;
   28.93 +
   28.94 +/**
   28.95 + *  \brief MessageBox structure containing title, text, window, etc.
   28.96 + */
   28.97 +typedef struct
   28.98 +{
   28.99 +    Uint32 flags;                       /**< ::SDL_MessageBoxFlags */
  28.100 +    SDL_Window *window;                 /**< Parent window, can be NULL */
  28.101 +    const char *title;                  /**< UTF-8 title */
  28.102 +    const char *message;                /**< UTF-8 message text */
  28.103 +
  28.104 +    int numbuttons;
  28.105 +    const SDL_MessageBoxButtonData *buttons;
  28.106 +
  28.107 +    const SDL_MessageBoxColorScheme *colorScheme;   /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */
  28.108 +} SDL_MessageBoxData;
  28.109 +
  28.110 +/**
  28.111 + *  \brief Create a modal message box.
  28.112 + *
  28.113 + *  \param messagebox The SDL_MessageBox structure with title, text, etc.
  28.114 + *
  28.115 + *  \return -1 on error, otherwise 0 and buttonid contains user id of button
  28.116 + *          hit or -1 if dialog was closed.
  28.117 + *
  28.118 + *  \note This function should be called on the thread that created the parent
  28.119 + *        window, or on the main thread if the messagebox has no parent.  It will
  28.120 + *        block execution of that thread until the user clicks a button or
  28.121 + *        closes the messagebox.
  28.122 + */
  28.123 +extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
  28.124 +
  28.125 +/**
  28.126 + *  \brief Create a simple modal message box
  28.127 + *
  28.128 + *  \param flags    ::SDL_MessageBoxFlags
  28.129 + *  \param title    UTF-8 title text
  28.130 + *  \param message  UTF-8 message text
  28.131 + *  \param window   The parent window, or NULL for no parent
  28.132 + *
  28.133 + *  \return 0 on success, -1 on error
  28.134 + *
  28.135 + *  \sa SDL_ShowMessageBox
  28.136 + */
  28.137 +extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window);
  28.138 +
  28.139 +
  28.140 +/* Ends C function definitions when using C++ */
  28.141 +#ifdef __cplusplus
  28.142 +/* *INDENT-OFF* */
  28.143 +}
  28.144 +/* *INDENT-ON* */
  28.145 +#endif
  28.146 +#include "close_code.h"
  28.147 +
  28.148 +#endif /* _SDL_messagebox_h */
  28.149 +
  28.150 +/* vi: set ts=4 sw=4 expandtab: */
    29.1 --- a/include/SDL_rwops.h	Sun Nov 04 09:02:58 2012 -0500
    29.2 +++ b/include/SDL_rwops.h	Sun Nov 04 09:46:59 2012 -0500
    29.3 @@ -46,13 +46,18 @@
    29.4  typedef struct SDL_RWops
    29.5  {
    29.6      /**
    29.7 +     *  Return the size of the file in this rwops, or -1 if unknown
    29.8 +     */
    29.9 +    Sint64 (SDLCALL * size) (struct SDL_RWops * context);
   29.10 +
   29.11 +    /**
   29.12       *  Seek to \c offset relative to \c whence, one of stdio's whence values:
   29.13       *  RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
   29.14       *  
   29.15       *  \return the final offset in the data stream.
   29.16       */
   29.17 -    long (SDLCALL * seek) (struct SDL_RWops * context, long offset,
   29.18 -                           int whence);
   29.19 +    Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset,
   29.20 +                             int whence);
   29.21  
   29.22      /**
   29.23       *  Read up to \c maxnum objects each of size \c size from the data
   29.24 @@ -60,8 +65,8 @@
   29.25       *  
   29.26       *  \return the number of objects read, or 0 at error or end of file.
   29.27       */
   29.28 -    size_t(SDLCALL * read) (struct SDL_RWops * context, void *ptr,
   29.29 -                            size_t size, size_t maxnum);
   29.30 +    size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr,
   29.31 +                             size_t size, size_t maxnum);
   29.32  
   29.33      /**
   29.34       *  Write exactly \c num objects each of size \c size from the area
   29.35 @@ -69,8 +74,8 @@
   29.36       *  
   29.37       *  \return the number of objects written, or 0 at error or end of file.
   29.38       */
   29.39 -    size_t(SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
   29.40 -                             size_t size, size_t num);
   29.41 +    size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
   29.42 +                              size_t size, size_t num);
   29.43  
   29.44      /**
   29.45       *  Close and free an allocated SDL_RWops structure.
   29.46 @@ -166,6 +171,7 @@
   29.47   *  Macros to easily read and write from an SDL_RWops structure.
   29.48   */
   29.49  /*@{*/
   29.50 +#define SDL_RWsize(ctx)	        (ctx)->size(ctx)
   29.51  #define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
   29.52  #define SDL_RWtell(ctx)			(ctx)->seek(ctx, 0, RW_SEEK_CUR)
   29.53  #define SDL_RWread(ctx, ptr, size, n)	(ctx)->read(ctx, ptr, size, n)
    30.1 --- a/include/SDL_stdinc.h	Sun Nov 04 09:02:58 2012 -0500
    30.2 +++ b/include/SDL_stdinc.h	Sun Nov 04 09:46:59 2012 -0500
    30.3 @@ -347,7 +347,7 @@
    30.4  /* We can count on memcpy existing on Mac OS X and being well-tuned. */
    30.5  #if defined(__MACOSX__)
    30.6  #define SDL_memcpy      memcpy
    30.7 -#elif defined(__GNUC__) && defined(i386)
    30.8 +#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
    30.9  #define SDL_memcpy(dst, src, len)					  \
   30.10  do {									  \
   30.11  	int u0, u1, u2;						  	  \
   30.12 @@ -640,8 +640,10 @@
   30.13  #endif
   30.14  
   30.15  #ifndef HAVE_M_PI
   30.16 +#ifndef M_PI
   30.17  #define M_PI    3.14159265358979323846264338327950288   /* pi */
   30.18  #endif
   30.19 +#endif
   30.20  
   30.21  #ifdef HAVE_ATAN
   30.22  #define SDL_atan        atan
   30.23 @@ -755,8 +757,8 @@
   30.24                                                 const char *inbuf,
   30.25                                                 size_t inbytesleft);
   30.26  #define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
   30.27 -#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
   30.28 -#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
   30.29 +#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
   30.30 +#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
   30.31  
   30.32  /* Ends C function definitions when using C++ */
   30.33  #ifdef __cplusplus
    31.1 --- a/include/SDL_system.h	Sun Nov 04 09:02:58 2012 -0500
    31.2 +++ b/include/SDL_system.h	Sun Nov 04 09:46:59 2012 -0500
    31.3 @@ -43,6 +43,7 @@
    31.4  /* *INDENT-ON* */
    31.5  #endif
    31.6  
    31.7 +/* Platform specific functions for iOS */
    31.8  #if __IPHONEOS__
    31.9  
   31.10  extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
   31.11 @@ -53,7 +54,43 @@
   31.12  #define SDL_iPhoneKeyboardToggle    SDL_ToggleScreenKeyboard
   31.13  #define SDL_iPhoneKeyboardIsShown   SDL_IsScreenKeyboardShown
   31.14  
   31.15 -#endif
   31.16 +#endif /* __IPHONEOS__ */
   31.17 +
   31.18 +
   31.19 +/* Platform specific functions for Android */
   31.20 +#if __ANDROID__
   31.21 +
   31.22 +/* Get the JNI environment for the current thread
   31.23 +   This returns JNIEnv*, but the prototype is void* so we don't need jni.h
   31.24 + */
   31.25 +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv();
   31.26 +
   31.27 +/* Get the SDL Activity object for the application
   31.28 +   This returns jobject, but the prototype is void* so we don't need jni.h
   31.29 + */
   31.30 +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity();
   31.31 +
   31.32 +/* See the official Android developer guide for more information:
   31.33 +   http://developer.android.com/guide/topics/data/data-storage.html
   31.34 +*/
   31.35 +#define SDL_ANDROID_EXTERNAL_STORAGE_READ   0x01
   31.36 +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE  0x02
   31.37 +
   31.38 +/* Get the path used for internal storage for this application */
   31.39 +extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath();
   31.40 +
   31.41 +/* Get the current state of external storage, a bitmask of these values:
   31.42 +    SDL_ANDROID_EXTERNAL_STORAGE_READ
   31.43 +    SDL_ANDROID_EXTERNAL_STORAGE_WRITE
   31.44 +   If external storage is currently unavailable, this will return 0.
   31.45 +*/
   31.46 +extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState();
   31.47 +
   31.48 +/* Get the path used for external storage for this application */
   31.49 +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
   31.50 +
   31.51 +#endif /* __ANDROID__ */
   31.52 +
   31.53  
   31.54  /* Ends C function definitions when using C++ */
   31.55  #ifdef __cplusplus
    32.1 --- a/src/SDL_assert.c	Sun Nov 04 09:02:58 2012 -0500
    32.2 +++ b/src/SDL_assert.c	Sun Nov 04 09:46:59 2012 -0500
    32.3 @@ -22,11 +22,13 @@
    32.4  
    32.5  #include "SDL.h"
    32.6  #include "SDL_atomic.h"
    32.7 +#include "SDL_messagebox.h"
    32.8 +#include "SDL_video.h"
    32.9  #include "SDL_assert.h"
   32.10  #include "SDL_assert_c.h"
   32.11  #include "video/SDL_sysvideo.h"
   32.12  
   32.13 -#if defined(__WIN32__) || defined(__WINRT__)
   32.14 +#ifdef __WIN32__
   32.15  #include "core/windows/SDL_windows.h"
   32.16  
   32.17  #ifndef WS_OVERLAPPEDWINDOW
   32.18 @@ -59,172 +61,13 @@
   32.19  static void
   32.20  debug_print(const char *fmt, ...)
   32.21  {
   32.22 -#if defined(__WIN32__) || defined(__WINRT__)
   32.23 -    /* Format into a buffer for OutputDebugStringA(). */
   32.24 -    char buf[1024];
   32.25 -    char *startptr;
   32.26 -    char *ptr;
   32.27 -    LPTSTR tstr;
   32.28 -    int len;
   32.29      va_list ap;
   32.30      va_start(ap, fmt);
   32.31 -    len = (int) SDL_vsnprintf(buf, sizeof (buf), fmt, ap);
   32.32 +    SDL_LogMessageV(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_WARN, fmt, ap);
   32.33      va_end(ap);
   32.34 -
   32.35 -    /* Visual C's vsnprintf() may not null-terminate the buffer. */
   32.36 -    if ((len >= sizeof (buf)) || (len < 0)) {
   32.37 -        buf[sizeof (buf) - 1] = '\0';
   32.38 -    }
   32.39 -
   32.40 -    /* Write it, sorting out the Unix newlines... */
   32.41 -    startptr = buf;
   32.42 -    for (ptr = startptr; *ptr; ptr++) {
   32.43 -        if (*ptr == '\n') {
   32.44 -            *ptr = '\0';
   32.45 -            tstr = WIN_UTF8ToString(startptr);
   32.46 -            OutputDebugString(tstr);
   32.47 -            SDL_free(tstr);
   32.48 -            OutputDebugString(TEXT("\r\n"));
   32.49 -            startptr = ptr+1;
   32.50 -        }
   32.51 -    }
   32.52 -
   32.53 -    /* catch that last piece if it didn't have a newline... */
   32.54 -    if (startptr != ptr) {
   32.55 -        tstr = WIN_UTF8ToString(startptr);
   32.56 -        OutputDebugString(tstr);
   32.57 -        SDL_free(tstr);
   32.58 -    }
   32.59 -#else
   32.60 -    /* Unix has it easy. Just dump it to stderr. */
   32.61 -    va_list ap;
   32.62 -    va_start(ap, fmt);
   32.63 -    vfprintf(stderr, fmt, ap);
   32.64 -    va_end(ap);
   32.65 -    fflush(stderr);
   32.66 -#endif
   32.67  }
   32.68  
   32.69  
   32.70 -#ifdef __WIN32__
   32.71 -static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
   32.72 -static const SDL_assert_data *SDL_Windows_AssertData = NULL;
   32.73 -
   32.74 -static LRESULT CALLBACK
   32.75 -SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
   32.76 -{
   32.77 -    switch (msg)
   32.78 -    {
   32.79 -        case WM_CREATE:
   32.80 -        {
   32.81 -            /* !!! FIXME: all this code stinks. */
   32.82 -            const SDL_assert_data *data = SDL_Windows_AssertData;
   32.83 -            char buf[1024];
   32.84 -            LPTSTR tstr;
   32.85 -            const int w = 100;
   32.86 -            const int h = 25;
   32.87 -            const int gap = 10;
   32.88 -            int x = gap;
   32.89 -            int y = 50;
   32.90 -            int len;
   32.91 -            int i;
   32.92 -            static const struct { 
   32.93 -                LPCTSTR name;
   32.94 -                SDL_assert_state state;
   32.95 -            } buttons[] = {
   32.96 -                {TEXT("Abort"), SDL_ASSERTION_ABORT },
   32.97 -                {TEXT("Break"), SDL_ASSERTION_BREAK },
   32.98 -                {TEXT("Retry"), SDL_ASSERTION_RETRY },
   32.99 -                {TEXT("Ignore"), SDL_ASSERTION_IGNORE },
  32.100 -                {TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE },
  32.101 -            };
  32.102 -
  32.103 -            len = (int) SDL_snprintf(buf, sizeof (buf), 
  32.104 -                         "Assertion failure at %s (%s:%d), triggered %u time%s:\r\n  '%s'",
  32.105 -                         data->function, data->filename, data->linenum,
  32.106 -                         data->trigger_count, (data->trigger_count == 1) ? "" : "s",
  32.107 -                         data->condition);
  32.108 -            if ((len < 0) || (len >= sizeof (buf))) {
  32.109 -                buf[sizeof (buf) - 1] = '\0';
  32.110 -            }
  32.111 -
  32.112 -            tstr = WIN_UTF8ToString(buf);
  32.113 -            CreateWindow(TEXT("STATIC"), tstr,
  32.114 -                         WS_VISIBLE | WS_CHILD | SS_LEFT,
  32.115 -                         x, y, 550, 100,
  32.116 -                         hwnd, (HMENU) 1, NULL, NULL);
  32.117 -            SDL_free(tstr);
  32.118 -            y += 110;
  32.119 -
  32.120 -            for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) {
  32.121 -                CreateWindow(TEXT("BUTTON"), buttons[i].name,
  32.122 -                         WS_VISIBLE | WS_CHILD,
  32.123 -                         x, y, w, h,
  32.124 -                         hwnd, (HMENU) buttons[i].state, NULL, NULL);
  32.125 -                x += w + gap;
  32.126 -            }
  32.127 -            break;
  32.128 -        }
  32.129 -
  32.130 -        case WM_COMMAND:
  32.131 -            SDL_Windows_AssertChoice = ((SDL_assert_state) (LOWORD(wParam)));
  32.132 -            SDL_Windows_AssertData = NULL;
  32.133 -            break;
  32.134 -
  32.135 -        case WM_DESTROY:
  32.136 -            SDL_Windows_AssertData = NULL;
  32.137 -            break;
  32.138 -    }
  32.139 -
  32.140 -    return DefWindowProc(hwnd, msg, wParam, lParam);
  32.141 -}
  32.142 -
  32.143 -static SDL_assert_state
  32.144 -SDL_PromptAssertion_windows(const SDL_assert_data *data)
  32.145 -{
  32.146 -    HINSTANCE hInstance = 0;  /* !!! FIXME? */
  32.147 -    HWND hwnd;
  32.148 -    MSG msg;
  32.149 -    WNDCLASS wc = {0};
  32.150 -
  32.151 -    SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
  32.152 -    SDL_Windows_AssertData = data;
  32.153 -
  32.154 -    wc.lpszClassName = TEXT("SDL_assert");
  32.155 -    wc.hInstance = hInstance ;
  32.156 -    wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  32.157 -    wc.lpfnWndProc = SDL_Assertion_WndProc;
  32.158 -    wc.hCursor = LoadCursor(0, IDC_ARROW);
  32.159 -  
  32.160 -    RegisterClass(&wc);
  32.161 -    hwnd = CreateWindow(wc.lpszClassName, TEXT("SDL assertion failure"),
  32.162 -                 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  32.163 -                 150, 150, 570, 260, 0, 0, hInstance, 0);  
  32.164 -
  32.165 -    while (GetMessage(&msg, NULL, 0, 0) && (SDL_Windows_AssertData != NULL)) {
  32.166 -        TranslateMessage(&msg);
  32.167 -        DispatchMessage(&msg);
  32.168 -    }
  32.169 -
  32.170 -    DestroyWindow(hwnd);
  32.171 -    UnregisterClass(wc.lpszClassName, hInstance);
  32.172 -    return SDL_Windows_AssertChoice;
  32.173 -}
  32.174 -#endif
  32.175 -
  32.176 -
  32.177 -#ifdef __WINRT__
  32.178 -
  32.179 -static SDL_assert_state
  32.180 -SDL_PromptAssertion_windowsrt(const SDL_assert_data *data)
  32.181 -{
  32.182 -    /* TODO, WinRT: implement SDL_PromptAssertion_windowsrt */
  32.183 -    return SDL_ASSERTION_ABORT;
  32.184 -}
  32.185 -
  32.186 -#endif
  32.187 -
  32.188 -
  32.189  static void SDL_AddAssertionToReport(SDL_assert_data *data)
  32.190  {
  32.191      /* (data) is always a static struct defined with the assert macros, so
  32.192 @@ -266,10 +109,8 @@
  32.193  
  32.194  static void SDL_ExitProcess(int exitcode)
  32.195  {
  32.196 -#if defined(__WIN32__)
  32.197 +#ifdef __WIN32__
  32.198      ExitProcess(exitcode);
  32.199 -#elif defined(__WINRT__)
  32.200 -    exit(exitcode);
  32.201  #else
  32.202      _exit(exitcode);
  32.203  #endif
  32.204 @@ -288,20 +129,39 @@
  32.205      const char *envr;
  32.206      SDL_assert_state state = SDL_ASSERTION_ABORT;
  32.207      SDL_Window *window;
  32.208 +    SDL_MessageBoxData messagebox;
  32.209 +    SDL_MessageBoxButtonData buttons[] = {
  32.210 +        {   0,  SDL_ASSERTION_RETRY,            "Retry" },
  32.211 +        {   0,  SDL_ASSERTION_BREAK,            "Break" },
  32.212 +        {   0,  SDL_ASSERTION_ABORT,            "Abort" },
  32.213 +        {   SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
  32.214 +                SDL_ASSERTION_IGNORE,           "Ignore" },
  32.215 +        {   SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
  32.216 +                SDL_ASSERTION_ALWAYS_IGNORE,    "Always Ignore" }
  32.217 +    };
  32.218 +    char *message;
  32.219 +    int selected;
  32.220  
  32.221      (void) userdata;  /* unused in default handler. */
  32.222  
  32.223 -    debug_print("\n\n"
  32.224 -                "Assertion failure at %s (%s:%d), triggered %u time%s:\n"
  32.225 -                "  '%s'\n"
  32.226 -                "\n",
  32.227 -                data->function, data->filename, data->linenum,
  32.228 -                data->trigger_count, (data->trigger_count == 1) ? "" : "s",
  32.229 -                data->condition);
  32.230 +    message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
  32.231 +    if (!message) {
  32.232 +        /* Uh oh, we're in real trouble now... */
  32.233 +        return SDL_ASSERTION_ABORT;
  32.234 +    }
  32.235 +    SDL_snprintf(message, SDL_MAX_LOG_MESSAGE,
  32.236 +                 "Assertion failure at %s (%s:%d), triggered %u %s:\r\n  '%s'",
  32.237 +                 data->function, data->filename, data->linenum,
  32.238 +                 data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
  32.239 +                 data->condition);
  32.240 +
  32.241 +    debug_print("\n\n%s\n\n", message);
  32.242  
  32.243      /* let env. variable override, so unit tests won't block in a GUI. */
  32.244      envr = SDL_getenv("SDL_ASSERT");
  32.245      if (envr != NULL) {
  32.246 +        SDL_stack_free(message);
  32.247 +
  32.248          if (SDL_strcmp(envr, "abort") == 0) {
  32.249              return SDL_ASSERTION_ABORT;
  32.250          } else if (SDL_strcmp(envr, "break") == 0) {
  32.251 @@ -325,57 +185,65 @@
  32.252          } else {
  32.253              /* !!! FIXME: ungrab the input if we're not fullscreen? */
  32.254              /* No need to mess with the window */
  32.255 -            window = 0;
  32.256 +            window = NULL;
  32.257          }
  32.258      }
  32.259  
  32.260 -    /* platform-specific UI... */
  32.261 +    /* Show a messagebox if we can, otherwise fall back to stdio */
  32.262 +    SDL_zero(messagebox);
  32.263 +    messagebox.flags = SDL_MESSAGEBOX_WARNING;
  32.264 +    messagebox.window = window;
  32.265 +    messagebox.title = "Assertion Failed";
  32.266 +    messagebox.message = message;
  32.267 +    messagebox.numbuttons = SDL_arraysize(buttons);
  32.268 +    messagebox.buttons = buttons;
  32.269  
  32.270 -#if defined(__WIN32__)
  32.271 -    state = SDL_PromptAssertion_windows(data);
  32.272 -
  32.273 -#elif defined(__WINRT__)
  32.274 -    state = SDL_PromptAssertion_windowsrt(data);
  32.275 -
  32.276 -#elif defined __MACOSX__ && defined SDL_VIDEO_DRIVER_COCOA
  32.277 -    /* This has to be done in an Objective-C (*.m) file, so we call out. */
  32.278 -    extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *);
  32.279 -    state = SDL_PromptAssertion_cocoa(data);
  32.280 -
  32.281 -#else
  32.282 -    /* this is a little hacky. */
  32.283 -    for ( ; ; ) {
  32.284 -        char buf[32];
  32.285 -        fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
  32.286 -        fflush(stderr);
  32.287 -        if (fgets(buf, sizeof (buf), stdin) == NULL) {
  32.288 -            break;
  32.289 -        }
  32.290 -
  32.291 -        if (SDL_strcmp(buf, "a") == 0) {
  32.292 -            state = SDL_ASSERTION_ABORT;
  32.293 -            break;
  32.294 -        } else if (SDL_strcmp(buf, "b") == 0) {
  32.295 -            state = SDL_ASSERTION_BREAK;
  32.296 -            break;
  32.297 -        } else if (SDL_strcmp(buf, "r") == 0) {
  32.298 -            state = SDL_ASSERTION_RETRY;
  32.299 -            break;
  32.300 -        } else if (SDL_strcmp(buf, "i") == 0) {
  32.301 +    if (SDL_ShowMessageBox(&messagebox, &selected) == 0) {
  32.302 +        if (selected == -1) {
  32.303              state = SDL_ASSERTION_IGNORE;
  32.304 -            break;
  32.305 -        } else if (SDL_strcmp(buf, "A") == 0) {
  32.306 -            state = SDL_ASSERTION_ALWAYS_IGNORE;
  32.307 -            break;
  32.308 +        } else {
  32.309 +            state = (SDL_assert_state)selected;
  32.310          }
  32.311      }
  32.312 -#endif
  32.313 +#ifdef HAVE_STDIO_H
  32.314 +    else
  32.315 +    {
  32.316 +        /* this is a little hacky. */
  32.317 +        for ( ; ; ) {
  32.318 +            char buf[32];
  32.319 +            fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
  32.320 +            fflush(stderr);
  32.321 +            if (fgets(buf, sizeof (buf), stdin) == NULL) {
  32.322 +                break;
  32.323 +            }
  32.324 +
  32.325 +            if (SDL_strcmp(buf, "a") == 0) {
  32.326 +                state = SDL_ASSERTION_ABORT;
  32.327 +                break;
  32.328 +            } else if (SDL_strcmp(buf, "b") == 0) {
  32.329 +                state = SDL_ASSERTION_BREAK;
  32.330 +                break;
  32.331 +            } else if (SDL_strcmp(buf, "r") == 0) {
  32.332 +                state = SDL_ASSERTION_RETRY;
  32.333 +                break;
  32.334 +            } else if (SDL_strcmp(buf, "i") == 0) {
  32.335 +                state = SDL_ASSERTION_IGNORE;
  32.336 +                break;
  32.337 +            } else if (SDL_strcmp(buf, "A") == 0) {
  32.338 +                state = SDL_ASSERTION_ALWAYS_IGNORE;
  32.339 +                break;
  32.340 +            }
  32.341 +        }
  32.342 +    }
  32.343 +#endif /* HAVE_STDIO_H */
  32.344  
  32.345      /* Re-enter fullscreen mode */
  32.346      if (window) {
  32.347          SDL_RestoreWindow(window);
  32.348      }
  32.349  
  32.350 +    SDL_stack_free(message);
  32.351 +
  32.352      return state;
  32.353  }
  32.354  
    33.1 --- a/src/SDL_log.c	Sun Nov 04 09:02:58 2012 -0500
    33.2 +++ b/src/SDL_log.c	Sun Nov 04 09:46:59 2012 -0500
    33.3 @@ -35,6 +35,7 @@
    33.4  #endif
    33.5  
    33.6  #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
    33.7 +#define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
    33.8  #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
    33.9  
   33.10  typedef struct SDL_LogLevel
   33.11 @@ -50,8 +51,9 @@
   33.12                            const char *message);
   33.13  
   33.14  static SDL_LogLevel *SDL_loglevels;
   33.15 +static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
   33.16 +static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
   33.17  static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
   33.18 -static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
   33.19  static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
   33.20  static void *SDL_log_userdata = NULL;
   33.21  
   33.22 @@ -95,7 +97,9 @@
   33.23      for (entry = SDL_loglevels; entry; entry = entry->next) {
   33.24          entry->priority = priority;
   33.25      }
   33.26 -    SDL_application_priority = SDL_default_priority = priority;
   33.27 +    SDL_default_priority = priority;
   33.28 +    SDL_assert_priority = priority;
   33.29 +    SDL_application_priority = priority;
   33.30  }
   33.31  
   33.32  void
   33.33 @@ -133,6 +137,8 @@
   33.34  
   33.35      if (category == SDL_LOG_CATEGORY_APPLICATION) {
   33.36          return SDL_application_priority;
   33.37 +    } else if (category == SDL_LOG_CATEGORY_ASSERT) {
   33.38 +        return SDL_assert_priority;
   33.39      } else {
   33.40          return SDL_default_priority;
   33.41      }
   33.42 @@ -149,8 +155,9 @@
   33.43          SDL_free(entry);
   33.44      }
   33.45  
   33.46 +    SDL_default_priority = DEFAULT_PRIORITY;
   33.47 +    SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
   33.48      SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
   33.49 -    SDL_default_priority = DEFAULT_PRIORITY;
   33.50  }
   33.51  
   33.52  void
   33.53 @@ -302,6 +309,19 @@
   33.54          SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
   33.55          __android_log_write(SDL_android_priority[priority], tag, message);
   33.56      }
   33.57 +#elif defined(__APPLE__)
   33.58 +    extern void SDL_NSLog(const char *text);
   33.59 +    {
   33.60 +        char *text;
   33.61 +
   33.62 +        text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
   33.63 +        if (text) {
   33.64 +            SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);
   33.65 +            SDL_NSLog(text);
   33.66 +            SDL_stack_free(text);
   33.67 +            return;
   33.68 +        }
   33.69 +    }
   33.70  #endif
   33.71  #if HAVE_STDIO_H
   33.72      fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
    34.1 --- a/src/audio/coreaudio/SDL_coreaudio.c	Sun Nov 04 09:02:58 2012 -0500
    34.2 +++ b/src/audio/coreaudio/SDL_coreaudio.c	Sun Nov 04 09:46:59 2012 -0500
    34.3 @@ -340,9 +340,10 @@
    34.4                                            scope, bus, &callback,
    34.5                                            sizeof(callback));
    34.6  
    34.7 -            /* !!! FIXME: how does iOS free this? */
    34.8              #if MACOSX_COREAUDIO
    34.9              CloseComponent(this->hidden->audioUnit);
   34.10 +            #else
   34.11 +            AudioComponentInstanceDispose(this->hidden->audioUnit);
   34.12              #endif
   34.13  
   34.14              this->hidden->audioUnitOpened = 0;
   34.15 @@ -538,8 +539,16 @@
   34.16      impl->DetectDevices = COREAUDIO_DetectDevices;
   34.17  #else
   34.18      impl->OnlyHasDefaultOutputDevice = 1;
   34.19 +
   34.20 +    /* Set category to ambient sound so that other music continues playing.
   34.21 +       You can change this at runtime in your own code if you need different
   34.22 +       behavior.  If this is common, we can add an SDL hint for this.
   34.23 +    */
   34.24 +    AudioSessionInitialize(NULL, NULL, NULL, nil);
   34.25 +    UInt32 category = kAudioSessionCategory_AmbientSound;
   34.26 +    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
   34.27  #endif
   34.28 -    
   34.29 +
   34.30      impl->ProvidesOwnCallbackThread = 1;
   34.31  
   34.32      return 1;   /* this audio target is available. */
    35.1 --- a/src/audio/coreaudio/SDL_coreaudio.h	Sun Nov 04 09:02:58 2012 -0500
    35.2 +++ b/src/audio/coreaudio/SDL_coreaudio.h	Sun Nov 04 09:46:59 2012 -0500
    35.3 @@ -35,6 +35,8 @@
    35.4  #if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
    35.5  #include <AudioUnit/AUNTComponent.h>
    35.6  #endif
    35.7 +#else
    35.8 +#include <AudioToolbox/AudioToolbox.h>
    35.9  #endif
   35.10  
   35.11  #include <AudioUnit/AudioUnit.h>
    36.1 --- a/src/core/android/SDL_android.cpp	Sun Nov 04 09:02:58 2012 -0500
    36.2 +++ b/src/core/android/SDL_android.cpp	Sun Nov 04 09:46:59 2012 -0500
    36.3 @@ -24,6 +24,7 @@
    36.4  
    36.5  #ifdef __ANDROID__
    36.6  
    36.7 +#include "SDL_system.h"
    36.8  #include "SDL_android.h"
    36.9  
   36.10  extern "C" {
   36.11 @@ -695,9 +696,14 @@
   36.12  }
   36.13  
   36.14  
   36.15 -extern "C" long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence)
   36.16 +extern "C" Sint64 Android_JNI_FileSize(SDL_RWops* ctx)
   36.17  {
   36.18 -    long newPosition;
   36.19 +    return ctx->hidden.androidio.size;
   36.20 +}
   36.21 +
   36.22 +extern "C" Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
   36.23 +{
   36.24 +    Sint64 newPosition;
   36.25  
   36.26      switch (whence) {
   36.27          case RW_SEEK_SET:
   36.28 @@ -713,27 +719,27 @@
   36.29              SDL_SetError("Unknown value for 'whence'");
   36.30              return -1;
   36.31      }
   36.32 +
   36.33 +    /* Validate the new position */
   36.34      if (newPosition < 0) {
   36.35 -        newPosition = 0;
   36.36 +        SDL_Error(SDL_EFSEEK);
   36.37 +        return -1;
   36.38      }
   36.39      if (newPosition > ctx->hidden.androidio.size) {
   36.40          newPosition = ctx->hidden.androidio.size;
   36.41      }
   36.42  
   36.43 -    long movement = newPosition - ctx->hidden.androidio.position;
   36.44 -    jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
   36.45 -
   36.46 +    Sint64 movement = newPosition - ctx->hidden.androidio.position;
   36.47      if (movement > 0) {
   36.48          unsigned char buffer[1024];
   36.49  
   36.50          // The easy case where we're seeking forwards
   36.51          while (movement > 0) {
   36.52 -            long amount = (long) sizeof (buffer);
   36.53 +            Sint64 amount = sizeof (buffer);
   36.54              if (amount > movement) {
   36.55                  amount = movement;
   36.56              }
   36.57              size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount);
   36.58 -
   36.59              if (result <= 0) {
   36.60                  // Failed to read/skip the required amount, so fail
   36.61                  return -1;
   36.62 @@ -741,6 +747,7 @@
   36.63  
   36.64              movement -= result;
   36.65          }
   36.66 +
   36.67      } else if (movement < 0) {
   36.68          // We can't seek backwards so we have to reopen the file and seek
   36.69          // forwards which obviously isn't very efficient
   36.70 @@ -749,8 +756,6 @@
   36.71          Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET);
   36.72      }
   36.73  
   36.74 -    ctx->hidden.androidio.position = newPosition;
   36.75 -
   36.76      return ctx->hidden.androidio.position;
   36.77  }
   36.78  
   36.79 @@ -963,8 +968,6 @@
   36.80  
   36.81  /*extern "C" int Android_JNI_HideTextInput()
   36.82  {
   36.83 -
   36.84 -
   36.85      JNIEnv *env = Android_JNI_GetEnv();
   36.86      if (!env) {
   36.87          return -1;
   36.88 @@ -978,6 +981,155 @@
   36.89      return 0;
   36.90  }*/
   36.91  
   36.92 +//////////////////////////////////////////////////////////////////////////////
   36.93 +//
   36.94 +// Functions exposed to SDL applications in SDL_system.h
   36.95 +//
   36.96 +
   36.97 +extern "C" void *SDL_AndroidGetJNIEnv()
   36.98 +{
   36.99 +    return Android_JNI_GetEnv();
  36.100 +}
  36.101 +
  36.102 +extern "C" void *SDL_AndroidGetActivity()
  36.103 +{
  36.104 +    LocalReferenceHolder refs;
  36.105 +    jmethodID mid;
  36.106 +
  36.107 +    JNIEnv *env = Android_JNI_GetEnv();
  36.108 +    if (!refs.init(env)) {
  36.109 +        return NULL;
  36.110 +    }
  36.111 +
  36.112 +    // return SDLActivity.getContext();
  36.113 +    mid = env->GetStaticMethodID(mActivityClass,
  36.114 +            "getContext","()Landroid/content/Context;");
  36.115 +    return env->CallStaticObjectMethod(mActivityClass, mid);
  36.116 +}
  36.117 +
  36.118 +extern "C" const char * SDL_AndroidGetInternalStoragePath()
  36.119 +{
  36.120 +    static char *s_AndroidInternalFilesPath = NULL;
  36.121 +
  36.122 +    if (!s_AndroidInternalFilesPath) {
  36.123 +        LocalReferenceHolder refs;
  36.124 +        jmethodID mid;
  36.125 +        jobject context;
  36.126 +        jobject fileObject;
  36.127 +        jstring pathString;
  36.128 +        const char *path;
  36.129 +
  36.130 +        JNIEnv *env = Android_JNI_GetEnv();
  36.131 +        if (!refs.init(env)) {
  36.132 +            return NULL;
  36.133 +        }
  36.134 +
  36.135 +        // context = SDLActivity.getContext();
  36.136 +        mid = env->GetStaticMethodID(mActivityClass,
  36.137 +                "getContext","()Landroid/content/Context;");
  36.138 +        context = env->CallStaticObjectMethod(mActivityClass, mid);
  36.139 +
  36.140 +        // fileObj = context.getFilesDir();
  36.141 +        mid = env->GetMethodID(env->GetObjectClass(context),
  36.142 +                "getFilesDir", "()Ljava/io/File;");
  36.143 +        fileObject = env->CallObjectMethod(context, mid);
  36.144 +        if (!fileObject) {
  36.145 +            SDL_SetError("Couldn't get internal directory");
  36.146 +            return NULL;
  36.147 +        }
  36.148 +
  36.149 +        // path = fileObject.getAbsolutePath();
  36.150 +        mid = env->GetMethodID(env->GetObjectClass(fileObject),
  36.151 +                "getAbsolutePath", "()Ljava/lang/String;");
  36.152 +        pathString = (jstring)env->CallObjectMethod(fileObject, mid);
  36.153 +
  36.154 +        path = env->GetStringUTFChars(pathString, NULL);
  36.155 +        s_AndroidInternalFilesPath = SDL_strdup(path);
  36.156 +        env->ReleaseStringUTFChars(pathString, path);
  36.157 +    }
  36.158 +    return s_AndroidInternalFilesPath;
  36.159 +}
  36.160 +
  36.161 +extern "C" int SDL_AndroidGetExternalStorageState()
  36.162 +{
  36.163 +    LocalReferenceHolder refs;
  36.164 +    jmethodID mid;
  36.165 +    jclass cls;
  36.166 +    jstring stateString;
  36.167 +    const char *state;
  36.168 +    int stateFlags;
  36.169 +
  36.170 +    JNIEnv *env = Android_JNI_GetEnv();
  36.171 +    if (!refs.init(env)) {
  36.172 +        return 0;
  36.173 +    }
  36.174 +
  36.175 +    cls = env->FindClass("android/os/Environment");
  36.176 +    mid = env->GetStaticMethodID(cls,
  36.177 +            "getExternalStorageState", "()Ljava/lang/String;");
  36.178 +    stateString = (jstring)env->CallStaticObjectMethod(cls, mid);
  36.179 +
  36.180 +    state = env->GetStringUTFChars(stateString, NULL);
  36.181 +
  36.182 +    // Print an info message so people debugging know the storage state
  36.183 +    __android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state);
  36.184 +
  36.185 +    if (SDL_strcmp(state, "mounted") == 0) {
  36.186 +        stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ |
  36.187 +                     SDL_ANDROID_EXTERNAL_STORAGE_WRITE;
  36.188 +    } else if (SDL_strcmp(state, "mounted_ro") == 0) {
  36.189 +        stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ;
  36.190 +    } else {
  36.191 +        stateFlags = 0;
  36.192 +    }
  36.193 +    env->ReleaseStringUTFChars(stateString, state);
  36.194 +
  36.195 +    return stateFlags;
  36.196 +}
  36.197 +
  36.198 +extern "C" const char * SDL_AndroidGetExternalStoragePath()
  36.199 +{
  36.200 +    static char *s_AndroidExternalFilesPath = NULL;
  36.201 +
  36.202 +    if (!s_AndroidExternalFilesPath) {
  36.203 +        LocalReferenceHolder refs;
  36.204 +        jmethodID mid;
  36.205 +        jobject context;
  36.206 +        jobject fileObject;
  36.207 +        jstring pathString;
  36.208 +        const char *path;
  36.209 +
  36.210 +        JNIEnv *env = Android_JNI_GetEnv();
  36.211 +        if (!refs.init(env)) {
  36.212 +            return NULL;
  36.213 +        }
  36.214 +
  36.215 +        // context = SDLActivity.getContext();
  36.216 +        mid = env->GetStaticMethodID(mActivityClass,
  36.217 +                "getContext","()Landroid/content/Context;");
  36.218 +        context = env->CallStaticObjectMethod(mActivityClass, mid);
  36.219 +
  36.220 +        // fileObj = context.getExternalFilesDir();
  36.221 +        mid = env->GetMethodID(env->GetObjectClass(context),
  36.222 +                "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
  36.223 +        fileObject = env->CallObjectMethod(context, mid, NULL);
  36.224 +        if (!fileObject) {
  36.225 +            SDL_SetError("Couldn't get external directory");
  36.226 +            return NULL;
  36.227 +        }
  36.228 +
  36.229 +        // path = fileObject.getAbsolutePath();
  36.230 +        mid = env->GetMethodID(env->GetObjectClass(fileObject),
  36.231 +                "getAbsolutePath", "()Ljava/lang/String;");
  36.232 +        pathString = (jstring)env->CallObjectMethod(fileObject, mid);
  36.233 +
  36.234 +        path = env->GetStringUTFChars(pathString, NULL);
  36.235 +        s_AndroidExternalFilesPath = SDL_strdup(path);
  36.236 +        env->ReleaseStringUTFChars(pathString, path);
  36.237 +    }
  36.238 +    return s_AndroidExternalFilesPath;
  36.239 +}
  36.240 +
  36.241  #endif /* __ANDROID__ */
  36.242  
  36.243  /* vi: set ts=4 sw=4 expandtab: */
    37.1 --- a/src/core/android/SDL_android.h	Sun Nov 04 09:02:58 2012 -0500
    37.2 +++ b/src/core/android/SDL_android.h	Sun Nov 04 09:46:59 2012 -0500
    37.3 @@ -45,7 +45,8 @@
    37.4  #include "SDL_rwops.h"
    37.5  
    37.6  int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode);
    37.7 -long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence);
    37.8 +Sint64 Android_JNI_FileSize(SDL_RWops* ctx);
    37.9 +Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence);
   37.10  size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, size_t size, size_t maxnum);
   37.11  size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, size_t size, size_t num);
   37.12  int Android_JNI_FileClose(SDL_RWops* ctx);
    38.1 --- a/src/core/windows/SDL_windows.h	Sun Nov 04 09:02:58 2012 -0500
    38.2 +++ b/src/core/windows/SDL_windows.h	Sun Nov 04 09:46:59 2012 -0500
    38.3 @@ -37,8 +37,8 @@
    38.4  
    38.5  /* Routines to convert from UTF8 to native Windows text */
    38.6  #if UNICODE
    38.7 -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
    38.8 -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)(S), SDL_strlen(S)+1)
    38.9 +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
   38.10 +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", (char *)(S), SDL_strlen(S)+1)
   38.11  #else
   38.12  #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
   38.13  #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
    39.1 --- a/src/file/SDL_rwops.c	Sun Nov 04 09:02:58 2012 -0500
    39.2 +++ b/src/file/SDL_rwops.c	Sun Nov 04 09:46:59 2012 -0500
    39.3 @@ -18,6 +18,8 @@
    39.4       misrepresented as being the original software.
    39.5    3. This notice may not be removed or altered from any source distribution.
    39.6  */
    39.7 +/* Need this so Linux systems define fseek64o, ftell64o and off64_t */
    39.8 +#define _LARGEFILE64_SOURCE
    39.9  #include "SDL_config.h"
   39.10  
   39.11  /* This file provides a general interface for SDL to read and write
   39.12 @@ -121,11 +123,29 @@
   39.13      return 0;                   /* ok */
   39.14  }
   39.15  
   39.16 -static long SDLCALL
   39.17 -windows_file_seek(SDL_RWops * context, long offset, int whence)
   39.18 +static Sint64 SDLCALL
   39.19 +windows_file_size(SDL_RWops * context)
   39.20 +{
   39.21 +    LARGE_INTEGER size;
   39.22 +
   39.23 +    if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
   39.24 +        SDL_SetError("windows_file_size: invalid context/file not opened");
   39.25 +        return -1;
   39.26 +    }
   39.27 +
   39.28 +    if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
   39.29 +        WIN_SetError("windows_file_size");
   39.30 +        return -1;
   39.31 +    }
   39.32 +
   39.33 +    return size.QuadPart;
   39.34 +}
   39.35 +
   39.36 +static Sint64 SDLCALL
   39.37 +windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
   39.38  {
   39.39      DWORD windowswhence;
   39.40 -    long file_pos;
   39.41 +    LARGE_INTEGER windowsoffset;
   39.42  
   39.43      if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
   39.44          SDL_SetError("windows_file_seek: invalid context/file not opened");
   39.45 @@ -153,14 +173,12 @@
   39.46          return -1;
   39.47      }
   39.48  
   39.49 -    file_pos =
   39.50 -        SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence);
   39.51 -
   39.52 -    if (file_pos != INVALID_SET_FILE_POINTER)
   39.53 -        return file_pos;        /* success */
   39.54 -
   39.55 -    SDL_Error(SDL_EFSEEK);
   39.56 -    return -1;                  /* error */
   39.57 +    windowsoffset.QuadPart = offset;
   39.58 +    if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
   39.59 +        WIN_SetError("windows_file_seek");
   39.60 +        return -1;
   39.61 +    }
   39.62 +    return windowsoffset.QuadPart;
   39.63  }
   39.64  
   39.65  static size_t SDLCALL
   39.66 @@ -281,15 +299,39 @@
   39.67  
   39.68  /* Functions to read/write stdio file pointers */
   39.69  
   39.70 -static long SDLCALL
   39.71 -stdio_seek(SDL_RWops * context, long offset, int whence)
   39.72 +static Sint64 SDLCALL
   39.73 +stdio_size(SDL_RWops * context)
   39.74  {
   39.75 +    Sint64 pos, size;
   39.76 +
   39.77 +    pos = SDL_RWseek(context, 0, RW_SEEK_CUR);
   39.78 +    if (pos < 0) {
   39.79 +        return -1;
   39.80 +    }
   39.81 +    size = SDL_RWseek(context, 0, RW_SEEK_END);
   39.82 +
   39.83 +    SDL_RWseek(context, pos, RW_SEEK_SET);
   39.84 +    return size;
   39.85 +}
   39.86 +
   39.87 +static Sint64 SDLCALL
   39.88 +stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
   39.89 +{
   39.90 +#ifdef HAVE_FSEEKO64
   39.91 +    if (fseeko64(context->hidden.stdio.fp, (off64_t)offset, whence) == 0) {
   39.92 +        return ftello64(context->hidden.stdio.fp);
   39.93 +    }
   39.94 +#elif defined(HAVE_FSEEKO)
   39.95 +    if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
   39.96 +        return ftello(context->hidden.stdio.fp);
   39.97 +    }
   39.98 +#else
   39.99      if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
  39.100          return (ftell(context->hidden.stdio.fp));
  39.101 -    } else {
  39.102 -        SDL_Error(SDL_EFSEEK);
  39.103 -        return (-1);
  39.104      }
  39.105 +#endif
  39.106 +    SDL_Error(SDL_EFSEEK);
  39.107 +    return (-1);
  39.108  }
  39.109  
  39.110  static size_t SDLCALL
  39.111 @@ -336,8 +378,14 @@
  39.112  
  39.113  /* Functions to read/write memory pointers */
  39.114  
  39.115 -static long SDLCALL
  39.116 -mem_seek(SDL_RWops * context, long offset, int whence)
  39.117 +static Sint64 SDLCALL
  39.118 +mem_size(SDL_RWops * context)
  39.119 +{
  39.120 +    return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
  39.121 +}
  39.122 +
  39.123 +static Sint64 SDLCALL
  39.124 +mem_seek(SDL_RWops * context, Sint64 offset, int whence)
  39.125  {
  39.126      Uint8 *newpos;
  39.127  
  39.128 @@ -362,7 +410,7 @@
  39.129          newpos = context->hidden.mem.stop;
  39.130      }
  39.131      context->hidden.mem.here = newpos;
  39.132 -    return (long)(context->hidden.mem.here - context->hidden.mem.base);
  39.133 +    return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
  39.134  }
  39.135  
  39.136  static size_t SDLCALL
  39.137 @@ -427,6 +475,32 @@
  39.138          return NULL;
  39.139      }
  39.140  #if defined(ANDROID)
  39.141 +#ifdef HAVE_STDIO_H
  39.142 +    /* Try to open the file on the filesystem first */
  39.143 +    if (*file == '/') {
  39.144 +        FILE *fp = fopen(file, mode);
  39.145 +        if (fp) {
  39.146 +            return SDL_RWFromFP(fp, 1);
  39.147 +        }
  39.148 +    } else {
  39.149 +        /* Try opening it from internal storage if it's a relative path */
  39.150 +        char *path;
  39.151 +        FILE *fp;
  39.152 +
  39.153 +        path = SDL_stack_alloc(char, PATH_MAX);
  39.154 +        if (path) {
  39.155 +            SDL_snprintf(path, PATH_MAX, "%s/%s",
  39.156 +                         SDL_AndroidGetInternalStoragePath(), file);
  39.157 +            fp = fopen(path, mode);
  39.158 +            SDL_stack_free(path);
  39.159 +            if (fp) {
  39.160 +                return SDL_RWFromFP(fp, 1);
  39.161 +            }
  39.162 +        }
  39.163 +    }
  39.164 +#endif /* HAVE_STDIO_H */
  39.165 +
  39.166 +    /* Try to open the file from the asset system */
  39.167      rwops = SDL_AllocRW();
  39.168      if (!rwops)
  39.169          return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
  39.170 @@ -434,6 +508,7 @@
  39.171          SDL_FreeRW(rwops);
  39.172          return NULL;
  39.173      }
  39.174 +    rwops->size = Android_JNI_FileSize;
  39.175      rwops->seek = Android_JNI_FileSeek;
  39.176      rwops->read = Android_JNI_FileRead;
  39.177      rwops->write = Android_JNI_FileWrite;
  39.178 @@ -447,6 +522,7 @@
  39.179          SDL_FreeRW(rwops);
  39.180          return NULL;
  39.181      }
  39.182 +    rwops->size = windows_file_size;
  39.183      rwops->seek = windows_file_seek;
  39.184      rwops->read = windows_file_read;
  39.185      rwops->write = windows_file_write;
  39.186 @@ -490,6 +566,7 @@
  39.187  
  39.188      rwops = SDL_AllocRW();
  39.189      if (rwops != NULL) {
  39.190 +        rwops->size = stdio_size;
  39.191          rwops->seek = stdio_seek;
  39.192          rwops->read = stdio_read;
  39.193          rwops->write = stdio_write;
  39.194 @@ -515,6 +592,7 @@
  39.195  
  39.196      rwops = SDL_AllocRW();
  39.197      if (rwops != NULL) {
  39.198 +        rwops->size = mem_size;
  39.199          rwops->seek = mem_seek;
  39.200          rwops->read = mem_read;
  39.201          rwops->write = mem_write;
  39.202 @@ -533,6 +611,7 @@
  39.203  
  39.204      rwops = SDL_AllocRW();
  39.205      if (rwops != NULL) {
  39.206 +        rwops->size = mem_size;
  39.207          rwops->seek = mem_seek;
  39.208          rwops->read = mem_read;
  39.209          rwops->write = mem_writeconst;
    40.1 --- a/src/stdlib/SDL_iconv.c	Sun Nov 04 09:02:58 2012 -0500
    40.2 +++ b/src/stdlib/SDL_iconv.c	Sun Nov 04 09:46:59 2012 -0500
    40.3 @@ -87,15 +87,21 @@
    40.4      ENCODING_UTF32,             /* Needs byte order marker */
    40.5      ENCODING_UTF32BE,
    40.6      ENCODING_UTF32LE,
    40.7 -    ENCODING_UCS2,              /* Native byte order assumed */
    40.8 -    ENCODING_UCS4,              /* Native byte order assumed */
    40.9 +    ENCODING_UCS2BE,
   40.10 +    ENCODING_UCS2LE,
   40.11 +    ENCODING_UCS4BE,
   40.12 +    ENCODING_UCS4LE,
   40.13  };
   40.14  #if SDL_BYTEORDER == SDL_BIG_ENDIAN
   40.15  #define ENCODING_UTF16NATIVE	ENCODING_UTF16BE
   40.16  #define ENCODING_UTF32NATIVE	ENCODING_UTF32BE
   40.17 +#define ENCODING_UCS2NATIVE     ENCODING_UCS2BE
   40.18 +#define ENCODING_UCS4NATIVE     ENCODING_UCS4BE
   40.19  #else
   40.20  #define ENCODING_UTF16NATIVE	ENCODING_UTF16LE
   40.21  #define ENCODING_UTF32NATIVE	ENCODING_UTF32LE
   40.22 +#define ENCODING_UCS2NATIVE     ENCODING_UCS2LE
   40.23 +#define ENCODING_UCS4NATIVE     ENCODING_UCS4LE
   40.24  #endif
   40.25  
   40.26  struct _SDL_iconv_t
   40.27 @@ -128,10 +134,16 @@
   40.28      { "UTF-32BE", ENCODING_UTF32BE },
   40.29      { "UTF32LE", ENCODING_UTF32LE },
   40.30      { "UTF-32LE", ENCODING_UTF32LE },
   40.31 -    { "UCS2", ENCODING_UCS2 },
   40.32 -    { "UCS-2", ENCODING_UCS2 },
   40.33 -    { "UCS4", ENCODING_UCS4 },
   40.34 -    { "UCS-4", ENCODING_UCS4 },
   40.35 +    { "UCS2", ENCODING_UCS2BE },
   40.36 +    { "UCS-2", ENCODING_UCS2BE },
   40.37 +    { "UCS-2LE", ENCODING_UCS2LE },
   40.38 +    { "UCS-2BE", ENCODING_UCS2BE },
   40.39 +    { "UCS-2-INTERNAL", ENCODING_UCS2NATIVE },
   40.40 +    { "UCS4", ENCODING_UCS4BE },
   40.41 +    { "UCS-4", ENCODING_UCS4BE },
   40.42 +    { "UCS-4LE", ENCODING_UCS4LE },
   40.43 +    { "UCS-4BE", ENCODING_UCS4BE },
   40.44 +    { "UCS-4-INTERNAL", ENCODING_UCS4NATIVE },
   40.45  /* *INDENT-ON* */
   40.46  };
   40.47  
   40.48 @@ -518,6 +530,29 @@
   40.49                        (Uint32) (W2 & 0x3FF)) + 0x10000;
   40.50              }
   40.51              break;
   40.52 +        case ENCODING_UCS2LE:
   40.53 +            {
   40.54 +                Uint8 *p = (Uint8 *) src;
   40.55 +                if (srclen < 2) {
   40.56 +                    return SDL_ICONV_EINVAL;
   40.57 +                }
   40.58 +                ch = ((Uint32) p[1] << 8) | (Uint32) p[0];
   40.59 +                src += 2;
   40.60 +                srclen -= 2;
   40.61 +            }
   40.62 +            break;
   40.63 +        case ENCODING_UCS2BE:
   40.64 +            {
   40.65 +                Uint8 *p = (Uint8 *) src;
   40.66 +                if (srclen < 2) {
   40.67 +                    return SDL_ICONV_EINVAL;
   40.68 +                }
   40.69 +                ch = ((Uint32) p[0] << 8) | (Uint32) p[1];
   40.70 +                src += 2;
   40.71 +                srclen -= 2;
   40.72 +            }
   40.73 +            break;
   40.74 +        case ENCODING_UCS4BE:
   40.75          case ENCODING_UTF32BE:
   40.76              {
   40.77                  Uint8 *p = (Uint8 *) src;
   40.78 @@ -531,6 +566,7 @@
   40.79                  srclen -= 4;
   40.80              }
   40.81              break;
   40.82 +        case ENCODING_UCS4LE:
   40.83          case ENCODING_UTF32LE:
   40.84              {
   40.85                  Uint8 *p = (Uint8 *) src;
   40.86 @@ -544,28 +580,6 @@
   40.87                  srclen -= 4;
   40.88              }
   40.89              break;
   40.90 -        case ENCODING_UCS2:
   40.91 -            {
   40.92 -                Uint16 *p = (Uint16 *) src;
   40.93 -                if (srclen < 2) {
   40.94 -                    return SDL_ICONV_EINVAL;
   40.95 -                }
   40.96 -                ch = *p;
   40.97 -                src += 2;
   40.98 -                srclen -= 2;
   40.99 -            }
  40.100 -            break;
  40.101 -        case ENCODING_UCS4:
  40.102 -            {
  40.103 -                Uint32 *p = (Uint32 *) src;
  40.104 -                if (srclen < 4) {
  40.105 -                    return SDL_ICONV_EINVAL;
  40.106 -                }
  40.107 -                ch = *p;
  40.108 -                src += 4;
  40.109 -                srclen -= 4;
  40.110 -            }
  40.111 -            break;
  40.112          }
  40.113  
  40.114          /* Encode a character */
  40.115 @@ -728,12 +742,46 @@
  40.116                  }
  40.117              }
  40.118              break;
  40.119 -        case ENCODING_UTF32BE:
  40.120 +        case ENCODING_UCS2BE:
  40.121              {
  40.122                  Uint8 *p = (Uint8 *) dst;
  40.123 -                if (ch > 0x10FFFF) {
  40.124 +                if (ch > 0xFFFF) {
  40.125                      ch = UNKNOWN_UNICODE;
  40.126                  }
  40.127 +                if (dstlen < 2) {
  40.128 +                    return SDL_ICONV_E2BIG;
  40.129 +                }
  40.130 +                p[0] = (Uint8) (ch >> 8);
  40.131 +                p[1] = (Uint8) ch;
  40.132 +                dst += 2;
  40.133 +                dstlen -= 2;
  40.134 +            }
  40.135 +            break;
  40.136 +        case ENCODING_UCS2LE:
  40.137 +            {
  40.138 +                Uint8 *p = (Uint8 *) dst;
  40.139 +                if (ch > 0xFFFF) {
  40.140 +                    ch = UNKNOWN_UNICODE;
  40.141 +                }
  40.142 +                if (dstlen < 2) {
  40.143 +                    return SDL_ICONV_E2BIG;
  40.144 +                }
  40.145 +                p[1] = (Uint8) (ch >> 8);
  40.146 +                p[0] = (Uint8) ch;
  40.147 +                dst += 2;
  40.148 +                dstlen -= 2;
  40.149 +            }
  40.150 +            break;
  40.151 +        case ENCODING_UTF32BE:
  40.152 +            if (ch > 0x10FFFF) {
  40.153 +                ch = UNKNOWN_UNICODE;
  40.154 +            }
  40.155 +        case ENCODING_UCS4BE:
  40.156 +            if (ch > 0x7FFFFFFF) {
  40.157 +                ch = UNKNOWN_UNICODE;
  40.158 +            }
  40.159 +            {
  40.160 +                Uint8 *p = (Uint8 *) dst;
  40.161                  if (dstlen < 4) {
  40.162                      return SDL_ICONV_E2BIG;
  40.163                  }
  40.164 @@ -746,11 +794,15 @@
  40.165              }
  40.166              break;
  40.167          case ENCODING_UTF32LE:
  40.168 +            if (ch > 0x10FFFF) {
  40.169 +                ch = UNKNOWN_UNICODE;
  40.170 +            }
  40.171 +        case ENCODING_UCS4LE:
  40.172 +            if (ch > 0x7FFFFFFF) {
  40.173 +                ch = UNKNOWN_UNICODE;
  40.174 +            }
  40.175              {
  40.176                  Uint8 *p = (Uint8 *) dst;
  40.177 -                if (ch > 0x10FFFF) {
  40.178 -                    ch = UNKNOWN_UNICODE;
  40.179 -                }
  40.180                  if (dstlen < 4) {
  40.181                      return SDL_ICONV_E2BIG;
  40.182                  }
  40.183 @@ -762,34 +814,6 @@
  40.184                  dstlen -= 4;
  40.185              }
  40.186              break;
  40.187 -        case ENCODING_UCS2:
  40.188 -            {
  40.189 -                Uint16 *p = (Uint16 *) dst;
  40.190 -                if (ch > 0xFFFF) {
  40.191 -                    ch = UNKNOWN_UNICODE;
  40.192 -                }
  40.193 -                if (dstlen < 2) {
  40.194 -                    return SDL_ICONV_E2BIG;
  40.195 -                }
  40.196 -                *p = (Uint16) ch;
  40.197 -                dst += 2;
  40.198 -                dstlen -= 2;
  40.199 -            }
  40.200 -            break;
  40.201 -        case ENCODING_UCS4:
  40.202 -            {
  40.203 -                Uint32 *p = (Uint32 *) dst;
  40.204 -                if (ch > 0x7FFFFFFF) {
  40.205 -                    ch = UNKNOWN_UNICODE;
  40.206 -                }
  40.207 -                if (dstlen < 4) {
  40.208 -                    return SDL_ICONV_E2BIG;
  40.209 -                }
  40.210 -                *p = ch;
  40.211 -                dst += 4;
  40.212 -                dstlen -= 4;
  40.213 -            }
  40.214 -            break;
  40.215          }
  40.216  
  40.217          /* Update state */
    41.1 --- a/src/thread/pthread/SDL_systhread.c	Sun Nov 04 09:02:58 2012 -0500
    41.2 +++ b/src/thread/pthread/SDL_systhread.c	Sun Nov 04 09:46:59 2012 -0500
    41.3 @@ -28,12 +28,19 @@
    41.4  #endif
    41.5  
    41.6  #include <signal.h>
    41.7 +
    41.8  #ifdef __LINUX__
    41.9  #include <sys/time.h>
   41.10  #include <sys/resource.h>
   41.11  #include <sys/syscall.h>
   41.12  #include <unistd.h>
   41.13 -extern int pthread_setname_np (pthread_t __target_thread, __const char *__name) __THROW __nonnull ((2));
   41.14 +#endif // __LINUX__
   41.15 +
   41.16 +#if defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__)
   41.17 +#include <dlfcn.h>
   41.18 +#ifndef RTLD_DEFAULT
   41.19 +#define RTLD_DEFAULT NULL
   41.20 +#endif
   41.21  #endif
   41.22  
   41.23  #include "SDL_platform.h"
   41.24 @@ -44,6 +51,8 @@
   41.25  #include "../../core/android/SDL_android.h"
   41.26  #endif
   41.27  
   41.28 +#include "SDL_assert.h"
   41.29 +
   41.30  /* List of signals to mask in the subthreads */
   41.31  static const int sig_list[] = {
   41.32      SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
   41.33 @@ -61,11 +70,31 @@
   41.34      return NULL;
   41.35  }
   41.36  
   41.37 +#if defined(__MACOSX__) || defined(__IPHONEOS__)
   41.38 +static SDL_bool checked_setname = SDL_FALSE;
   41.39 +static int (*ppthread_setname_np)(const char*) = NULL;
   41.40 +#elif defined(__LINUX__)
   41.41 +static SDL_bool checked_setname = SDL_FALSE;
   41.42 +static int (*ppthread_setname_np)(pthread_t, const char*) = NULL;
   41.43 +#endif
   41.44  int
   41.45  SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
   41.46  {
   41.47      pthread_attr_t type;
   41.48  
   41.49 +    /* do this here before any threads exist, so there's no race condition. */
   41.50 +    #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
   41.51 +    if (!checked_setname) {
   41.52 +        void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
   41.53 +        #if defined(__MACOSX__) || defined(__IPHONEOS__)
   41.54 +        ppthread_setname_np = (int(*)(const char*)) fn;
   41.55 +        #elif defined(__LINUX__)
   41.56 +        ppthread_setname_np = (int(*)(pthread_t, const char*)) fn;
   41.57 +        #endif
   41.58 +        checked_setname = SDL_TRUE;
   41.59 +    }
   41.60 +    #endif
   41.61 +
   41.62      /* Set the thread attributes */
   41.63      if (pthread_attr_init(&type) != 0) {
   41.64          SDL_SetError("Couldn't initialize pthread attributes");
   41.65 @@ -89,14 +118,20 @@
   41.66      sigset_t mask;
   41.67  
   41.68      if (name != NULL) {
   41.69 -#if ( (__MACOSX__ && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \
   41.70 -      (__IPHONEOS__ && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 30200)) )
   41.71 -        if (pthread_setname_np != NULL) { pthread_setname_np(name); }
   41.72 -#elif HAVE_PTHREAD_SETNAME_NP
   41.73 -        pthread_setname_np(pthread_self(), name);
   41.74 -#elif HAVE_PTHREAD_SET_NAME_NP
   41.75 -        pthread_set_name_np(pthread_self(), name);
   41.76 -#endif
   41.77 +        #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
   41.78 +        SDL_assert(checked_setname);
   41.79 +        if (ppthread_setname_np != NULL) {
   41.80 +            #if defined(__MACOSX__) || defined(__IPHONEOS__)
   41.81 +            ppthread_setname_np(name);
   41.82 +            #elif defined(__LINUX__)
   41.83 +            ppthread_setname_np(pthread_self(), name);
   41.84 +            #endif
   41.85 +        }
   41.86 +        #elif HAVE_PTHREAD_SETNAME_NP
   41.87 +            pthread_setname_np(pthread_self(), name);
   41.88 +        #elif HAVE_PTHREAD_SET_NAME_NP
   41.89 +            pthread_set_name_np(pthread_self(), name);
   41.90 +        #endif
   41.91      }
   41.92  
   41.93      /* Mask asynchronous signals for this thread */
    42.1 --- a/src/video/SDL_sysvideo.h	Sun Nov 04 09:02:58 2012 -0500
    42.2 +++ b/src/video/SDL_sysvideo.h	Sun Nov 04 09:46:59 2012 -0500
    42.3 @@ -23,6 +23,7 @@
    42.4  #ifndef _SDL_sysvideo_h
    42.5  #define _SDL_sysvideo_h
    42.6  
    42.7 +#include "SDL_messagebox.h"
    42.8  #include "SDL_shape.h"
    42.9  
   42.10  /* The SDL video driver */
   42.11 @@ -246,6 +247,9 @@
   42.12      char * (*GetClipboardText) (_THIS);
   42.13      SDL_bool (*HasClipboardText) (_THIS);
   42.14  
   42.15 +    /* MessageBox */
   42.16 +    int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
   42.17 +
   42.18      /* * * */
   42.19      /* Data common to all drivers */
   42.20      SDL_bool suspend_screensaver;
    43.1 --- a/src/video/SDL_video.c	Sun Nov 04 09:02:58 2012 -0500
    43.2 +++ b/src/video/SDL_video.c	Sun Nov 04 09:46:59 2012 -0500
    43.3 @@ -1171,7 +1171,9 @@
    43.4              SDL_SetError("No OpenGL support in video driver");
    43.5              return NULL;
    43.6          }
    43.7 -        SDL_GL_LoadLibrary(NULL);
    43.8 +        if (SDL_GL_LoadLibrary(NULL) < 0) {
    43.9 +            return NULL;
   43.10 +        }
   43.11      }
   43.12      window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
   43.13      window->magic = &_this->window_magic;
   43.14 @@ -2842,4 +2844,79 @@
   43.15      return SDL_FALSE;
   43.16  }
   43.17  
   43.18 +#if SDL_VIDEO_DRIVER_WINDOWS
   43.19 +#include "windows/SDL_windowsmessagebox.h"
   43.20 +#endif
   43.21 +#if SDL_VIDEO_DRIVER_COCOA
   43.22 +#include "cocoa/SDL_cocoamessagebox.h"
   43.23 +#endif
   43.24 +#if SDL_VIDEO_DRIVER_UIKIT
   43.25 +#include "uikit/SDL_uikitmessagebox.h"
   43.26 +#endif
   43.27 +#if SDL_VIDEO_DRIVER_X11
   43.28 +#include "x11/SDL_x11messagebox.h"
   43.29 +#endif
   43.30 +
   43.31 +int
   43.32 +SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   43.33 +{
   43.34 +    int dummybutton;
   43.35 +
   43.36 +    if (!buttonid) {
   43.37 +        buttonid = &dummybutton;
   43.38 +    }
   43.39 +    if (_this && _this->ShowMessageBox) {
   43.40 +        if (_this->ShowMessageBox(_this, messageboxdata, buttonid) == 0) {
   43.41 +            return 0;
   43.42 +        }
   43.43 +    }
   43.44 +
   43.45 +    /* It's completely fine to call this function before video is initialized */
   43.46 +#if SDL_VIDEO_DRIVER_WINDOWS
   43.47 +    if (WIN_ShowMessageBox(messageboxdata, buttonid) == 0) {
   43.48 +        return 0;
   43.49 +    }
   43.50 +#endif
   43.51 +#if SDL_VIDEO_DRIVER_COCOA
   43.52 +    if (Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) {
   43.53 +        return 0;
   43.54 +    }
   43.55 +#endif
   43.56 +#if SDL_VIDEO_DRIVER_UIKIT
   43.57 +    if (UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) {
   43.58 +        return 0;
   43.59 +    }
   43.60 +#endif
   43.61 +#if SDL_VIDEO_DRIVER_X11
   43.62 +    if (X11_ShowMessageBox(messageboxdata, buttonid) == 0) {
   43.63 +        return 0;
   43.64 +    }
   43.65 +#endif
   43.66 +
   43.67 +    SDL_SetError("No message system available");
   43.68 +    return -1;
   43.69 +}
   43.70 +
   43.71 +int
   43.72 +SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
   43.73 +{
   43.74 +    SDL_MessageBoxData data;
   43.75 +    SDL_MessageBoxButtonData button;
   43.76 +
   43.77 +    SDL_zero(data);
   43.78 +    data.flags = flags;
   43.79 +    data.title = title;
   43.80 +    data.message = message;
   43.81 +    data.numbuttons = 1;
   43.82 +    data.buttons = &button;
   43.83 +    data.window = window;
   43.84 +
   43.85 +    SDL_zero(button);
   43.86 +    button.flags |= SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
   43.87 +    button.flags |= SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
   43.88 +    button.text = "OK";
   43.89 +
   43.90 +    return SDL_ShowMessageBox(&data, NULL);
   43.91 +}
   43.92 +
   43.93  /* vi: set ts=4 sw=4 expandtab: */
    44.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Sun Nov 04 09:02:58 2012 -0500
    44.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Nov 04 09:46:59 2012 -0500
    44.3 @@ -156,6 +156,7 @@
    44.4  void
    44.5  Cocoa_RegisterApp(void)
    44.6  {
    44.7 +    /* This can get called more than once! Be careful what you initialize! */
    44.8      ProcessSerialNumber psn;
    44.9      NSAutoreleasePool *pool;
   44.10  
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.h	Sun Nov 04 09:46:59 2012 -0500
    45.3 @@ -0,0 +1,29 @@
    45.4 +/*
    45.5 +  Simple DirectMedia Layer
    45.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    45.7 +
    45.8 +  This software is provided 'as-is', without any express or implied
    45.9 +  warranty.  In no event will the authors be held liable for any damages
   45.10 +  arising from the use of this software.
   45.11 +
   45.12 +  Permission is granted to anyone to use this software for any purpose,
   45.13 +  including commercial applications, and to alter it and redistribute it
   45.14 +  freely, subject to the following restrictions:
   45.15 +
   45.16 +  1. The origin of this software must not be misrepresented; you must not
   45.17 +     claim that you wrote the original software. If you use this software
   45.18 +     in a product, an acknowledgment in the product documentation would be
   45.19 +     appreciated but is not required.
   45.20 +  2. Altered source versions must be plainly marked as such, and must not be
   45.21 +     misrepresented as being the original software.
   45.22 +  3. This notice may not be removed or altered from any source distribution.
   45.23 +*/
   45.24 +#include "SDL_config.h"
   45.25 +
   45.26 +#if SDL_VIDEO_DRIVER_COCOA
   45.27 +
   45.28 +extern int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   45.29 +
   45.30 +#endif /* SDL_VIDEO_DRIVER_COCOA */
   45.31 +
   45.32 +/* vi: set ts=4 sw=4 expandtab: */
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.m	Sun Nov 04 09:46:59 2012 -0500
    46.3 @@ -0,0 +1,81 @@
    46.4 +/*
    46.5 +  Simple DirectMedia Layer
    46.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    46.7 +
    46.8 +  This software is provided 'as-is', without any express or implied
    46.9 +  warranty.  In no event will the authors be held liable for any damages
   46.10 +  arising from the use of this software.
   46.11 +
   46.12 +  Permission is granted to anyone to use this software for any purpose,
   46.13 +  including commercial applications, and to alter it and redistribute it
   46.14 +  freely, subject to the following restrictions:
   46.15 +
   46.16 +  1. The origin of this software must not be misrepresented; you must not
   46.17 +     claim that you wrote the original software. If you use this software
   46.18 +     in a product, an acknowledgment in the product documentation would be
   46.19 +     appreciated but is not required.
   46.20 +  2. Altered source versions must be plainly marked as such, and must not be
   46.21 +     misrepresented as being the original software.
   46.22 +  3. This notice may not be removed or altered from any source distribution.
   46.23 +*/
   46.24 +#include "SDL_config.h"
   46.25 +
   46.26 +#if SDL_VIDEO_DRIVER_COCOA
   46.27 +
   46.28 +#if defined(__APPLE__) && defined(__POWERPC__)
   46.29 +#include <altivec.h>
   46.30 +#undef bool
   46.31 +#undef vector
   46.32 +#undef pixel
   46.33 +#endif
   46.34 +
   46.35 +#include "SDL_messagebox.h"
   46.36 +#include "SDL_cocoavideo.h"
   46.37 +
   46.38 +
   46.39 +/* Display a Cocoa message box */
   46.40 +int
   46.41 +Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   46.42 +{
   46.43 +    Cocoa_RegisterApp();
   46.44 +
   46.45 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   46.46 +
   46.47 +    NSAlert* alert = [[NSAlert alloc] init];
   46.48 +
   46.49 +    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
   46.50 +        [alert setAlertStyle:NSCriticalAlertStyle];
   46.51 +    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
   46.52 +        [alert setAlertStyle:NSWarningAlertStyle];
   46.53 +    } else {
   46.54 +        [alert setAlertStyle:NSInformationalAlertStyle];
   46.55 +    }
   46.56 +
   46.57 +    [alert setMessageText:[[NSString alloc] initWithUTF8String:messageboxdata->title]];
   46.58 +    [alert setInformativeText:[[NSString alloc] initWithUTF8String:messageboxdata->message]];
   46.59 +
   46.60 +    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
   46.61 +    int i;
   46.62 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
   46.63 +        NSButton *button = [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
   46.64 +        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
   46.65 +            [button setKeyEquivalent:@"\r"];
   46.66 +        } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
   46.67 +            [button setKeyEquivalent:@"\033"];
   46.68 +        } else {
   46.69 +            [button setKeyEquivalent:@""];
   46.70 +        }
   46.71 +    }
   46.72 +
   46.73 +    NSInteger clicked = [alert runModal];
   46.74 +    clicked -= NSAlertFirstButtonReturn;
   46.75 +    *buttonid = buttons[clicked].buttonid;
   46.76 +
   46.77 +    [pool release];
   46.78 +
   46.79 +    return 0;
   46.80 +}
   46.81 +
   46.82 +#endif /* SDL_VIDEO_DRIVER_COCOA */
   46.83 +
   46.84 +/* vi: set ts=4 sw=4 expandtab: */
    47.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Sun Nov 04 09:02:58 2012 -0500
    47.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Sun Nov 04 09:46:59 2012 -0500
    47.3 @@ -26,6 +26,7 @@
    47.4  #include <altivec.h>
    47.5  #undef bool
    47.6  #undef vector
    47.7 +#undef pixel
    47.8  #endif
    47.9  
   47.10  #include "SDL.h"
   47.11 @@ -218,6 +219,22 @@
   47.12  }
   47.13  
   47.14  /*
   47.15 + * Mac OS X log support.
   47.16 + *
   47.17 + * This doesn't really have aything to do with the interfaces of the SDL video
   47.18 + *  subsystem, but we need to stuff this into an Objective-C source code file.
   47.19 + */
   47.20 +
   47.21 +void SDL_NSLog(const char *text)
   47.22 +{
   47.23 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   47.24 +
   47.25 +    NSLog(@"%@", [[NSString alloc] initWithUTF8String:text]);
   47.26 +
   47.27 +    [pool release];
   47.28 +}
   47.29 +
   47.30 +/*
   47.31   * Mac OS X assertion support.
   47.32   *
   47.33   * This doesn't really have aything to do with the interfaces of the SDL video
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/src/video/uikit/SDL_uikitmessagebox.h	Sun Nov 04 09:46:59 2012 -0500
    48.3 @@ -0,0 +1,29 @@
    48.4 +/*
    48.5 +  Simple DirectMedia Layer
    48.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    48.7 +
    48.8 +  This software is provided 'as-is', without any express or implied
    48.9 +  warranty.  In no event will the authors be held liable for any damages
   48.10 +  arising from the use of this software.
   48.11 +
   48.12 +  Permission is granted to anyone to use this software for any purpose,
   48.13 +  including commercial applications, and to alter it and redistribute it
   48.14 +  freely, subject to the following restrictions:
   48.15 +
   48.16 +  1. The origin of this software must not be misrepresented; you must not
   48.17 +     claim that you wrote the original software. If you use this software
   48.18 +     in a product, an acknowledgment in the product documentation would be
   48.19 +     appreciated but is not required.
   48.20 +  2. Altered source versions must be plainly marked as such, and must not be
   48.21 +     misrepresented as being the original software.
   48.22 +  3. This notice may not be removed or altered from any source distribution.
   48.23 +*/
   48.24 +#include "SDL_config.h"
   48.25 +
   48.26 +#if SDL_VIDEO_DRIVER_UIKIT
   48.27 +
   48.28 +extern int UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   48.29 +
   48.30 +#endif /* SDL_VIDEO_DRIVER_UIKIT */
   48.31 +
   48.32 +/* vi: set ts=4 sw=4 expandtab: */
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/src/video/uikit/SDL_uikitmessagebox.m	Sun Nov 04 09:46:59 2012 -0500
    49.3 @@ -0,0 +1,101 @@
    49.4 +/*
    49.5 +  Simple DirectMedia Layer
    49.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    49.7 +
    49.8 +  This software is provided 'as-is', without any express or implied
    49.9 +  warranty.  In no event will the authors be held liable for any damages
   49.10 +  arising from the use of this software.
   49.11 +
   49.12 +  Permission is granted to anyone to use this software for any purpose,
   49.13 +  including commercial applications, and to alter it and redistribute it
   49.14 +  freely, subject to the following restrictions:
   49.15 +
   49.16 +  1. The origin of this software must not be misrepresented; you must not
   49.17 +     claim that you wrote the original software. If you use this software
   49.18 +     in a product, an acknowledgment in the product documentation would be
   49.19 +     appreciated but is not required.
   49.20 +  2. Altered source versions must be plainly marked as such, and must not be
   49.21 +     misrepresented as being the original software.
   49.22 +  3. This notice may not be removed or altered from any source distribution.
   49.23 +*/
   49.24 +#include "SDL_config.h"
   49.25 +
   49.26 +#if SDL_VIDEO_DRIVER_UIKIT
   49.27 +
   49.28 +#include "SDL.h"
   49.29 +#include "SDL_uikitvideo.h"
   49.30 +
   49.31 +
   49.32 +/* Display a UIKit message box */
   49.33 +
   49.34 +
   49.35 +@interface UIKit_UIAlertViewDelegate : NSObject <UIAlertViewDelegate> {
   49.36 +@private
   49.37 +    int *clickedButtonIndex;
   49.38 +}
   49.39 +
   49.40 +- (id)initWithButtonIndex:(int *)_buttonIndex;
   49.41 +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
   49.42 +
   49.43 +@end
   49.44 +
   49.45 +@implementation UIKit_UIAlertViewDelegate
   49.46 +
   49.47 +- (id)initWithButtonIndex:(int *)buttonIndex
   49.48 +{
   49.49 +    self = [self init];
   49.50 +    if (self == nil) {
   49.51 +        return nil;
   49.52 +    }
   49.53 +    self->clickedButtonIndex = buttonIndex;
   49.54 +    
   49.55 +    return self;
   49.56 +}
   49.57 +
   49.58 +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
   49.59 +{
   49.60 +    *clickedButtonIndex = buttonIndex;
   49.61 +}
   49.62 +
   49.63 +@end // UIKit_UIAlertViewDelegate
   49.64 +
   49.65 +
   49.66 +int
   49.67 +UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
   49.68 +{
   49.69 +    int clicked;
   49.70 +    
   49.71 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   49.72 +
   49.73 +    UIAlertView* alert = [[UIAlertView alloc] init];
   49.74 +
   49.75 +    alert.title = [[NSString alloc] initWithUTF8String:messageboxdata->title];
   49.76 +    alert.message = [[NSString alloc] initWithUTF8String:messageboxdata->message];
   49.77 +    alert.delegate = [[UIKit_UIAlertViewDelegate alloc] initWithButtonIndex:&clicked];
   49.78 +
   49.79 +    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
   49.80 +    int i;
   49.81 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
   49.82 +        [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
   49.83 +    }
   49.84 +
   49.85 +    // Set up for showing the alert
   49.86 +    clicked = messageboxdata->numbuttons;
   49.87 +
   49.88 +    [alert show];
   49.89 +    
   49.90 +    // Run the main event loop until the alert has finished
   49.91 +    // Note that this needs to be done on the main thread
   49.92 +    while (clicked == messageboxdata->numbuttons) {
   49.93 +        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
   49.94 +    }
   49.95 +    *buttonid = messageboxdata->buttons[clicked].buttonid;
   49.96 +
   49.97 +    [pool release];
   49.98 +
   49.99 +    return 0;
  49.100 +}
  49.101 +
  49.102 +#endif /* SDL_VIDEO_DRIVER_UIKIT */
  49.103 +
  49.104 +/* vi: set ts=4 sw=4 expandtab: */
    50.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 09:02:58 2012 -0500
    50.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 09:46:59 2012 -0500
    50.3 @@ -129,6 +129,22 @@
    50.4      UIKit_QuitModes(_this);
    50.5  }
    50.6  
    50.7 +/*
    50.8 + * iOS log support.
    50.9 + *
   50.10 + * This doesn't really have aything to do with the interfaces of the SDL video
   50.11 + *  subsystem, but we need to stuff this into an Objective-C source code file.
   50.12 + */
   50.13 +
   50.14 +void SDL_NSLog(const char *text)
   50.15 +{
   50.16 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   50.17 +
   50.18 +    NSLog(@"%@", [[NSString alloc] initWithUTF8String:text]);
   50.19 +
   50.20 +    [pool release];
   50.21 +}
   50.22 +
   50.23  #endif /* SDL_VIDEO_DRIVER_UIKIT */
   50.24  
   50.25  /* vi: set ts=4 sw=4 expandtab: */
    51.1 --- a/src/video/uikit/SDL_uikitview.h	Sun Nov 04 09:02:58 2012 -0500
    51.2 +++ b/src/video/uikit/SDL_uikitview.h	Sun Nov 04 09:46:59 2012 -0500
    51.3 @@ -22,8 +22,9 @@
    51.4  #import <UIKit/UIKit.h>
    51.5  #import "SDL_uikitviewcontroller.h"
    51.6  
    51.7 +#include "SDL_touch.h"
    51.8 +
    51.9  #define IPHONE_TOUCH_EFFICIENT_DANGEROUS
   51.10 -#define FIXED_MULTITOUCH
   51.11  
   51.12  #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   51.13  #define MAX_SIMULTANEOUS_TOUCHES 5
   51.14 @@ -35,12 +36,11 @@
   51.15  @interface SDL_uikitview : UIView {
   51.16  #endif
   51.17  
   51.18 -#ifdef FIXED_MULTITOUCH
   51.19 -    long touchId;
   51.20 +    SDL_TouchID touchId;
   51.21 +    SDL_FingerID leftFingerDown;
   51.22  #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   51.23      UITouch *finger[MAX_SIMULTANEOUS_TOUCHES];
   51.24  #endif
   51.25 -#endif
   51.26  
   51.27  #if SDL_IPHONE_KEYBOARD
   51.28      UITextField *textField;
    52.1 --- a/src/video/uikit/SDL_uikitview.m	Sun Nov 04 09:02:58 2012 -0500
    52.2 +++ b/src/video/uikit/SDL_uikitview.m	Sun Nov 04 09:46:59 2012 -0500
    52.3 @@ -50,7 +50,6 @@
    52.4      [self initializeKeyboard];
    52.5  #endif
    52.6  
    52.7 -#ifdef FIXED_MULTITOUCH
    52.8      self.multipleTouchEnabled = YES;
    52.9  
   52.10      SDL_Touch touch;
   52.11 @@ -69,9 +68,7 @@
   52.12      touch.pressure_max = 1;
   52.13      touch.native_pressureres = touch.pressure_max - touch.pressure_min;
   52.14  
   52.15 -
   52.16      touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
   52.17 -#endif
   52.18  
   52.19      return self;
   52.20  
   52.21 @@ -102,25 +99,25 @@
   52.22      NSEnumerator *enumerator = [touches objectEnumerator];
   52.23      UITouch *touch = (UITouch*)[enumerator nextObject];
   52.24  
   52.25 -    if (touch) {
   52.26 -        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   52.27 +    while (touch) {
   52.28 +        if (!leftFingerDown) {
   52.29 +            CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   52.30  
   52.31 -        /* send moved event */
   52.32 -        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   52.33 +            /* send moved event */
   52.34 +            SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   52.35  
   52.36 -        /* send mouse down event */
   52.37 -        SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
   52.38 -    }
   52.39 +            /* send mouse down event */
   52.40 +            SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
   52.41  
   52.42 -#ifdef FIXED_MULTITOUCH
   52.43 -    while(touch) {
   52.44 +            leftFingerDown = (SDL_FingerID)touch;
   52.45 +        }
   52.46 +
   52.47          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   52.48 -
   52.49  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   52.50 -        //FIXME: TODO: Using touch as the fingerId is potentially dangerous
   52.51 -        //It is also much more efficient than storing the UITouch pointer
   52.52 -        //and comparing it to the incoming event.
   52.53 -        SDL_SendFingerDown(touchId, (long)touch,
   52.54 +        // FIXME: TODO: Using touch as the fingerId is potentially dangerous
   52.55 +        // It is also much more efficient than storing the UITouch pointer
   52.56 +        // and comparing it to the incoming event.
   52.57 +        SDL_SendFingerDown(touchId, (SDL_FingerID)touch,
   52.58                             SDL_TRUE, locationInView.x, locationInView.y,
   52.59                             1);
   52.60  #else
   52.61 @@ -135,10 +132,8 @@
   52.62              }
   52.63          }
   52.64  #endif
   52.65 -
   52.66          touch = (UITouch*)[enumerator nextObject];
   52.67      }
   52.68 -#endif
   52.69  }
   52.70  
   52.71  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
   52.72 @@ -146,15 +141,14 @@
   52.73      NSEnumerator *enumerator = [touches objectEnumerator];
   52.74      UITouch *touch = (UITouch*)[enumerator nextObject];
   52.75  
   52.76 -    if (touch) {
   52.77 -        /* send mouse up */
   52.78 -        SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
   52.79 -    }
   52.80 +    while(touch) {
   52.81 +        if ((SDL_FingerID)touch == leftFingerDown) {
   52.82 +            /* send mouse up */
   52.83 +            SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
   52.84 +            leftFingerDown = 0;
   52.85 +        }
   52.86  
   52.87 -#ifdef FIXED_MULTITOUCH
   52.88 -    while(touch) {
   52.89          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   52.90 -
   52.91  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   52.92          SDL_SendFingerDown(touchId, (long)touch,
   52.93                             SDL_FALSE, locationInView.x, locationInView.y,
   52.94 @@ -171,10 +165,8 @@
   52.95              }
   52.96          }
   52.97  #endif
   52.98 -
   52.99          touch = (UITouch*)[enumerator nextObject];
  52.100      }
  52.101 -#endif
  52.102  }
  52.103  
  52.104  - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
  52.105 @@ -192,17 +184,15 @@
  52.106      NSEnumerator *enumerator = [touches objectEnumerator];
  52.107      UITouch *touch = (UITouch*)[enumerator nextObject];
  52.108  
  52.109 -    if (touch) {
  52.110 -        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
  52.111 +    while (touch) {
  52.112 +        if ((SDL_FingerID)touch == leftFingerDown) {
  52.113 +            CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
  52.114  
  52.115 -        /* send moved event */
  52.116 -        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
  52.117 -    }
  52.118 +            /* send moved event */
  52.119 +            SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
  52.120 +        }
  52.121  
  52.122 -#ifdef FIXED_MULTITOUCH
  52.123 -    while(touch) {
  52.124          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
  52.125 -
  52.126  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
  52.127          SDL_SendTouchMotion(touchId, (long)touch,
  52.128                              SDL_FALSE, locationInView.x, locationInView.y,
  52.129 @@ -218,10 +208,8 @@
  52.130              }
  52.131          }
  52.132  #endif
  52.133 -
  52.134          touch = (UITouch*)[enumerator nextObject];
  52.135      }
  52.136 -#endif
  52.137  }
  52.138  
  52.139  /*
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/src/video/windows/SDL_windowsmessagebox.c	Sun Nov 04 09:46:59 2012 -0500
    53.3 @@ -0,0 +1,282 @@
    53.4 +/*
    53.5 +  Simple DirectMedia Layer
    53.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    53.7 +
    53.8 +  This software is provided 'as-is', without any express or implied
    53.9 +  warranty.  In no event will the authors be held liable for any damages
   53.10 +  arising from the use of this software.
   53.11 +
   53.12 +  Permission is granted to anyone to use this software for any purpose,
   53.13 +  including commercial applications, and to alter it and redistribute it
   53.14 +  freely, subject to the following restrictions:
   53.15 +
   53.16 +  1. The origin of this software must not be misrepresented; you must not
   53.17 +     claim that you wrote the original software. If you use this software
   53.18 +     in a product, an acknowledgment in the product documentation would be
   53.19 +     appreciated but is not required.
   53.20 +  2. Altered source versions must be plainly marked as such, and must not be
   53.21 +     misrepresented as being the original software.
   53.22 +  3. This notice may not be removed or altered from any source distribution.
   53.23 +*/
   53.24 +#include "SDL_config.h"
   53.25 +
   53.26 +#if SDL_VIDEO_DRIVER_WINDOWS
   53.27 +
   53.28 +#include "SDL.h"
   53.29 +#include "SDL_windowsvideo.h"
   53.30 +
   53.31 +
   53.32 +/* Display a Windows message box */
   53.33 +
   53.34 +typedef struct
   53.35 +{
   53.36 +    LPDLGTEMPLATE lpDialog;
   53.37 +    Uint8 *data;
   53.38 +    size_t size;
   53.39 +    size_t used;
   53.40 +} WIN_DialogData;
   53.41 +
   53.42 +
   53.43 +static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
   53.44 +{
   53.45 +    switch ( iMessage ) {
   53.46 +    case WM_COMMAND:
   53.47 +        /* Return the ID of the button that was pushed */
   53.48 +		EndDialog(hDlg, LOWORD(wParam));
   53.49 +        return TRUE;
   53.50 +
   53.51 +    default:
   53.52 +        break;
   53.53 +    }
   53.54 +    return FALSE;
   53.55 +}
   53.56 +
   53.57 +static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space)
   53.58 +{
   53.59 +    size_t size = dialog->size;
   53.60 +
   53.61 +    if (size == 0) {
   53.62 +        size = space;
   53.63 +    } else {
   53.64 +        while ((dialog->used + space) > size) {
   53.65 +            size *= 2;
   53.66 +        }
   53.67 +    }
   53.68 +    if (size > dialog->size) {
   53.69 +        void *data = SDL_realloc(dialog->data, size);
   53.70 +        if (!data) {
   53.71 +            SDL_OutOfMemory();
   53.72 +            return SDL_FALSE;
   53.73 +        }
   53.74 +        dialog->data = data;
   53.75 +        dialog->size = size;
   53.76 +        dialog->lpDialog = (LPDLGTEMPLATE)dialog->data;
   53.77 +    }
   53.78 +    return SDL_TRUE;
   53.79 +}
   53.80 + 
   53.81 +static SDL_bool AlignDialogData(WIN_DialogData *dialog, size_t size)
   53.82 +{
   53.83 +    size_t padding = (dialog->used % size);
   53.84 +
   53.85 +    if (!ExpandDialogSpace(dialog, padding)) {
   53.86 +        return SDL_FALSE;
   53.87 +    }
   53.88 +
   53.89 +    dialog->used += padding;
   53.90 +
   53.91 +    return SDL_TRUE;
   53.92 +}
   53.93 +
   53.94 +static SDL_bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t size)
   53.95 +{
   53.96 +    if (!ExpandDialogSpace(dialog, size)) {
   53.97 +        return SDL_FALSE;
   53.98 +    }
   53.99 +
  53.100 +    SDL_memcpy(dialog->data+dialog->used, data, size);
  53.101 +    dialog->used += size;
  53.102 +
  53.103 +    return SDL_TRUE;
  53.104 +}
  53.105 +
  53.106 +static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string)
  53.107 +{
  53.108 +    WCHAR *wstring;
  53.109 +    WCHAR *p;
  53.110 +    size_t count;
  53.111 +    SDL_bool status;
  53.112 +
  53.113 +    if (!string) {
  53.114 +        string = "";
  53.115 +    }
  53.116 +
  53.117 +    wstring = WIN_UTF8ToString(string);
  53.118 +    if (!wstring) {
  53.119 +        return SDL_FALSE;
  53.120 +    }
  53.121 +
  53.122 +    /* Find out how many characters we have, including null terminator */
  53.123 +    count = 0;
  53.124 +    for (p = wstring; *p; ++p) {
  53.125 +        ++count;
  53.126 +    }
  53.127 +    ++count;
  53.128 +
  53.129 +    status = AddDialogData(dialog, wstring, count*sizeof(WCHAR));
  53.130 +    SDL_free(wstring);
  53.131 +    return status;
  53.132 +}
  53.133 +
  53.134 +static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption)
  53.135 +{
  53.136 +    DLGITEMTEMPLATE item;
  53.137 +    WORD marker = 0xFFFF;
  53.138 +    WORD extraData = 0;
  53.139 +
  53.140 +    SDL_zero(item);
  53.141 +    item.style = style;
  53.142 +    item.dwExtendedStyle = exStyle;
  53.143 +    item.x = x;
  53.144 +    item.y = y;
  53.145 +    item.cx = w;
  53.146 +    item.cy = h;
  53.147 +    item.id = id;
  53.148 +
  53.149 +    if (!AlignDialogData(dialog, sizeof(DWORD))) {
  53.150 +        return SDL_FALSE;
  53.151 +    }
  53.152 +    if (!AddDialogData(dialog, &item, sizeof(item))) {
  53.153 +        return SDL_FALSE;
  53.154 +    }
  53.155 +    if (!AddDialogData(dialog, &marker, sizeof(marker))) {
  53.156 +        return SDL_FALSE;
  53.157 +    }
  53.158 +    if (!AddDialogData(dialog, &type, sizeof(type))) {
  53.159 +        return SDL_FALSE;
  53.160 +    }
  53.161 +    if (!AddDialogString(dialog, caption)) {
  53.162 +        return SDL_FALSE;
  53.163 +    }
  53.164 +    if (!AddDialogData(dialog, &extraData, sizeof(extraData))) {
  53.165 +        return SDL_FALSE;
  53.166 +    }
  53.167 +    ++dialog->lpDialog->cdit;
  53.168 +
  53.169 +    return SDL_TRUE;
  53.170 +}
  53.171 +
  53.172 +static SDL_bool AddDialogStatic(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text)
  53.173 +{
  53.174 +    DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX;
  53.175 +    return AddDialogControl(dialog, 0x0082, style, 0, x, y, w, h, -1, text);
  53.176 +}
  53.177 +
  53.178 +static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, SDL_bool isDefault)
  53.179 +{
  53.180 +    DWORD style = WS_VISIBLE | WS_CHILD;
  53.181 +    if (isDefault) {
  53.182 +        style |= BS_DEFPUSHBUTTON;
  53.183 +    } else {
  53.184 +        style |= BS_PUSHBUTTON;
  53.185 +    }
  53.186 +    return AddDialogControl(dialog, 0x0080, style, 0, x, y, w, h, id, text);
  53.187 +}
  53.188 +
  53.189 +static void FreeDialogData(WIN_DialogData *dialog)
  53.190 +{
  53.191 +    if (dialog->data) {
  53.192 +        SDL_free(dialog->data);
  53.193 +    }
  53.194 +    SDL_free(dialog);
  53.195 +}
  53.196 +
  53.197 +static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
  53.198 +{
  53.199 +    WIN_DialogData *dialog;
  53.200 +    DLGTEMPLATE dialogTemplate;
  53.201 +
  53.202 +    SDL_zero(dialogTemplate);
  53.203 +    dialogTemplate.style = (WS_CAPTION | DS_CENTER);
  53.204 +    dialogTemplate.x = 0;
  53.205 +    dialogTemplate.y = 0;
  53.206 +    dialogTemplate.cx = w;
  53.207 +    dialogTemplate.cy = h;
  53.208 +
  53.209 +    dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog));
  53.210 +    if (!dialog) {
  53.211 +        return NULL;
  53.212 +    }
  53.213 +
  53.214 +    if (!AddDialogData(dialog, &dialogTemplate, sizeof(dialogTemplate))) {
  53.215 +        FreeDialogData(dialog);
  53.216 +        return NULL;
  53.217 +    }
  53.218 +
  53.219 +    /* There is no menu or special class */
  53.220 +    if (!AddDialogString(dialog, "") || !AddDialogString(dialog, "")) {
  53.221 +        FreeDialogData(dialog);
  53.222 +        return NULL;
  53.223 +    }
  53.224 +
  53.225 +    if (!AddDialogString(dialog, caption)) {
  53.226 +        FreeDialogData(dialog);
  53.227 +        return NULL;
  53.228 +    }
  53.229 +
  53.230 +    return dialog;
  53.231 +}
  53.232 +
  53.233 +int
  53.234 +WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
  53.235 +{
  53.236 +    WIN_DialogData *dialog;
  53.237 +    int i, x, y, w, h, gap, which;
  53.238 +    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
  53.239 + 
  53.240 +    /* FIXME: Need a better algorithm for laying out the message box */
  53.241 +
  53.242 +    dialog = CreateDialogData(570, 260, messageboxdata->title);
  53.243 +    if (!dialog) {
  53.244 +        return -1;
  53.245 +    }
  53.246 +
  53.247 +    w = 100;
  53.248 +    h = 25;
  53.249 +    gap = 10;
  53.250 +    x = gap;
  53.251 +    y = 50;
  53.252 +
  53.253 +    if (!AddDialogStatic(dialog, x, y, 550, 100, messageboxdata->message)) {
  53.254 +        FreeDialogData(dialog);
  53.255 +        return -1;
  53.256 +    }
  53.257 +
  53.258 +    y += 110;
  53.259 +
  53.260 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
  53.261 +        SDL_bool isDefault;
  53.262 +
  53.263 +        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
  53.264 +            isDefault = SDL_TRUE;
  53.265 +        } else {
  53.266 +            isDefault = SDL_FALSE;
  53.267 +        }
  53.268 +        if (!AddDialogButton(dialog, x, y, w, h, buttons[i].text, i, isDefault)) {
  53.269 +            FreeDialogData(dialog);
  53.270 +            return -1;
  53.271 +        }
  53.272 +        x += w + gap;
  53.273 +    }
  53.274 +
  53.275 +    /* FIXME: If we have a parent window, get the Instance and HWND for them */
  53.276 +    which = DialogBoxIndirect(NULL, dialog->lpDialog, NULL, (DLGPROC)MessageBoxDialogProc);
  53.277 +    *buttonid = buttons[which].buttonid;
  53.278 +
  53.279 +    FreeDialogData(dialog);
  53.280 +    return 0;
  53.281 +}
  53.282 +
  53.283 +#endif /* SDL_VIDEO_DRIVER_WINDOWS */
  53.284 +
  53.285 +/* vi: set ts=4 sw=4 expandtab: */
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/src/video/windows/SDL_windowsmessagebox.h	Sun Nov 04 09:46:59 2012 -0500
    54.3 @@ -0,0 +1,29 @@
    54.4 +/*
    54.5 +  Simple DirectMedia Layer
    54.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    54.7 +
    54.8 +  This software is provided 'as-is', without any express or implied
    54.9 +  warranty.  In no event will the authors be held liable for any damages
   54.10 +  arising from the use of this software.
   54.11 +
   54.12 +  Permission is granted to anyone to use this software for any purpose,
   54.13 +  including commercial applications, and to alter it and redistribute it
   54.14 +  freely, subject to the following restrictions:
   54.15 +
   54.16 +  1. The origin of this software must not be misrepresented; you must not
   54.17 +     claim that you wrote the original software. If you use this software
   54.18 +     in a product, an acknowledgment in the product documentation would be
   54.19 +     appreciated but is not required.
   54.20 +  2. Altered source versions must be plainly marked as such, and must not be
   54.21 +     misrepresented as being the original software.
   54.22 +  3. This notice may not be removed or altered from any source distribution.
   54.23 +*/
   54.24 +#include "SDL_config.h"
   54.25 +
   54.26 +#if SDL_VIDEO_DRIVER_WINDOWS
   54.27 +
   54.28 +extern int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   54.29 +
   54.30 +#endif /* SDL_VIDEO_DRIVER_WINDOWS */
   54.31 +
   54.32 +/* vi: set ts=4 sw=4 expandtab: */
    55.1 --- a/src/video/x11/SDL_x11events.c	Sun Nov 04 09:02:58 2012 -0500
    55.2 +++ b/src/video/x11/SDL_x11events.c	Sun Nov 04 09:46:59 2012 -0500
    55.3 @@ -386,10 +386,35 @@
    55.4  
    55.5          /* Have we been requested to quit (or another client message?) */
    55.6      case ClientMessage:{
    55.7 -            if ((xevent.xclient.format == 32) &&
    55.8 +            if ((xevent.xclient.message_type == videodata->WM_PROTOCOLS) &&
    55.9 +                (xevent.xclient.format == 32) &&
   55.10 +                (xevent.xclient.data.l[0] == videodata->_NET_WM_PING)) {
   55.11 +
   55.12 +                SDL_DisplayData *dpydata;
   55.13 +                Window root;
   55.14 +
   55.15 +#ifdef DEBUG_XEVENTS
   55.16 +                printf("window %p: _NET_WM_PING\n", data);
   55.17 +#endif
   55.18 +
   55.19 +                dpydata = (SDL_DisplayData *)
   55.20 +                    SDL_GetDisplayForWindow(data->window);
   55.21 +                root = RootWindow(display, dpydata->screen);
   55.22 +                xevent.xclient.window = root;
   55.23 +                XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
   55.24 +                break;
   55.25 +            }
   55.26 +
   55.27 +            else if ((xevent.xclient.message_type == videodata->WM_PROTOCOLS) &&
   55.28 +                (xevent.xclient.format == 32) &&
   55.29                  (xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) {
   55.30  
   55.31 +#ifdef DEBUG_XEVENTS
   55.32 +                printf("window %p: WM_DELETE_WINDOW\n", data);
   55.33 +#endif
   55.34 +
   55.35                  SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
   55.36 +                break;
   55.37              }
   55.38          }
   55.39          break;
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/src/video/x11/SDL_x11messagebox.c	Sun Nov 04 09:46:59 2012 -0500
    56.3 @@ -0,0 +1,642 @@
    56.4 +/*
    56.5 +  Simple DirectMedia Layer
    56.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    56.7 +
    56.8 +  This software is provided 'as-is', without any express or implied
    56.9 +  warranty.  In no event will the authors be held liable for any damages
   56.10 +  arising from the use of this software.
   56.11 +
   56.12 +  Permission is granted to anyone to use this software for any purpose,
   56.13 +  including commercial applications, and to alter it and redistribute it
   56.14 +  freely, subject to the following restrictions:
   56.15 +
   56.16 +  1. The origin of this software must not be misrepresented; you must not
   56.17 +     claim that you wrote the original software. If you use this software
   56.18 +     in a product, an acknowledgment in the product documentation would be
   56.19 +     appreciated but is not required.
   56.20 +  2. Altered source versions must be plainly marked as such, and must not be
   56.21 +     misrepresented as being the original software.
   56.22 +  3. This notice may not be removed or altered from any source distribution.
   56.23 +*/
   56.24 +#include "SDL_config.h"
   56.25 +
   56.26 +#if SDL_VIDEO_DRIVER_X11
   56.27 +
   56.28 +#include "SDL.h"
   56.29 +#include "SDL_x11video.h"
   56.30 +#include "SDL_x11dyn.h"
   56.31 +
   56.32 +#define MAX_BUTTONS             8       /* Maximum number of buttons supported */
   56.33 +#define MAX_TEXT_LINES          32      /* Maximum number of text lines supported */
   56.34 +#define MIN_BUTTON_WIDTH        64      /* Minimum button width */
   56.35 +#define MIN_DIALOG_WIDTH        200     /* Minimum dialog width */
   56.36 +#define MIN_DIALOG_HEIGHT       100     /* Minimum dialog height */
   56.37 +
   56.38 +static const char g_MessageBoxFont[] = "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1";
   56.39 +
   56.40 +static const SDL_MessageBoxColor g_default_colors[ SDL_MESSAGEBOX_COLOR_MAX ] =
   56.41 +{
   56.42 +    { 56,  54,  53  }, // SDL_MESSAGEBOX_COLOR_BACKGROUND,       
   56.43 +    { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT,             
   56.44 +    { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,    
   56.45 +    { 105, 102, 99  }, // SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
   56.46 +    { 205, 202, 53  }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,  
   56.47 +};
   56.48 +
   56.49 +#define SDL_MAKE_RGB( _r, _g, _b )  ( ( ( Uint32 )( _r ) << 16 ) | \
   56.50 +                                      ( ( Uint32 )( _g ) << 8 ) |  \
   56.51 +                                      ( ( Uint32 )( _b ) ) )
   56.52 +
   56.53 +typedef struct SDL_MessageBoxButtonDataX11
   56.54 +{
   56.55 +    int x, y;                           /* Text position */
   56.56 +    int length;                         /* Text length */
   56.57 +    int text_width;                     /* Text width */
   56.58 +
   56.59 +    SDL_Rect rect;                      /* Rectangle for entire button */
   56.60 +
   56.61 +    const SDL_MessageBoxButtonData *buttondata;   /* Button data from caller */
   56.62 +} SDL_MessageBoxButtonDataX11;
   56.63 +
   56.64 +typedef struct TextLineData
   56.65 +{
   56.66 +    int width;                          /* Width of this text line */
   56.67 +    int length;                         /* String length of this text line */
   56.68 +    const char *text;                   /* Text for this line */
   56.69 +} TextLineData;
   56.70 +
   56.71 +typedef struct SDL_MessageBoxDataX11
   56.72 +{
   56.73 +    Font hfont;
   56.74 +    Window window;
   56.75 +    Display *display;
   56.76 +    long event_mask;
   56.77 +    Atom wm_protocols;
   56.78 +    Atom wm_delete_message;
   56.79 +
   56.80 +    int dialog_width;                   /* Dialog box width. */
   56.81 +    int dialog_height;                  /* Dialog box height. */
   56.82 +
   56.83 +    int xtext, ytext;                   /* Text position to start drawing at. */
   56.84 +    int numlines;                       /* Count of Text lines. */
   56.85 +    int text_height;                    /* Height for text lines. */
   56.86 +    TextLineData linedata[ MAX_TEXT_LINES ];
   56.87 +
   56.88 +    int *pbuttonid;                     /* Pointer to user return buttonid value. */
   56.89 +
   56.90 +    int button_press_index;             /* Index into buttondata/buttonpos for button which is pressed (or -1). */
   56.91 +    int mouse_over_index;               /* Index into buttondata/buttonpos for button mouse is over (or -1). */
   56.92 +
   56.93 +    int numbuttons;                     /* Count of buttons. */
   56.94 +    const SDL_MessageBoxButtonData *buttondata;
   56.95 +    SDL_MessageBoxButtonDataX11 buttonpos[ MAX_BUTTONS ];
   56.96 +
   56.97 +    Uint32 color[ SDL_MESSAGEBOX_COLOR_MAX ];
   56.98 +
   56.99 +    const SDL_MessageBoxData *messageboxdata;
  56.100 +} SDL_MessageBoxDataX11;
  56.101 +
  56.102 +/* Maximum helper for ints. */
  56.103 +static __inline__ int
  56.104 +IntMax( int a, int b )
  56.105 +{
  56.106 +    return ( a > b  ) ? a : b;
  56.107 +}
  56.108 +
  56.109 +/* Return width and height for a string. */
  56.110 +static void
  56.111 +GetTextWidthHeight( XFontStruct *font_struct, const char *str, int nchars, int *pwidth, int *pheight )
  56.112 +{
  56.113 +    XCharStruct text_structure;
  56.114 +    int font_direction, font_ascent, font_descent;
  56.115 +
  56.116 +    XTextExtents( font_struct, str, nchars,
  56.117 +                     &font_direction, &font_ascent, &font_descent,
  56.118 +                     &text_structure );
  56.119 +
  56.120 +    *pwidth = text_structure.width;
  56.121 +    *pheight = text_structure.ascent + text_structure.descent;
  56.122 +}
  56.123 +
  56.124 +/* Return index of button if position x,y is contained therein. */
  56.125 +static int
  56.126 +GetHitButtonIndex( SDL_MessageBoxDataX11 *data, int x, int y )
  56.127 +{
  56.128 +    int i;
  56.129 +    int numbuttons = data->numbuttons;
  56.130 +    SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos;
  56.131 +
  56.132 +    for ( i = 0; i < numbuttons; i++ )
  56.133 +    {
  56.134 +        SDL_Rect *rect = &buttonpos[ i ].rect;
  56.135 +
  56.136 +        if ( ( x >= rect->x ) &&
  56.137 +            ( x <= ( rect->x + rect->w ) ) &&
  56.138 +            ( y >= rect->y ) &&
  56.139 +            ( y <= ( rect->y + rect->h ) ) )
  56.140 +        {
  56.141 +            return i;
  56.142 +        }
  56.143 +    }
  56.144 +
  56.145 +    return -1;
  56.146 +}
  56.147 +
  56.148 +/* Initialize SDL_MessageBoxData structure and Display, etc. */
  56.149 +static int
  56.150 +X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * messageboxdata, int * pbuttonid )
  56.151 +{
  56.152 +    int i;
  56.153 +    int numbuttons = messageboxdata->numbuttons;
  56.154 +    const SDL_MessageBoxButtonData *buttondata = messageboxdata->buttons;
  56.155 +    const SDL_MessageBoxColor *colorhints;
  56.156 +
  56.157 +    if ( numbuttons > MAX_BUTTONS ) {
  56.158 +        SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
  56.159 +        return -1;
  56.160 +    }
  56.161 +
  56.162 +    data->dialog_width = MIN_DIALOG_WIDTH;
  56.163 +    data->dialog_height = MIN_DIALOG_HEIGHT;
  56.164 +    data->messageboxdata = messageboxdata;
  56.165 +    data->buttondata = buttondata;
  56.166 +    data->numbuttons = numbuttons;
  56.167 +    data->pbuttonid = pbuttonid;
  56.168 +
  56.169 +    data->display = XOpenDisplay( NULL );
  56.170 +    if ( !data->display ) {
  56.171 +        SDL_SetError("Couldn't open X11 display");
  56.172 +        return -1;
  56.173 +    }
  56.174 +
  56.175 +    data->hfont = XLoadFont( data->display, g_MessageBoxFont );
  56.176 +    if ( data->hfont == None ) {
  56.177 +        SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
  56.178 +        return -1;
  56.179 +    }
  56.180 +
  56.181 +    if ( messageboxdata->colorScheme ) {
  56.182 +        colorhints = messageboxdata->colorScheme->colors;
  56.183 +    } else {
  56.184 +        colorhints = g_default_colors;
  56.185 +    }
  56.186 +
  56.187 +    /* Convert our SDL_MessageBoxColor r,g,b values to packed RGB format. */
  56.188 +    for ( i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; i++ ) {
  56.189 +        data->color[ i ] = SDL_MAKE_RGB( colorhints[ i ].r, colorhints[ i ].g, colorhints[ i ].b );
  56.190 +    }
  56.191 +
  56.192 +    return 0;
  56.193 +}
  56.194 +
  56.195 +/* Calculate and initialize text and button locations. */
  56.196 +static int
  56.197 +X11_MessageBoxInitPositions( SDL_MessageBoxDataX11 *data )
  56.198 +{
  56.199 +    int i;
  56.200 +    int ybuttons;
  56.201 +    int text_width_max = 0;
  56.202 +    int button_text_height = 0;
  56.203 +    int button_width = MIN_BUTTON_WIDTH;
  56.204 +    const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
  56.205 +
  56.206 +    XFontStruct *fontinfo = XQueryFont( data->display, data->hfont );
  56.207 +    if ( !fontinfo ) {
  56.208 +        SDL_SetError("Couldn't get font info");
  56.209 +        return -1;
  56.210 +    }
  56.211 +
  56.212 +    /* Go over text and break linefeeds into separate lines. */
  56.213 +    if ( messageboxdata->message && messageboxdata->message[ 0 ] )
  56.214 +    {
  56.215 +        const char *text = messageboxdata->message;
  56.216 +        TextLineData *plinedata = data->linedata;
  56.217 +
  56.218 +        for ( i = 0; i < MAX_TEXT_LINES; i++, plinedata++ )
  56.219 +        {
  56.220 +            int height;
  56.221 +            char *lf = SDL_strchr( ( char * )text, '\n' );
  56.222 +
  56.223 +            data->numlines++;
  56.224 +
  56.225 +            /* Only grab length up to lf if it exists and isn't the last line. */
  56.226 +            plinedata->length = ( lf && ( i < MAX_TEXT_LINES - 1 ) ) ? ( lf - text ) : SDL_strlen( text );
  56.227 +            plinedata->text = text;
  56.228 +
  56.229 +            GetTextWidthHeight( fontinfo, text, plinedata->length, &plinedata->width, &height );
  56.230 +
  56.231 +            /* Text and widths are the largest we've ever seen. */
  56.232 +            data->text_height = IntMax( data->text_height, height );
  56.233 +            text_width_max = IntMax( text_width_max, plinedata->width );
  56.234 +
  56.235 +            text += plinedata->length + 1;
  56.236 +
  56.237 +            /* Break if there are no more linefeeds. */
  56.238 +            if ( !lf )
  56.239 +                break;
  56.240 +        }
  56.241 +
  56.242 +        /* Bump up the text height slightly. */
  56.243 +        data->text_height += 2;
  56.244 +    }
  56.245 +
  56.246 +    /* Loop through all buttons and calculate the button widths and height. */
  56.247 +    for ( i = 0; i < data->numbuttons; i++ )
  56.248 +    {
  56.249 +        int height;
  56.250 +
  56.251 +        data->buttonpos[ i ].buttondata = &data->buttondata[ i ];
  56.252 +        data->buttonpos[ i ].length = SDL_strlen( data->buttondata[ i ].text );
  56.253 +
  56.254 +        GetTextWidthHeight( fontinfo, data->buttondata[ i ].text, SDL_strlen( data->buttondata[ i ].text ),
  56.255 +                            &data->buttonpos[ i ].text_width, &height );
  56.256 +
  56.257 +        button_width = IntMax( button_width, data->buttonpos[ i ].text_width );
  56.258 +        button_text_height = IntMax( button_text_height, height );
  56.259 +    }
  56.260 +
  56.261 +    if ( data->numlines )
  56.262 +    {
  56.263 +        /* x,y for this line of text. */
  56.264 +        data->xtext = data->text_height;
  56.265 +        data->ytext = data->text_height + data->text_height;
  56.266 +
  56.267 +        /* Bump button y down to bottom of text. */
  56.268 +        ybuttons = 3 * data->ytext / 2 + ( data->numlines - 1 ) * data->text_height;
  56.269 +
  56.270 +        /* Bump the dialog box width and height up if needed. */
  56.271 +        data->dialog_width = IntMax( data->dialog_width, 2 * data->xtext + text_width_max );
  56.272 +        data->dialog_height = IntMax( data->dialog_height, ybuttons );
  56.273 +    }
  56.274 +    else
  56.275 +    {
  56.276 +        /* Button y starts at height of button text. */
  56.277 +        ybuttons = button_text_height;
  56.278 +    }
  56.279 +
  56.280 +    if ( data->numbuttons )
  56.281 +    {
  56.282 +        int x, y;
  56.283 +        int width_of_buttons;
  56.284 +        int button_spacing = button_text_height;
  56.285 +        int button_height = 2 * button_text_height;
  56.286 +
  56.287 +        /* Bump button width up a bit. */
  56.288 +        button_width += button_text_height;
  56.289 +
  56.290 +        /* Get width of all buttons lined up. */
  56.291 +        width_of_buttons = data->numbuttons * button_width + ( data->numbuttons - 1 ) * button_spacing;
  56.292 +
  56.293 +        /* Bump up dialog width and height if buttons are wider than text. */
  56.294 +        data->dialog_width = IntMax( data->dialog_width, width_of_buttons + 2 * button_spacing );
  56.295 +        data->dialog_height = IntMax( data->dialog_height, ybuttons + 2 * button_height );
  56.296 +
  56.297 +        /* Location for first button. */
  56.298 +        x = ( data->dialog_width - width_of_buttons ) / 2;
  56.299 +        y = ybuttons + ( data->dialog_height - ybuttons - button_height ) / 2;
  56.300 +
  56.301 +        for ( i = 0; i < data->numbuttons; i++ )
  56.302 +        {
  56.303 +            /* Button coordinates. */
  56.304 +            data->buttonpos[ i ].rect.x = x;
  56.305 +            data->buttonpos[ i ].rect.y = y;
  56.306 +            data->buttonpos[ i ].rect.w = button_width;
  56.307 +            data->buttonpos[ i ].rect.h = button_height;
  56.308 +
  56.309 +            /* Button text coordinates. */
  56.310 +            data->buttonpos[ i ].x = x + ( button_width - data->buttonpos[ i ].text_width ) / 2;
  56.311 +            data->buttonpos[ i ].y = y + ( button_height - button_text_height - 1 ) / 2 + button_text_height;
  56.312 +
  56.313 +            /* Scoot over for next button. */
  56.314 +            x += button_width + button_spacing;
  56.315 +        }
  56.316 +    }
  56.317 +
  56.318 +    XFreeFontInfo( NULL, fontinfo, 1 );
  56.319 +    return 0;
  56.320 +}
  56.321 +
  56.322 +/* Free SDL_MessageBoxData data. */
  56.323 +static void
  56.324 +X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
  56.325 +{
  56.326 +    if ( data->hfont != None )
  56.327 +    {
  56.328 +        XUnloadFont( data->display, data->hfont );
  56.329 +        data->hfont = None;
  56.330 +    }
  56.331 +
  56.332 +    if ( data->display )
  56.333 +    {
  56.334 +        if ( data->window != None )
  56.335 +        {
  56.336 +            XUnmapWindow( data->display, data->window );
  56.337 +            XDestroyWindow( data->display, data->window );
  56.338 +            data->window = None;
  56.339 +        }
  56.340 +
  56.341 +        XCloseDisplay( data->display );
  56.342 +        data->display = NULL;
  56.343 +    }
  56.344 +}
  56.345 +
  56.346 +/* Create and set up our X11 dialog box indow. */
  56.347 +static int
  56.348 +X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
  56.349 +{
  56.350 +    int x, y;
  56.351 +    XSizeHints *sizehints;
  56.352 +    XSetWindowAttributes wnd_attr;
  56.353 +    Display *display = data->display;
  56.354 +    SDL_WindowData *windowdata = NULL;
  56.355 +    const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
  56.356 +
  56.357 +    if ( messageboxdata->window ) {
  56.358 +        windowdata = (SDL_WindowData *)messageboxdata->window->driverdata;
  56.359 +    }
  56.360 +
  56.361 +    data->event_mask = ExposureMask |
  56.362 +        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
  56.363 +        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
  56.364 +    wnd_attr.event_mask = data->event_mask;
  56.365 +
  56.366 +    data->window = XCreateWindow(
  56.367 +                            display, DefaultRootWindow( display ),
  56.368 +                            0, 0,
  56.369 +                            data->dialog_width, data->dialog_height,
  56.370 +                            0, CopyFromParent, InputOutput, CopyFromParent,
  56.371 +                            CWEventMask, &wnd_attr );
  56.372 +    if ( data->window == None ) {
  56.373 +        SDL_SetError("Couldn't create X window");
  56.374 +        return -1;
  56.375 +    }
  56.376 +
  56.377 +    if ( windowdata ) {
  56.378 +        /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */
  56.379 +        XSetTransientForHint( display, data->window, windowdata->xwindow );
  56.380 +    }
  56.381 +
  56.382 +    XStoreName( display, data->window, messageboxdata->title );
  56.383 +
  56.384 +    /* Allow the window to be deleted by the window manager */
  56.385 +    data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False );
  56.386 +    data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False );
  56.387 +    XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
  56.388 +
  56.389 +    if ( windowdata ) {
  56.390 +        XWindowAttributes attrib;
  56.391 +        Window dummy;
  56.392 +
  56.393 +        XGetWindowAttributes(display, windowdata->xwindow, &attrib);
  56.394 +        x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
  56.395 +        y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
  56.396 +        XTranslateCoordinates(display, windowdata->xwindow, DefaultRootWindow( display ), x, y, &x, &y, &dummy);
  56.397 +    } else {
  56.398 +        int screen = DefaultScreen( display );
  56.399 +        x = ( DisplayWidth( display, screen ) - data->dialog_width ) / 2;
  56.400 +        y = ( DisplayHeight( display, screen ) - data->dialog_height ) / 3 ;
  56.401 +    }
  56.402 +    XMoveWindow( display, data->window, x, y );
  56.403 +
  56.404 +    sizehints = XAllocSizeHints();
  56.405 +    if ( sizehints ) {
  56.406 +        sizehints->flags = USPosition | USSize | PMaxSize | PMinSize;
  56.407 +        sizehints->x = x;
  56.408 +        sizehints->y = y;
  56.409 +        sizehints->width = data->dialog_width;
  56.410 +        sizehints->height = data->dialog_height;
  56.411 +
  56.412 +        sizehints->min_width = sizehints->max_width = data->dialog_width;
  56.413 +        sizehints->min_height = sizehints->max_height = data->dialog_height;
  56.414 +
  56.415 +        XSetWMNormalHints( display, data->window, sizehints );
  56.416 +
  56.417 +        XFree( sizehints );
  56.418 +    }
  56.419 +
  56.420 +    XMapRaised( display, data->window );
  56.421 +    return 0;
  56.422 +}
  56.423 +
  56.424 +/* Draw our message box. */
  56.425 +static void
  56.426 +X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
  56.427 +{
  56.428 +    int i;
  56.429 +    Window window = data->window;
  56.430 +    Display *display = data->display;
  56.431 +
  56.432 +    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
  56.433 +    XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
  56.434 +
  56.435 +    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
  56.436 +    for ( i = 0; i < data->numlines; i++ )
  56.437 +    {
  56.438 +        TextLineData *plinedata = &data->linedata[ i ];
  56.439 +
  56.440 +        XDrawString( display, window, ctx,
  56.441 +                     data->xtext, data->ytext + i * data->text_height,
  56.442 +                     plinedata->text, plinedata->length );
  56.443 +    }
  56.444 +
  56.445 +    for ( i = 0; i < data->numbuttons; i++ )
  56.446 +    {
  56.447 +        SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ];
  56.448 +        const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata;
  56.449 +        int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
  56.450 +        int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0;
  56.451 +
  56.452 +        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
  56.453 +        XFillRectangle( display, window, ctx,
  56.454 +                        buttondatax11->rect.x - border, buttondatax11->rect.y - border,
  56.455 +                        buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border );
  56.456 +
  56.457 +        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
  56.458 +        XDrawRectangle( display, window, ctx,
  56.459 +                        buttondatax11->rect.x, buttondatax11->rect.y,
  56.460 +                        buttondatax11->rect.w, buttondatax11->rect.h );
  56.461 +
  56.462 +        XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
  56.463 +                        data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
  56.464 +                        data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
  56.465 +        XDrawString( display, window, ctx,
  56.466 +            buttondatax11->x + offset, buttondatax11->y + offset,
  56.467 +            buttondata->text, buttondatax11->length );
  56.468 +    }
  56.469 +}
  56.470 +
  56.471 +/* Loop and handle message box event messages until something kills it. */
  56.472 +static int
  56.473 +X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
  56.474 +{
  56.475 +    GC ctx;
  56.476 +    XGCValues ctx_vals;
  56.477 +    SDL_bool close_dialog = SDL_FALSE;
  56.478 +    SDL_bool has_focus = SDL_TRUE;
  56.479 +    KeySym last_key_pressed = XK_VoidSymbol;
  56.480 +
  56.481 +    ctx_vals.font = data->hfont;
  56.482 +    ctx_vals.foreground = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ];
  56.483 +    ctx_vals.background = data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ];
  56.484 +
  56.485 +    ctx = XCreateGC( data->display, data->window, GCForeground | GCBackground | GCFont, &ctx_vals );
  56.486 +    if ( ctx == None ) {
  56.487 +        SDL_SetError("Couldn't create graphics context");
  56.488 +        return -1;
  56.489 +    }
  56.490 +
  56.491 +    data->button_press_index = -1;  /* Reset what button is currently depressed. */
  56.492 +    data->mouse_over_index = -1;    /* Reset what button the mouse is over. */
  56.493 +
  56.494 +    while( !close_dialog ) {
  56.495 +        XEvent e;
  56.496 +        SDL_bool draw = SDL_TRUE;
  56.497 +
  56.498 +        XWindowEvent( data->display, data->window, data->event_mask, &e );
  56.499 +
  56.500 +        /* If XFilterEvent returns True, then some input method has filtered the
  56.501 +           event, and the client should discard the event. */
  56.502 +        if ( ( e.type != Expose ) && XFilterEvent( &e, None ) )
  56.503 +            continue;
  56.504 +
  56.505 +        switch( e.type ) {
  56.506 +        case Expose:
  56.507 +            if ( e.xexpose.count > 0 ) {
  56.508 +                draw = SDL_FALSE;
  56.509 +            }
  56.510 +            break;
  56.511 +
  56.512 +        case FocusIn:
  56.513 +            /* Got focus. */
  56.514 +            has_focus = SDL_TRUE;
  56.515 +            break;
  56.516 +
  56.517 +        case FocusOut:
  56.518 +            /* lost focus. Reset button and mouse info. */
  56.519 +            has_focus = SDL_FALSE;
  56.520 +            data->button_press_index = -1;
  56.521 +            data->mouse_over_index = -1;
  56.522 +            break;
  56.523 +
  56.524 +        case MotionNotify:
  56.525 +            if ( has_focus ) {
  56.526 +                /* Mouse moved... */
  56.527 +                data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
  56.528 +            }
  56.529 +            break;
  56.530 +
  56.531 +        case ClientMessage:
  56.532 +            if ( e.xclient.message_type == data->wm_protocols &&
  56.533 +                 e.xclient.format == 32 &&
  56.534 +                 e.xclient.data.l[ 0 ] == data->wm_delete_message ) {
  56.535 +                close_dialog = SDL_TRUE;
  56.536 +            }
  56.537 +            break;
  56.538 +
  56.539 +        case KeyPress:
  56.540 +            /* Store key press - we make sure in key release that we got both. */
  56.541 +            last_key_pressed = XLookupKeysym( &e.xkey, 0 );
  56.542 +            break;
  56.543 +
  56.544 +        case KeyRelease:
  56.545 +        {
  56.546 +            Uint32 mask = 0;
  56.547 +            KeySym key = XLookupKeysym( &e.xkey, 0 );
  56.548 +
  56.549 +            /* If this is a key release for something we didn't get the key down for, then bail. */
  56.550 +            if ( key != last_key_pressed )
  56.551 +                break;
  56.552 +
  56.553 +            if ( key == XK_Escape )
  56.554 +                mask = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
  56.555 +            else if ( ( key == XK_Return ) || ( key == XK_KP_Enter ) )
  56.556 +                mask = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
  56.557 +
  56.558 +            if ( mask ) {
  56.559 +                int i;
  56.560 +
  56.561 +                /* Look for first button with this mask set, and return it if found. */
  56.562 +                for ( i = 0; i < data->numbuttons; i++ ) {
  56.563 +                    SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ i ];
  56.564 +
  56.565 +                    if ( buttondatax11->buttondata->flags & mask ) {
  56.566 +                        *data->pbuttonid = buttondatax11->buttondata->buttonid;
  56.567 +                        close_dialog = SDL_TRUE;
  56.568 +                        break;
  56.569 +                    }
  56.570 +                }
  56.571 +            }
  56.572 +            break;
  56.573 +        }
  56.574 +
  56.575 +        case ButtonPress:
  56.576 +            data->button_press_index = -1;
  56.577 +            if ( e.xbutton.button == Button1 ) {
  56.578 +                /* Find index of button they clicked on. */
  56.579 +                data->button_press_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
  56.580 +            }
  56.581 +            break;
  56.582 +
  56.583 +        case ButtonRelease:
  56.584 +            /* If button is released over the same button that was clicked down on, then return it. */
  56.585 +            if ( ( e.xbutton.button == Button1 ) && ( data->button_press_index >= 0 ) ) {
  56.586 +                int button = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y );
  56.587 +
  56.588 +                if ( data->button_press_index == button ) {
  56.589 +                    SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[ button ];
  56.590 +
  56.591 +                    *data->pbuttonid = buttondatax11->buttondata->buttonid;
  56.592 +                    close_dialog = SDL_TRUE;
  56.593 +                }
  56.594 +            }
  56.595 +            data->button_press_index = -1;
  56.596 +            break;
  56.597 +        }
  56.598 +
  56.599 +        if ( draw ) {
  56.600 +            /* Draw our dialog box. */
  56.601 +            X11_MessageBoxDraw( data, ctx );
  56.602 +        }
  56.603 +    }
  56.604 +
  56.605 +    XFreeGC( data->display, ctx );
  56.606 +    return 0;
  56.607 +}
  56.608 +
  56.609 +/* Display an x11 message box. */
  56.610 +int
  56.611 +X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
  56.612 +{
  56.613 +    int ret;
  56.614 +    SDL_MessageBoxDataX11 data;
  56.615 +
  56.616 +    SDL_memset( &data, 0, sizeof( data ) );
  56.617 +
  56.618 +    if ( !SDL_X11_LoadSymbols() )
  56.619 +        return -1;
  56.620 +
  56.621 +    /* This code could get called from multiple threads maybe? */
  56.622 +    XInitThreads();
  56.623 +
  56.624 +    /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */
  56.625 +    *buttonid = -1;
  56.626 +
  56.627 +    /* Init and display the message box. */
  56.628 +    ret = X11_MessageBoxInit( &data, messageboxdata, buttonid );
  56.629 +    if ( ret != -1 ) {
  56.630 +        ret = X11_MessageBoxInitPositions( &data );
  56.631 +        if ( ret != -1 ) {
  56.632 +            ret = X11_MessageBoxCreateWindow( &data );
  56.633 +            if ( ret != -1 ) {
  56.634 +                ret = X11_MessageBoxLoop( &data );
  56.635 +            }
  56.636 +        }
  56.637 +    }
  56.638 +
  56.639 +    X11_MessageBoxShutdown( &data );
  56.640 +    return ret;
  56.641 +}
  56.642 +
  56.643 +#endif /* SDL_VIDEO_DRIVER_X11 */
  56.644 +
  56.645 +/* vi: set ts=4 sw=4 expandtab: */
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/src/video/x11/SDL_x11messagebox.h	Sun Nov 04 09:46:59 2012 -0500
    57.3 @@ -0,0 +1,28 @@
    57.4 +/*
    57.5 +  Simple DirectMedia Layer
    57.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    57.7 +
    57.8 +  This software is provided 'as-is', without any express or implied
    57.9 +  warranty.  In no event will the authors be held liable for any damages
   57.10 +  arising from the use of this software.
   57.11 +
   57.12 +  Permission is granted to anyone to use this software for any purpose,
   57.13 +  including commercial applications, and to alter it and redistribute it
   57.14 +  freely, subject to the following restrictions:
   57.15 +
   57.16 +  1. The origin of this software must not be misrepresented; you must not
   57.17 +     claim that you wrote the original software. If you use this software
   57.18 +     in a product, an acknowledgment in the product documentation would be
   57.19 +     appreciated but is not required.
   57.20 +  2. Altered source versions must be plainly marked as such, and must not be
   57.21 +     misrepresented as being the original software.
   57.22 +  3. This notice may not be removed or altered from any source distribution.
   57.23 +*/
   57.24 +
   57.25 +#if SDL_VIDEO_DRIVER_X11
   57.26 +
   57.27 +extern int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
   57.28 +
   57.29 +#endif /* SDL_VIDEO_DRIVER_X11 */
   57.30 +
   57.31 +/* vi: set ts=4 sw=4 expandtab: */
    58.1 --- a/src/video/x11/SDL_x11sym.h	Sun Nov 04 09:02:58 2012 -0500
    58.2 +++ b/src/video/x11/SDL_x11sym.h	Sun Nov 04 09:46:59 2012 -0500
    58.3 @@ -43,13 +43,17 @@
    58.4  SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
    58.5  SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
    58.6  SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
    58.7 +SDL_X11_SYM(int,XDrawRectangle,(Display* a,Drawable b,GC c,int d,int e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
    58.8  SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
    58.9 +SDL_X11_SYM(int,XDrawString,(Display* a,Drawable b,GC c,int d,int e,_Xconst char* f,int g),(a,b,c,d,e,f,g),return)
   58.10  SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
   58.11 +SDL_X11_SYM(int,XFillRectangle,(Display* a,Drawable b,GC c,int d,int e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
   58.12  SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
   58.13  SDL_X11_SYM(int,XFlush,(Display* a),(a),return)
   58.14  SDL_X11_SYM(int,XFree,(void*a),(a),return)
   58.15  SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return)
   58.16  SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
   58.17 +SDL_X11_SYM(int,XFreeFontInfo,(char** a,XFontStruct* b,int c),(a,b,c),return)
   58.18  SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
   58.19  SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
   58.20  SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
   58.21 @@ -73,6 +77,7 @@
   58.22  SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
   58.23  SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
   58.24  SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return)
   58.25 +SDL_X11_SYM(Font,XLoadFont,(Display* a,_Xconst char* b),(a,b),return)
   58.26  SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return)
   58.27  SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return)
   58.28  SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return)
   58.29 @@ -85,6 +90,7 @@
   58.30  SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
   58.31  SDL_X11_SYM(int,XPending,(Display* a),(a),return)
   58.32  SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
   58.33 +SDL_X11_SYM(XFontStruct*,XQueryFont,(Display* a,XID b),(a,b),return)
   58.34  SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
   58.35  SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
   58.36  SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
   58.37 @@ -94,6 +100,7 @@
   58.38  SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
   58.39  SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
   58.40  SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
   58.41 +SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return)
   58.42  SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
   58.43  SDL_X11_SYM(int,XSetInputFocus,(Display *a,Window b,int c,Time d),(a,b,c,d),return)
   58.44  SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
   58.45 @@ -104,15 +111,20 @@
   58.46  SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
   58.47  SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
   58.48  SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
   58.49 +SDL_X11_SYM(int,XStoreName,(Display* a,Window b,_Xconst char* c),(a,b,c),return)
   58.50  SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return)
   58.51  SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return)
   58.52 +SDL_X11_SYM(int,XTextExtents,(XFontStruct* a,_Xconst char* b,int c,int* d,int* e,int* f,XCharStruct* g),(a,b,c,d,e,f,g),return)
   58.53 +SDL_X11_SYM(Bool,XTranslateCoordinates,(Display *a,Window b,Window c,int d,int e,int* f,int* g,Window* h),(a,b,c,d,e,f,g,h),return)
   58.54  SDL_X11_SYM(int,XUndefineCursor,(Display* a,Window b),(a,b),return)
   58.55  SDL_X11_SYM(int,XUngrabKeyboard,(Display* a,Time b),(a,b),return)
   58.56  SDL_X11_SYM(int,XUngrabPointer,(Display* a,Time b),(a,b),return)
   58.57  SDL_X11_SYM(int,XUngrabServer,(Display* a),(a),return)
   58.58  SDL_X11_SYM(int,XUninstallColormap,(Display* a,Colormap b),(a,b),return)
   58.59 +SDL_X11_SYM(int,XUnloadFont,(Display* a,Font b),(a,b),return)
   58.60  SDL_X11_SYM(int,XUnmapWindow,(Display* a,Window b),(a,b),return)
   58.61  SDL_X11_SYM(int,XWarpPointer,(Display* a,Window b,Window c,int d,int e,unsigned int f,unsigned int g,int h,int i),(a,b,c,d,e,f,g,h,i),return)
   58.62 +SDL_X11_SYM(int,XWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return)
   58.63  SDL_X11_SYM(VisualID,XVisualIDFromVisual,(Visual* a),(a),return)
   58.64  #if SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
   58.65  SDL_X11_SYM(XExtDisplayInfo*,XextAddDisplay,(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f),(a,b,c,d,e,f),return)
    59.1 --- a/src/video/x11/SDL_x11video.c	Sun Nov 04 09:02:58 2012 -0500
    59.2 +++ b/src/video/x11/SDL_x11video.c	Sun Nov 04 09:46:59 2012 -0500
    59.3 @@ -370,6 +370,7 @@
    59.4  
    59.5      /* Look up some useful Atoms */
    59.6  #define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
    59.7 +    GET_ATOM(WM_PROTOCOLS);
    59.8      GET_ATOM(WM_DELETE_WINDOW);
    59.9      GET_ATOM(_NET_WM_STATE);
   59.10      GET_ATOM(_NET_WM_STATE_HIDDEN);
   59.11 @@ -382,6 +383,7 @@
   59.12      GET_ATOM(_NET_WM_NAME);
   59.13      GET_ATOM(_NET_WM_ICON_NAME);
   59.14      GET_ATOM(_NET_WM_ICON);
   59.15 +    GET_ATOM(_NET_WM_PING);
   59.16      GET_ATOM(UTF8_STRING);
   59.17  
   59.18      /* Detect the window manager */
    60.1 --- a/src/video/x11/SDL_x11video.h	Sun Nov 04 09:02:58 2012 -0500
    60.2 +++ b/src/video/x11/SDL_x11video.h	Sun Nov 04 09:46:59 2012 -0500
    60.3 @@ -80,6 +80,7 @@
    60.4      SDL_bool net_wm;
    60.5  
    60.6      /* Useful atoms */
    60.7 +    Atom WM_PROTOCOLS;
    60.8      Atom WM_DELETE_WINDOW;
    60.9      Atom _NET_WM_STATE;
   60.10      Atom _NET_WM_STATE_HIDDEN;
   60.11 @@ -92,6 +93,7 @@
   60.12      Atom _NET_WM_NAME;
   60.13      Atom _NET_WM_ICON_NAME;
   60.14      Atom _NET_WM_ICON;
   60.15 +    Atom _NET_WM_PING;
   60.16      Atom UTF8_STRING;
   60.17  
   60.18      SDL_Scancode key_layout[256];
    61.1 --- a/src/video/x11/SDL_x11window.c	Sun Nov 04 09:02:58 2012 -0500
    61.2 +++ b/src/video/x11/SDL_x11window.c	Sun Nov 04 09:46:59 2012 -0500
    61.3 @@ -536,8 +536,14 @@
    61.4                      PropModeReplace,
    61.5                      (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
    61.6  
    61.7 -    /* Allow the window to be deleted by the window manager */
    61.8 -    XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1);
    61.9 +    
   61.10 +    {
   61.11 +        Atom protocols[] = {
   61.12 +            data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
   61.13 +            data->_NET_WM_PING, /* Respond so WM knows we're alive */
   61.14 +        };
   61.15 +        XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
   61.16 +    }
   61.17  
   61.18      if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
   61.19          XDestroyWindow(display, w);
    62.1 --- a/test/Makefile.in	Sun Nov 04 09:02:58 2012 -0500
    62.2 +++ b/test/Makefile.in	Sun Nov 04 09:46:59 2012 -0500
    62.3 @@ -47,6 +47,7 @@
    62.4  	testwm2$(EXE) \
    62.5  	torturethread$(EXE) \
    62.6  	testrendercopyex$(EXE) \
    62.7 +	testmessage$(EXE) \
    62.8  
    62.9  all: Makefile $(TARGETS)
   62.10  
   62.11 @@ -54,142 +55,145 @@
   62.12  	$(SHELL) config.status $@
   62.13  
   62.14  checkkeys$(EXE): $(srcdir)/checkkeys.c
   62.15 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.16 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.17  
   62.18  loopwave$(EXE): $(srcdir)/loopwave.c
   62.19 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.20 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.21  
   62.22  testresample$(EXE): $(srcdir)/testresample.c
   62.23 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.24 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.25  
   62.26  testaudioinfo$(EXE): $(srcdir)/testaudioinfo.c
   62.27 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.28 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.29  
   62.30  testmultiaudio$(EXE): $(srcdir)/testmultiaudio.c
   62.31 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.32 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.33  
   62.34  testatomic$(EXE): $(srcdir)/testatomic.c
   62.35 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.36 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.37  
   62.38  testintersections$(EXE): $(srcdir)/testintersections.c $(srcdir)/common.c
   62.39 -	$(CC) -o $@ $(srcdir)/testintersections.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
   62.40 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.41  
   62.42  testrelative$(EXE): $(srcdir)/testrelative.c $(srcdir)/common.c
   62.43 -	$(CC) -o $@ $(srcdir)/testrelative.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
   62.44 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.45  
   62.46  testdraw2$(EXE): $(srcdir)/testdraw2.c $(srcdir)/common.c
   62.47 -	$(CC) -o $@ $(srcdir)/testdraw2.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
   62.48 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.49  
   62.50  testerror$(EXE): $(srcdir)/testerror.c
   62.51 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.52 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.53  
   62.54  testfile$(EXE): $(srcdir)/testfile.c
   62.55 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.56 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.57  
   62.58  testgesture$(EXE): $(srcdir)/testgesture.c
   62.59 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
   62.60 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
   62.61   
   62.62  testgl2$(EXE): $(srcdir)/testgl2.c $(srcdir)/common.c
   62.63 -	$(CC) -o $@ $(srcdir)/testgl2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   62.64 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   62.65  
   62.66  testgles$(EXE): $(srcdir)/testgles.c $(srcdir)/common.c
   62.67 -	$(CC) -o $@ $(srcdir)/testgles.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   62.68 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
   62.69  
   62.70  testhaptic$(EXE): $(srcdir)/testhaptic.c
   62.71 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.72 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.73  
   62.74  testrumble$(EXE): $(srcdir)/testrumble.c
   62.75 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.76 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.77  
   62.78  testthread$(EXE): $(srcdir)/testthread.c
   62.79 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.80 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.81  
   62.82  testiconv$(EXE): $(srcdir)/testiconv.c
   62.83 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.84 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.85  
   62.86  testime$(EXE): $(srcdir)/testime.c $(srcdir)/common.c
   62.87 -	$(CC) -o $@ $(srcdir)/testime.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @SDL_TTF_LIB@
   62.88 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @SDL_TTF_LIB@
   62.89  
   62.90  testjoystick$(EXE): $(srcdir)/testjoystick.c $(srcdir)/common.c
   62.91 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.92 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.93  
   62.94  testkeys$(EXE): $(srcdir)/testkeys.c
   62.95 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
   62.96 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
   62.97  
   62.98  testloadso$(EXE): $(srcdir)/testloadso.c
   62.99 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.100 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.101  
  62.102  testlock$(EXE): $(srcdir)/testlock.c
  62.103 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.104 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.105  
  62.106  ifeq (@ISMACOSX@,true)
  62.107  testnative$(EXE): $(srcdir)/testnative.c \
  62.108  			$(srcdir)/testnativecocoa.m \
  62.109  			$(srcdir)/testnativew32.c \
  62.110  			$(srcdir)/testnativex11.c
  62.111 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) -L/usr/X11/lib -lX11 -framework Cocoa
  62.112 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -L/usr/X11/lib -lX11 -framework Cocoa
  62.113  endif
  62.114  
  62.115  ifeq (@ISWINDOWS@,true)
  62.116  testnative$(EXE): $(srcdir)/testnative.c \
  62.117  			$(srcdir)/testnativew32.c
  62.118 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.119 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.120  endif
  62.121  
  62.122  ifeq (@ISUNIX@,true)
  62.123  testnative$(EXE): $(srcdir)/testnative.c \
  62.124  			$(srcdir)/testnativex11.c
  62.125 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) -L/usr/X11/lib -lX11
  62.126 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -L/usr/X11/lib -lX11
  62.127  endif
  62.128  
  62.129  testoverlay2$(EXE): $(srcdir)/testoverlay2.c
  62.130 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.131 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.132  
  62.133  testplatform$(EXE): $(srcdir)/testplatform.c
  62.134 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.135 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.136  
  62.137  testpower$(EXE): $(srcdir)/testpower.c
  62.138 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.139 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.140  
  62.141  testrendertarget$(EXE): $(srcdir)/testrendertarget.c $(srcdir)/common.c
  62.142 -	$(CC) -o $@ $(srcdir)/testrendertarget.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
  62.143 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.144  
  62.145  testscale$(EXE): $(srcdir)/testscale.c $(srcdir)/common.c
  62.146 -	$(CC) -o $@ $(srcdir)/testscale.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
  62.147 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.148  
  62.149  testsem$(EXE): $(srcdir)/testsem.c
  62.150 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.151 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.152  
  62.153  testshader$(EXE): $(srcdir)/testshader.c
  62.154 -	$(CC) -o $@ $(srcdir)/testshader.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
  62.155 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
  62.156  
  62.157  testshape$(EXE): $(srcdir)/testshape.c
  62.158 -	$(CC) -o $@ $? -std=c99 $(CFLAGS) $(LIBS)
  62.159 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.160  
  62.161  testsprite2$(EXE): $(srcdir)/testsprite2.c $(srcdir)/common.c
  62.162 -	$(CC) -o $@ $(srcdir)/testsprite2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @MATHLIB@
  62.163 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
  62.164  
  62.165  testspriteminimal$(EXE): $(srcdir)/testspriteminimal.c
  62.166 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
  62.167 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
  62.168  
  62.169  teststreaming$(EXE): $(srcdir)/teststreaming.c
  62.170 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @MATHLIB@
  62.171 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
  62.172  
  62.173  testtimer$(EXE): $(srcdir)/testtimer.c
  62.174 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.175 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.176  
  62.177  testver$(EXE): $(srcdir)/testver.c
  62.178 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.179 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.180  
  62.181  testwm2$(EXE): $(srcdir)/testwm2.c $(srcdir)/common.c
  62.182 -	$(CC) -o $@ $(srcdir)/testwm2.c $(srcdir)/common.c $(CFLAGS) $(LIBS)
  62.183 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.184  
  62.185  torturethread$(EXE): $(srcdir)/torturethread.c
  62.186 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
  62.187 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.188  
  62.189  testrendercopyex$(EXE): $(srcdir)/testrendercopyex.c $(srcdir)/common.c
  62.190 -	$(CC) -o $@ $(srcdir)/testrendercopyex.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @MATHLIB@
  62.191 -	
  62.192 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@
  62.193 +
  62.194 +testmessage$(EXE): $(srcdir)/testmessage.c
  62.195 +	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
  62.196 +
  62.197  clean:
  62.198  	rm -f $(TARGETS)
  62.199  
    63.1 --- a/test/common.c	Sun Nov 04 09:02:58 2012 -0500
    63.2 +++ b/test/common.c	Sun Nov 04 09:46:59 2012 -0500
    63.3 @@ -1204,6 +1204,12 @@
    63.4                  }
    63.5              }
    63.6              break;
    63.7 +        case SDLK_1:
    63.8 +            if (event->key.keysym.mod & KMOD_CTRL) {
    63.9 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
   63.10 +                SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Test Message", "You're awesome!", window);
   63.11 +            }
   63.12 +            break;
   63.13          case SDLK_ESCAPE:
   63.14              *done = 1;
   63.15              break;
    64.1 --- a/test/configure	Sun Nov 04 09:02:58 2012 -0500
    64.2 +++ b/test/configure	Sun Nov 04 09:46:59 2012 -0500
    64.3 @@ -3865,39 +3865,52 @@
    64.4  
    64.5  
    64.6  
    64.7 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL_ttf" >&5
    64.8 -$as_echo_n "checking for SDL_ttf... " >&6; }
    64.9 -have_SDL_ttf=no
   64.10 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5
   64.11 +$as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; }
   64.12 +if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then :
   64.13 +  $as_echo_n "(cached) " >&6
   64.14 +else
   64.15 +  ac_check_lib_save_LIBS=$LIBS
   64.16 +LIBS="-lSDL2_ttf  $LIBS"
   64.17  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   64.18  /* end confdefs.h.  */
   64.19  
   64.20 - #include "SDL_ttf.h"
   64.21 -
   64.22 +/* Override any GCC internal prototype to avoid an error.
   64.23 +   Use char because int might match the return type of a GCC
   64.24 +   builtin and then its argument prototype would still apply.  */
   64.25 +#ifdef __cplusplus
   64.26 +extern "C"
   64.27 +#endif
   64.28 +char TTF_Init ();
   64.29  int
   64.30  main ()
   64.31  {
   64.32 -
   64.33 -
   64.34 +return TTF_Init ();
   64.35    ;
   64.36    return 0;
   64.37  }
   64.38  _ACEOF
   64.39 -if ac_fn_c_try_compile "$LINENO"; then :
   64.40 -
   64.41 -have_SDL_ttf=yes
   64.42 -
   64.43 +if ac_fn_c_try_link "$LINENO"; then :
   64.44 +  ac_cv_lib_SDL2_ttf_TTF_Init=yes
   64.45 +else
   64.46 +  ac_cv_lib_SDL2_ttf_TTF_Init=no
   64.47  fi
   64.48 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   64.49 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_SDL_ttf" >&5
   64.50 -$as_echo "$have_SDL_ttf" >&6; }
   64.51 +rm -f core conftest.err conftest.$ac_objext \
   64.52 +    conftest$ac_exeext conftest.$ac_ext
   64.53 +LIBS=$ac_check_lib_save_LIBS
   64.54 +fi
   64.55 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SDL2_ttf_TTF_Init" >&5
   64.56 +$as_echo "$ac_cv_lib_SDL2_ttf_TTF_Init" >&6; }
   64.57 +if test "x$ac_cv_lib_SDL2_ttf_TTF_Init" = xyes; then :
   64.58 +  have_SDL_ttf=yes
   64.59 +fi
   64.60  
   64.61  if test x$have_SDL_ttf = xyes; then
   64.62      CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
   64.63 -    SDL_TTF_LIB="-lSDL_ttf"
   64.64 +    SDL_TTF_LIB="-lSDL2_ttf"
   64.65  fi
   64.66  
   64.67  
   64.68 -
   64.69  ac_config_files="$ac_config_files Makefile"
   64.70  
   64.71  cat >confcache <<\_ACEOF
    65.1 --- a/test/configure.in	Sun Nov 04 09:02:58 2012 -0500
    65.2 +++ b/test/configure.in	Sun Nov 04 09:46:59 2012 -0500
    65.3 @@ -143,21 +143,11 @@
    65.4  AC_SUBST(GLLIB)
    65.5  
    65.6  dnl Check for SDL_ttf
    65.7 -AC_MSG_CHECKING(for SDL_ttf)
    65.8 -have_SDL_ttf=no
    65.9 -AC_TRY_COMPILE([
   65.10 - #include "SDL_ttf.h"
   65.11 -],[
   65.12 -],[
   65.13 -have_SDL_ttf=yes
   65.14 -])
   65.15 -AC_MSG_RESULT($have_SDL_ttf)
   65.16 -
   65.17 +AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
   65.18  if test x$have_SDL_ttf = xyes; then
   65.19      CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
   65.20 -    SDL_TTF_LIB="-lSDL_ttf"
   65.21 +    SDL_TTF_LIB="-lSDL2_ttf"
   65.22  fi
   65.23 -
   65.24  AC_SUBST(SDL_TTF_LIB)
   65.25  
   65.26  dnl Finally create all the generated files
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/test/testmessage.c	Sun Nov 04 09:46:59 2012 -0500
    66.3 @@ -0,0 +1,86 @@
    66.4 +/*
    66.5 +  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
    66.6 +
    66.7 +  This software is provided 'as-is', without any express or implied
    66.8 +  warranty.  In no event will the authors be held liable for any damages
    66.9 +  arising from the use of this software.
   66.10 +
   66.11 +  Permission is granted to anyone to use this software for any purpose,
   66.12 +  including commercial applications, and to alter it and redistribute it
   66.13 +  freely.
   66.14 +*/
   66.15 +
   66.16 +/* Simple test of the SDL MessageBox API*/
   66.17 +
   66.18 +#include <stdio.h>
   66.19 +#include <stdlib.h>
   66.20 +#include <signal.h>
   66.21 +
   66.22 +#include "SDL.h"
   66.23 +#include "SDL_thread.h"
   66.24 +
   66.25 +static int alive = 0;
   66.26 +
   66.27 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   66.28 +static void
   66.29 +quit(int rc)
   66.30 +{
   66.31 +    SDL_Quit();
   66.32 +    exit(rc);
   66.33 +}
   66.34 +
   66.35 +int
   66.36 +main(int argc, char *argv[])
   66.37 +{
   66.38 +    int success;
   66.39 +
   66.40 +    /* Load the SDL library */
   66.41 +    if (SDL_Init(0) < 0) {
   66.42 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   66.43 +        return (1);
   66.44 +    }
   66.45 +
   66.46 +    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
   66.47 +                "Simple MessageBox",
   66.48 +                "This is a simple error MessageBox",
   66.49 +                NULL);
   66.50 +    if (success == -1) {
   66.51 +        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   66.52 +        quit(1);
   66.53 +    }
   66.54 +
   66.55 +    {
   66.56 +        const SDL_MessageBoxButtonData buttons[] = {
   66.57 +            {
   66.58 +                SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
   66.59 +                0,
   66.60 +                "OK"
   66.61 +            },{
   66.62 +                SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
   66.63 +                1,
   66.64 +                "Cancel"
   66.65 +            },
   66.66 +        };
   66.67 +
   66.68 +        SDL_MessageBoxData data = {
   66.69 +            SDL_MESSAGEBOX_INFORMATION,
   66.70 +            NULL, // no parent window
   66.71 +            "Custom MessageBox",
   66.72 +            "This is a custom messagebox",
   66.73 +            2,
   66.74 +            buttons,
   66.75 +            NULL // Default color scheme
   66.76 +        };
   66.77 +
   66.78 +        int button = -1;
   66.79 +        success = SDL_ShowMessageBox(&data, &button);
   66.80 +        if (success == -1) {
   66.81 +            printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   66.82 +            quit(2);
   66.83 +        }
   66.84 +        printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
   66.85 +    }
   66.86 +
   66.87 +    SDL_Quit();
   66.88 +    return (0);
   66.89 +}