Merge with main repo (mainly for non-printable character fix)
authordewyatt
Sun, 18 Jul 2010 13:48:23 -0400
changeset 4755436183eb30c8
parent 4754 2072fed2f583
parent 4542 af1d018ebbe6
child 4756 b99b1024607a
Merge with main repo (mainly for non-printable character fix)
include/SDL_stdinc.h
src/events/SDL_keyboard.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
src/video/win32/SDL_win32window.c
     1.1 --- a/Makefile.in	Tue Jul 13 15:05:45 2010 -0400
     1.2 +++ b/Makefile.in	Sun Jul 18 13:48:23 2010 -0400
     1.3 @@ -44,7 +44,7 @@
     1.4  
     1.5  DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-Win32.zip WhatsNew Xcode Xcode-iPhoneOS
     1.6  
     1.7 -HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_input.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.8 +HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_clipboard.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_input.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.9  
    1.10  LT_AGE      = @LT_AGE@
    1.11  LT_CURRENT  = @LT_CURRENT@
     2.1 --- a/VisualC/SDL/SDL_VS2005.vcproj	Tue Jul 13 15:05:45 2010 -0400
     2.2 +++ b/VisualC/SDL/SDL_VS2005.vcproj	Sun Jul 18 13:48:23 2010 -0400
     2.3 @@ -236,6 +236,10 @@
     2.4  				>
     2.5  			</File>
     2.6  			<File
     2.7 +				RelativePath="..\..\include\SDL_clipboard.h"
     2.8 +				>
     2.9 +			</File>
    2.10 +			<File
    2.11  				RelativePath="..\..\include\SDL_compat.h"
    2.12  				>
    2.13  			</File>
    2.14 @@ -561,6 +565,18 @@
    2.15  			>
    2.16  		</File>
    2.17  		<File
    2.18 +			RelativePath="..\..\src\video\SDL_clipboard.c"
    2.19 +			>
    2.20 +		</File>
    2.21 +		<File
    2.22 +			RelativePath="..\..\src\events\SDL_clipboardevents.c"
    2.23 +			>
    2.24 +		</File>
    2.25 +		<File
    2.26 +			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
    2.27 +			>
    2.28 +		</File>
    2.29 +		<File
    2.30  			RelativePath="..\..\src\SDL_compat.c"
    2.31  			>
    2.32  		</File>
    2.33 @@ -841,10 +857,6 @@
    2.34  			>
    2.35  		</File>
    2.36  		<File
    2.37 -			RelativePath="..\..\src\video\SDL_stretch_c.h"
    2.38 -			>
    2.39 -		</File>
    2.40 -		<File
    2.41  			RelativePath="..\..\src\stdlib\SDL_string.c"
    2.42  			>
    2.43  		</File>
    2.44 @@ -945,6 +957,14 @@
    2.45  			>
    2.46  		</File>
    2.47  		<File
    2.48 +			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
    2.49 +			>
    2.50 +		</File>
    2.51 +		<File
    2.52 +			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
    2.53 +			>
    2.54 +		</File>
    2.55 +		<File
    2.56  			RelativePath="..\..\src\video\win32\SDL_win32events.c"
    2.57  			>
    2.58  		</File>
     3.1 --- a/VisualC/SDL/SDL_VS2008.vcproj	Tue Jul 13 15:05:45 2010 -0400
     3.2 +++ b/VisualC/SDL/SDL_VS2008.vcproj	Sun Jul 18 13:48:23 2010 -0400
     3.3 @@ -383,6 +383,10 @@
     3.4  				>
     3.5  			</File>
     3.6  			<File
     3.7 +				RelativePath="..\..\include\SDL_clipboard.h"
     3.8 +				>
     3.9 +			</File>
    3.10 +			<File
    3.11  				RelativePath="..\..\include\SDL_compat.h"
    3.12  				>
    3.13  			</File>
    3.14 @@ -716,6 +720,18 @@
    3.15  			>
    3.16  		</File>
    3.17  		<File
    3.18 +			RelativePath="..\..\src\video\SDL_clipboard.c"
    3.19 +			>
    3.20 +		</File>
    3.21 +		<File
    3.22 +			RelativePath="..\..\src\events\SDL_clipboardevents.c"
    3.23 +			>
    3.24 +		</File>
    3.25 +		<File
    3.26 +			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
    3.27 +			>
    3.28 +		</File>
    3.29 +		<File
    3.30  			RelativePath="..\..\src\SDL_compat.c"
    3.31  			>
    3.32  		</File>
    3.33 @@ -996,10 +1012,6 @@
    3.34  			>
    3.35  		</File>
    3.36  		<File
    3.37 -			RelativePath="..\..\src\video\SDL_stretch_c.h"
    3.38 -			>
    3.39 -		</File>
    3.40 -		<File
    3.41  			RelativePath="..\..\src\stdlib\SDL_string.c"
    3.42  			>
    3.43  		</File>
    3.44 @@ -1100,6 +1112,14 @@
    3.45  			>
    3.46  		</File>
    3.47  		<File
    3.48 +			RelativePath="..\..\src\video\win32\SDL_win32clipboard.c"
    3.49 +			>
    3.50 +		</File>
    3.51 +		<File
    3.52 +			RelativePath="..\..\src\video\win32\SDL_win32clipboard.h"
    3.53 +			>
    3.54 +		</File>
    3.55 +		<File
    3.56  			RelativePath="..\..\src\video\win32\SDL_win32events.c"
    3.57  			>
    3.58  		</File>
     4.1 --- a/VisualC/SDLmain/SDLmain_VS2008.vcproj	Tue Jul 13 15:05:45 2010 -0400
     4.2 +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj	Sun Jul 18 13:48:23 2010 -0400
     4.3 @@ -29,7 +29,7 @@
     4.4  			<Tool
     4.5  				Name="VCPreBuildEventTool"
     4.6  				Description="Making sure basic SDL headers are in place..."
     4.7 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
     4.8 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
     4.9  			/>
    4.10  			<Tool
    4.11  				Name="VCCustomBuildTool"
    4.12 @@ -166,7 +166,7 @@
    4.13  			<Tool
    4.14  				Name="VCPreBuildEventTool"
    4.15  				Description="Making sure basic SDL headers are in place..."
    4.16 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
    4.17 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.18  			/>
    4.19  			<Tool
    4.20  				Name="VCCustomBuildTool"
    4.21 @@ -303,7 +303,7 @@
    4.22  			<Tool
    4.23  				Name="VCPreBuildEventTool"
    4.24  				Description="Making sure basic SDL headers are in place..."
    4.25 -				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
    4.26 +				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
    4.27  			/>
    4.28  			<Tool
    4.29  				Name="VCCustomBuildTool"
     5.1 --- a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Tue Jul 13 15:05:45 2010 -0400
     5.2 +++ b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj	Sun Jul 18 13:48:23 2010 -0400
     5.3 @@ -105,6 +105,13 @@
     5.4  /* End PBXBuildFile section */
     5.5  
     5.6  /* Begin PBXContainerItemProxy section */
     5.7 +		04AB757011E563D200BE9753 /* PBXContainerItemProxy */ = {
     5.8 +			isa = PBXContainerItemProxy;
     5.9 +			containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
    5.10 +			proxyType = 2;
    5.11 +			remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
    5.12 +			remoteInfo = testsdl;
    5.13 +		};
    5.14  		FD1B489D0E313154007AB34E /* PBXContainerItemProxy */ = {
    5.15  			isa = PBXContainerItemProxy;
    5.16  			containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
    5.17 @@ -318,6 +325,7 @@
    5.18  			isa = PBXGroup;
    5.19  			children = (
    5.20  				FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */,
    5.21 +				04AB757111E563D200BE9753 /* testsdl.app */,
    5.22  			);
    5.23  			name = Products;
    5.24  			sourceTree = "<group>";
    5.25 @@ -523,6 +531,13 @@
    5.26  /* End PBXProject section */
    5.27  
    5.28  /* Begin PBXReferenceProxy section */
    5.29 +		04AB757111E563D200BE9753 /* testsdl.app */ = {
    5.30 +			isa = PBXReferenceProxy;
    5.31 +			fileType = wrapper.application;
    5.32 +			path = testsdl.app;
    5.33 +			remoteRef = 04AB757011E563D200BE9753 /* PBXContainerItemProxy */;
    5.34 +			sourceTree = BUILT_PRODUCTS_DIR;
    5.35 +		};
    5.36  		FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */ = {
    5.37  			isa = PBXReferenceProxy;
    5.38  			fileType = archive.ar;
    5.39 @@ -731,7 +746,7 @@
    5.40  				OTHER_CFLAGS = "";
    5.41  				PREBINDING = NO;
    5.42  				PRELINK_LIBS = "";
    5.43 -				SDKROOT = iphoneos2.0;
    5.44 +				SDKROOT = iphoneos3.2;
    5.45  			};
    5.46  			name = Debug;
    5.47  		};
    5.48 @@ -749,7 +764,7 @@
    5.49  				OTHER_CFLAGS = "";
    5.50  				PREBINDING = NO;
    5.51  				PRELINK_LIBS = "";
    5.52 -				SDKROOT = iphoneos2.0;
    5.53 +				SDKROOT = iphoneos3.2;
    5.54  			};
    5.55  			name = Release;
    5.56  		};
     6.1 --- a/Xcode-iPhoneOS/Demos/src/fireworks.c	Tue Jul 13 15:05:45 2010 -0400
     6.2 +++ b/Xcode-iPhoneOS/Demos/src/fireworks.c	Sun Jul 18 13:48:23 2010 -0400
     6.3 @@ -430,9 +430,7 @@
     6.4                  done = 1;
     6.5              }
     6.6              if (event.type == SDL_MOUSEBUTTONDOWN) {
     6.7 -                int which = event.button.which;
     6.8                  int x, y;
     6.9 -                SDL_SelectMouse(which);
    6.10                  SDL_GetMouseState(&x, &y);
    6.11                  spawnEmitterParticle(x, y);
    6.12              }
     7.1 --- a/Xcode-iPhoneOS/Demos/src/mixer.c	Tue Jul 13 15:05:45 2010 -0400
     7.2 +++ b/Xcode-iPhoneOS/Demos/src/mixer.c	Sun Jul 18 13:48:23 2010 -0400
     7.3 @@ -124,10 +124,9 @@
     7.4  
     7.5      int x, y, mouseIndex, i, drumIndex;
     7.6  
     7.7 -    mouseIndex = event->button.which;
     7.8 +    mouseIndex = 0;
     7.9      drumIndex = -1;
    7.10  
    7.11 -    SDL_SelectMouse(mouseIndex);
    7.12      SDL_GetMouseState(&x, &y);
    7.13      /* check if we hit any of the drum buttons */
    7.14      for (i = 0; i < NUM_DRUMS; i++) {
    7.15 @@ -153,7 +152,7 @@
    7.16  handleMouseButtonUp(SDL_Event * event)
    7.17  {
    7.18      int i;
    7.19 -    int mouseIndex = event->button.which;
    7.20 +    int mouseIndex = 0;
    7.21      /* check if this should cause any of the buttons to become unpressed */
    7.22      for (i = 0; i < NUM_DRUMS; i++) {
    7.23          if (buttons[i].touchIndex == mouseIndex) {
     8.1 --- a/Xcode-iPhoneOS/Demos/src/touch.c	Tue Jul 13 15:05:45 2010 -0400
     8.2 +++ b/Xcode-iPhoneOS/Demos/src/touch.c	Sun Jul 18 13:48:23 2010 -0400
     8.3 @@ -106,7 +106,6 @@
     8.4              done = 1;
     8.5              break;
     8.6          case SDL_MOUSEMOTION:
     8.7 -            SDL_SelectMouse(event.motion.which);        /* select 'mouse' (touch) that moved */
     8.8              state = SDL_GetMouseState(&x, &y);  /* get its location */
     8.9              SDL_GetRelativeMouseState(&dx, &dy);        /* find how much the mouse moved */
    8.10              if (state & SDL_BUTTON_LMASK) {     /* is the mouse (touch) down? */
     9.1 --- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Tue Jul 13 15:05:45 2010 -0400
     9.2 +++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Sun Jul 18 13:48:23 2010 -0400
     9.3 @@ -62,11 +62,16 @@
     9.4  		0098A5631195B4D900343137 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5621195B4D900343137 /* OpenGLES.framework */; };
     9.5  		0098A5651195B4D900343137 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5641195B4D900343137 /* UIKit.framework */; };
     9.6  		0098A5851195B5E200343137 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5841195B5E200343137 /* QuartzCore.framework */; };
     9.7 +		0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; };
     9.8 +		0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; };
     9.9  		043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */; };
    9.10  		043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */; };
    9.11  		043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */; };
    9.12  		043DD77210FD8A0000DED673 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */; };
    9.13  		04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04461DED0EA76BA3006C462D /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; };
    9.14 +		044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; };
    9.15 +		044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; };
    9.16 +		044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 044E5FB711E606EB0076F181 /* SDL_clipboard.c */; };
    9.17  		0463873F0F0B5B7D0041FD65 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387370F0B5B7D0041FD65 /* SDL_blendline.c */; };
    9.18  		046387400F0B5B7D0041FD65 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */; };
    9.19  		046387410F0B5B7D0041FD65 /* SDL_blendrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387390F0B5B7D0041FD65 /* SDL_blendrect.c */; };
    9.20 @@ -308,11 +313,16 @@
    9.21  		0098A5621195B4D900343137 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
    9.22  		0098A5641195B4D900343137 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
    9.23  		0098A5841195B5E200343137 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
    9.24 +		0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
    9.25 +		0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
    9.26  		043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; };
    9.27  		043DD76C10FD8A0000DED673 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = "<group>"; };
    9.28  		043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
    9.29  		043DD76E10FD8A0000DED673 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; };
    9.30  		04461DED0EA76BA3006C462D /* SDL_haptic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_haptic.h; path = ../../include/SDL_haptic.h; sourceTree = SOURCE_ROOT; };
    9.31 +		044E5FB311E6069F0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
    9.32 +		044E5FB411E6069F0076F181 /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; };
    9.33 +		044E5FB711E606EB0076F181 /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; };
    9.34  		046387370F0B5B7D0041FD65 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; };
    9.35  		046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; };
    9.36  		046387390F0B5B7D0041FD65 /* SDL_blendrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendrect.c; sourceTree = "<group>"; };
    9.37 @@ -826,19 +836,23 @@
    9.38  		FD99B8BC0DD52E5C00FB1D6B /* Public Headers */ = {
    9.39  			isa = PBXGroup;
    9.40  			children = (
    9.41 +				FD99B8CC0DD52EB400FB1D6B /* begin_code.h */,
    9.42 +				FD99B8CD0DD52EB400FB1D6B /* close_code.h */,
    9.43 +				FD99B8F50DD52EB400FB1D6B /* SDL.h */,
    9.44  				04F2AF531104ABC300D6DDF7 /* SDL_assert.h */,
    9.45  				04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */,
    9.46 -				FD99B8CC0DD52EB400FB1D6B /* begin_code.h */,
    9.47 -				FD99B8CD0DD52EB400FB1D6B /* close_code.h */,
    9.48  				FD99B8CF0DD52EB400FB1D6B /* SDL_audio.h */,
    9.49 +				044E5FB311E6069F0076F181 /* SDL_clipboard.h */,
    9.50  				FD99B8D10DD52EB400FB1D6B /* SDL_compat.h */,
    9.51 +				04B2ED061025CF9E00F9BC5F /* SDL_config.h */,
    9.52  				04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */,
    9.53 -				04B2ED061025CF9E00F9BC5F /* SDL_config.h */,
    9.54  				FD99B8DA0DD52EB400FB1D6B /* SDL_copying.h */,
    9.55  				FD99B8DB0DD52EB400FB1D6B /* SDL_cpuinfo.h */,
    9.56 +				FD99B8F60DD52EB400FB1D6B /* SDL_endian.h */,
    9.57  				FD99B8DC0DD52EB400FB1D6B /* SDL_error.h */,
    9.58  				FD99B8DD0DD52EB400FB1D6B /* SDL_events.h */,
    9.59  				04461DED0EA76BA3006C462D /* SDL_haptic.h */,
    9.60 +				044E5FB411E6069F0076F181 /* SDL_input.h */,
    9.61  				FD99B8DE0DD52EB400FB1D6B /* SDL_joystick.h */,
    9.62  				FD99B8DF0DD52EB400FB1D6B /* SDL_keyboard.h */,
    9.63  				FD99B8E00DD52EB400FB1D6B /* SDL_keysym.h */,
    9.64 @@ -865,8 +879,6 @@
    9.65  				FD99B8F20DD52EB400FB1D6B /* SDL_types.h */,
    9.66  				FD99B8F30DD52EB400FB1D6B /* SDL_version.h */,
    9.67  				FD99B8F40DD52EB400FB1D6B /* SDL_video.h */,
    9.68 -				FD99B8F50DD52EB400FB1D6B /* SDL.h */,
    9.69 -				FD99B8F60DD52EB400FB1D6B /* SDL_endian.h */,
    9.70  			);
    9.71  			name = "Public Headers";
    9.72  			sourceTree = "<group>";
    9.73 @@ -950,6 +962,8 @@
    9.74  				FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */,
    9.75  				FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */,
    9.76  				FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */,
    9.77 +				0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */,
    9.78 +				0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */,
    9.79  				FD99B9930DD52EDC00FB1D6B /* SDL_events.c */,
    9.80  				FD99B9940DD52EDC00FB1D6B /* SDL_events_c.h */,
    9.81  				FD99B9950DD52EDC00FB1D6B /* SDL_keyboard.c */,
    9.82 @@ -1023,6 +1037,7 @@
    9.83  		FDA682420DF2374D00F98A1A /* video */ = {
    9.84  			isa = PBXGroup;
    9.85  			children = (
    9.86 +				044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
    9.87  				FD689F090E26E5D900F90B21 /* uikit */,
    9.88  				FDA685F40DF244C800F98A1A /* dummy */,
    9.89  				0495E6850E97408800152DFE /* SDL_glfuncs.h */,
    9.90 @@ -1173,6 +1188,9 @@
    9.91  				043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */,
    9.92  				04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */,
    9.93  				006E9888119552DD001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
    9.94 +				044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */,
    9.95 +				044E5FB611E6069F0076F181 /* SDL_input.h in Headers */,
    9.96 +				0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
    9.97  			);
    9.98  			runOnlyForDeploymentPostprocessing = 0;
    9.99  		};
   9.100 @@ -1411,6 +1429,8 @@
   9.101  				56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */,
   9.102  				56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */,
   9.103  				006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
   9.104 +				044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */,
   9.105 +				0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */,
   9.106  			);
   9.107  			runOnlyForDeploymentPostprocessing = 0;
   9.108  		};
    10.1 --- a/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Tue Jul 13 15:05:45 2010 -0400
    10.2 +++ b/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj	Sun Jul 18 13:48:23 2010 -0400
    10.3 @@ -287,6 +287,13 @@
    10.4  /* End PBXBuildFile section */
    10.5  
    10.6  /* Begin PBXContainerItemProxy section */
    10.7 +		0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */ = {
    10.8 +			isa = PBXContainerItemProxy;
    10.9 +			containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
   10.10 +			proxyType = 2;
   10.11 +			remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
   10.12 +			remoteInfo = testsdl;
   10.13 +		};
   10.14  		FD1B48B70E3131CA007AB34E /* PBXContainerItemProxy */ = {
   10.15  			isa = PBXContainerItemProxy;
   10.16  			containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
   10.17 @@ -298,9 +305,7 @@
   10.18  
   10.19  /* Begin PBXFileReference section */
   10.20  		1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; };
   10.21 -		56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "testpower-Info.plist"; sourceTree = "<group>"; };
   10.22  		56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; };
   10.23 -		56ED050F118A8FE400A56AA6 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; };
   10.24  		56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; };
   10.25  		FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDLiPhoneOS.xcodeproj; path = ../SDL/SDLiPhoneOS.xcodeproj; sourceTree = SOURCE_ROOT; };
   10.26  		FDA8A7400E2D0F1600EA573E /* testalpha.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testalpha.c; path = ../../test/testalpha.c; sourceTree = SOURCE_ROOT; };
   10.27 @@ -861,14 +866,11 @@
   10.28  		29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
   10.29  			isa = PBXGroup;
   10.30  			children = (
   10.31 -				56ED0510118A904200A56AA6 /* testpower.c */,
   10.32  				FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */,
   10.33  				FDA8AAD60E2D339A00EA573E /* Resources */,
   10.34  				FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */,
   10.35  				FDA8A73B0E2D0F0400EA573E /* src */,
   10.36  				19C28FACFE9D520D11CA2CBB /* Products */,
   10.37 -				56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */,
   10.38 -				56ED050F118A8FE400A56AA6 /* Info copy.plist */,
   10.39  			);
   10.40  			name = CustomTemplate;
   10.41  			sourceTree = "<group>";
   10.42 @@ -877,6 +879,7 @@
   10.43  			isa = PBXGroup;
   10.44  			children = (
   10.45  				FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */,
   10.46 +				0466EE7011E565E4000198A4 /* testsdl.app */,
   10.47  			);
   10.48  			name = Products;
   10.49  			sourceTree = "<group>";
   10.50 @@ -910,6 +913,7 @@
   10.51  				FDA8A7540E2D0F1600EA573E /* testoverlay2.c */,
   10.52  				FDA8A7550E2D0F1600EA573E /* testpalette.c */,
   10.53  				FDA8A7560E2D0F1600EA573E /* testplatform.c */,
   10.54 +				56ED0510118A904200A56AA6 /* testpower.c */,
   10.55  				FDA8A7570E2D0F1600EA573E /* testsem.c */,
   10.56  				FDA8A7580E2D0F1600EA573E /* testsprite.c */,
   10.57  				FDA8A7590E2D0F1600EA573E /* testsprite2.c */,
   10.58 @@ -1502,6 +1506,13 @@
   10.59  /* End PBXProject section */
   10.60  
   10.61  /* Begin PBXReferenceProxy section */
   10.62 +		0466EE7011E565E4000198A4 /* testsdl.app */ = {
   10.63 +			isa = PBXReferenceProxy;
   10.64 +			fileType = wrapper.application;
   10.65 +			path = testsdl.app;
   10.66 +			remoteRef = 0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */;
   10.67 +			sourceTree = BUILT_PRODUCTS_DIR;
   10.68 +		};
   10.69  		FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */ = {
   10.70  			isa = PBXReferenceProxy;
   10.71  			fileType = archive.ar;
   10.72 @@ -2034,7 +2045,7 @@
   10.73  				ONLY_ACTIVE_ARCH = YES;
   10.74  				PREBINDING = NO;
   10.75  				"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
   10.76 -				SDKROOT = iphoneos2.2.1;
   10.77 +				SDKROOT = iphoneos3.2;
   10.78  			};
   10.79  			name = Debug;
   10.80  		};
   10.81 @@ -2049,7 +2060,7 @@
   10.82  				HEADER_SEARCH_PATHS = ../../include;
   10.83  				PREBINDING = NO;
   10.84  				"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
   10.85 -				SDKROOT = iphoneos2.2.1;
   10.86 +				SDKROOT = iphoneos3.2;
   10.87  			};
   10.88  			name = Release;
   10.89  		};
    11.1 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Tue Jul 13 15:05:45 2010 -0400
    11.2 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Jul 18 13:48:23 2010 -0400
    11.3 @@ -438,6 +438,24 @@
    11.4  		00D8DA281195093100638393 /* SDL_at.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA151195093100638393 /* SDL_at.c */; };
    11.5  		00D8DA291195093100638393 /* surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA181195093100638393 /* surface.c */; };
    11.6  		00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; };
    11.7 +		0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; };
    11.8 +		0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; };
    11.9 +		0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; };
   11.10 +		0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; };
   11.11 +		0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; };
   11.12 +		0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; };
   11.13 +		0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; };
   11.14 +		0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; };
   11.15 +		0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; };
   11.16 +		0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; };
   11.17 +		0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; };
   11.18 +		0420498111E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; };
   11.19 +		0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; };
   11.20 +		0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; };
   11.21 +		0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; };
   11.22 +		0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; };
   11.23 +		044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
   11.24 +		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
   11.25  		046B91EC0A11B53500FB151C /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B91E90A11B53500FB151C /* SDL_sysloadso.c */; };
   11.26  		046B91ED0A11B53500FB151C /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B91E90A11B53500FB151C /* SDL_sysloadso.c */; };
   11.27  		046B92130A11B8AD00FB151C /* SDL_dlcompat.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B92100A11B8AD00FB151C /* SDL_dlcompat.c */; };
   11.28 @@ -446,9 +464,17 @@
   11.29  		04DB838D10FD8C81000519B5 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */; };
   11.30  		04DB838E10FD8C81000519B5 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838A10FD8C81000519B5 /* SDL_blendfillrect.c */; };
   11.31  		04DB838F10FD8C81000519B5 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */; };
   11.32 +		04DEA57111E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; settings = {ATTRIBUTES = (Public, ); }; };
   11.33 +		04DEA57311E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; };
   11.34 +		04DEA57511E6009000386CAC /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57411E6009000386CAC /* SDL_clipboard.c */; };
   11.35 +		04DEA57611E6009000386CAC /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57411E6009000386CAC /* SDL_clipboard.c */; };
   11.36 +		04DEA57911E600A600386CAC /* SDL_cocoaclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */; };
   11.37 +		04DEA57A11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */; };
   11.38 +		04DEA57B11E600A600386CAC /* SDL_cocoaclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */; };
   11.39 +		04DEA57C11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */; };
   11.40  		04F2AF661104AC0800D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF651104AC0800D6DDF7 /* SDL_assert.c */; };
   11.41  		04F2AF671104AC0800D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF651104AC0800D6DDF7 /* SDL_assert.c */; };
   11.42 -		04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; };
   11.43 +		04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
   11.44  		04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; };
   11.45  		BECDF62E0761BA81005FE872 /* SDL_audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 01538330006D78D67F000001 /* SDL_audio.c */; };
   11.46  		BECDF62F0761BA81005FE872 /* SDL_audiocvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 01538331006D78D67F000001 /* SDL_audiocvt.c */; };
   11.47 @@ -795,10 +821,23 @@
   11.48  		01538439006D7D947F000001 /* SDL_fatal.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL_fatal.c; path = ../../src/SDL_fatal.c; sourceTree = SOURCE_ROOT; };
   11.49  		0153843C006D7D947F000001 /* SDL.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL.c; path = ../../src/SDL.c; sourceTree = SOURCE_ROOT; };
   11.50  		01538445006D7EC67F000001 /* SDL_thread.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL_thread.c; path = ../../src/thread/SDL_thread.c; sourceTree = SOURCE_ROOT; };
   11.51 +		0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
   11.52 +		0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
   11.53 +		0420497411E6F052007E7EC9 /* blank_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blank_cursor.h; sourceTree = "<group>"; };
   11.54 +		0420497511E6F052007E7EC9 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
   11.55 +		0420497611E6F052007E7EC9 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
   11.56 +		0420497711E6F052007E7EC9 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
   11.57 +		0420497811E6F052007E7EC9 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
   11.58 +		0420497911E6F052007E7EC9 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
   11.59 +		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
   11.60  		046B91E90A11B53500FB151C /* SDL_sysloadso.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_sysloadso.c; sourceTree = "<group>"; };
   11.61  		046B92100A11B8AD00FB151C /* SDL_dlcompat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_dlcompat.c; sourceTree = "<group>"; };
   11.62  		04DB838A10FD8C81000519B5 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
   11.63  		04DB838B10FD8C81000519B5 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; };
   11.64 +		04DEA56F11E6006A00386CAC /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; };
   11.65 +		04DEA57411E6009000386CAC /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; };
   11.66 +		04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaclipboard.h; sourceTree = "<group>"; };
   11.67 +		04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaclipboard.m; sourceTree = "<group>"; };
   11.68  		04F2AF651104AC0800D6DDF7 /* SDL_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_assert.c; path = ../../src/SDL_assert.c; sourceTree = SOURCE_ROOT; };
   11.69  		04F2AF681104AC4500D6DDF7 /* SDL_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert.h; path = ../../include/SDL_assert.h; sourceTree = SOURCE_ROOT; };
   11.70  		083E489D006D88D97F000001 /* SDL_joystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_joystick.c; sourceTree = "<group>"; };
   11.71 @@ -1033,6 +1072,8 @@
   11.72  		00CFA703106B498A00758660 /* cocoa */ = {
   11.73  			isa = PBXGroup;
   11.74  			children = (
   11.75 +				04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */,
   11.76 +				04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */,
   11.77  				00CFA704106B498A00758660 /* SDL_cocoaevents.h */,
   11.78  				00CFA705106B498A00758660 /* SDL_cocoaevents.m */,
   11.79  				00CFA706106B498A00758660 /* SDL_cocoakeyboard.h */,
   11.80 @@ -1312,6 +1353,14 @@
   11.81  		01538367006D79147F000001 /* events */ = {
   11.82  			isa = PBXGroup;
   11.83  			children = (
   11.84 +				0420497411E6F052007E7EC9 /* blank_cursor.h */,
   11.85 +				0420497511E6F052007E7EC9 /* default_cursor.h */,
   11.86 +				0420497611E6F052007E7EC9 /* scancodes_darwin.h */,
   11.87 +				0420497711E6F052007E7EC9 /* scancodes_linux.h */,
   11.88 +				0420497811E6F052007E7EC9 /* scancodes_win32.h */,
   11.89 +				0420497911E6F052007E7EC9 /* scancodes_xfree86.h */,
   11.90 +				0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */,
   11.91 +				0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */,
   11.92  				00CFA6C2106B480800758660 /* SDL_events_c.h */,
   11.93  				01538369006D79147F000001 /* SDL_events.c */,
   11.94  				00CFA6C3106B480800758660 /* SDL_keyboard_c.h */,
   11.95 @@ -1380,6 +1429,7 @@
   11.96  				00CFA7FA106B49B600758660 /* SDL_blit.c */,
   11.97  				00CFA7FB106B49B600758660 /* SDL_blit.h */,
   11.98  				00CFA7FC106B49B600758660 /* SDL_bmp.c */,
   11.99 +				04DEA57411E6009000386CAC /* SDL_clipboard.c */,
  11.100  				00CFA7FD106B49B600758660 /* SDL_draw.h */,
  11.101  				00CFA7FE106B49B600758660 /* SDL_drawline.c */,
  11.102  				00CFA7FF106B49B600758660 /* SDL_drawpoint.c */,
  11.103 @@ -1420,12 +1470,13 @@
  11.104  		0153844A006D81B07F000001 /* Public Headers */ = {
  11.105  			isa = PBXGroup;
  11.106  			children = (
  11.107 -				04F2AF681104AC4500D6DDF7 /* SDL_assert.h */,
  11.108  				0C5AF5E501191D2B7F000001 /* begin_code.h */,
  11.109  				0C5AF5E601191D2B7F000001 /* close_code.h */,
  11.110  				0C5AF5FF01191D2B7F000001 /* SDL.h */,
  11.111 +				04F2AF681104AC4500D6DDF7 /* SDL_assert.h */,
  11.112  				00CFA67A106B44CE00758660 /* SDL_atomic.h */,
  11.113  				0C5AF5E801191D2B7F000001 /* SDL_audio.h */,
  11.114 +				044E5F8411E6051C0076F181 /* SDL_clipboard.h */,
  11.115  				00CFA67B106B44CE00758660 /* SDL_compat.h */,
  11.116  				00162D3709BD1FA90037C8D0 /* SDL_config.h */,
  11.117  				00162D3409BD1FA90037C8D0 /* SDL_config_macosx.h */,
  11.118 @@ -1435,6 +1486,7 @@
  11.119  				0C5AF5ED01191D2B7F000001 /* SDL_error.h */,
  11.120  				0C5AF5EE01191D2B7F000001 /* SDL_events.h */,
  11.121  				00CFA67C106B44CE00758660 /* SDL_haptic.h */,
  11.122 +				04DEA56F11E6006A00386CAC /* SDL_input.h */,
  11.123  				0C5AF5F001191D2B7F000001 /* SDL_joystick.h */,
  11.124  				0C5AF5F101191D2B7F000001 /* SDL_keyboard.h */,
  11.125  				0C5AF5F201191D2B7F000001 /* SDL_keysym.h */,
  11.126 @@ -1743,6 +1795,16 @@
  11.127  				00A6EBDA1078D569001EEA06 /* SDL_revision.h in Headers */,
  11.128  				04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */,
  11.129  				006E95B011952992001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
  11.130 +				04DEA57111E6006A00386CAC /* SDL_input.h in Headers */,
  11.131 +				04DEA57911E600A600386CAC /* SDL_cocoaclipboard.h in Headers */,
  11.132 +				044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */,
  11.133 +				0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
  11.134 +				0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */,
  11.135 +				0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */,
  11.136 +				0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */,
  11.137 +				0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */,
  11.138 +				0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */,
  11.139 +				0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */,
  11.140  			);
  11.141  			runOnlyForDeploymentPostprocessing = 0;
  11.142  		};
  11.143 @@ -1843,6 +1905,16 @@
  11.144  				00A6EBDB1078D569001EEA06 /* SDL_revision.h in Headers */,
  11.145  				04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */,
  11.146  				006E95B211952992001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
  11.147 +				04DEA57311E6006A00386CAC /* SDL_input.h in Headers */,
  11.148 +				04DEA57B11E600A600386CAC /* SDL_cocoaclipboard.h in Headers */,
  11.149 +				044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */,
  11.150 +				0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
  11.151 +				0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */,
  11.152 +				0420498111E6F052007E7EC9 /* default_cursor.h in Headers */,
  11.153 +				0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */,
  11.154 +				0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */,
  11.155 +				0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */,
  11.156 +				0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */,
  11.157  			);
  11.158  			runOnlyForDeploymentPostprocessing = 0;
  11.159  		};
  11.160 @@ -2035,7 +2107,7 @@
  11.161  			);
  11.162  			runOnlyForDeploymentPostprocessing = 0;
  11.163  			shellPath = /bin/sh;
  11.164 -			shellScript = "# The underlying scripts require calling hg to get revision info.\n# Since hg may not be in the standard Xcode path, I am sourcing .bashrc\n# But I don't know what to do if people are using other shells.\nsource ~/.bashrc\nsh ../../build-scripts/updaterev.sh\n";
  11.165 +			shellScript = "# The underlying scripts require calling hg to get revision info.\n# Since hg may not be in the standard Xcode path, I am sourcing .bashrc\n# But I don't know what to do if people are using other shells.\nif test -f ~/.bash_profile; then source ~/.bash_profile; fi\nif test -f ~/.bashrc; then source ~/.bashrc; fi\nsh ../../build-scripts/updaterev.sh\n";
  11.166  		};
  11.167  		0083103E1072EA5700A531F1 /* ShellScript */ = {
  11.168  			isa = PBXShellScriptBuildPhase;
  11.169 @@ -2202,6 +2274,9 @@
  11.170  				04DB838D10FD8C81000519B5 /* SDL_drawrect.c in Sources */,
  11.171  				04F2AF661104AC0800D6DDF7 /* SDL_assert.c in Sources */,
  11.172  				006E95B111952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
  11.173 +				04DEA57511E6009000386CAC /* SDL_clipboard.c in Sources */,
  11.174 +				04DEA57A11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */,
  11.175 +				0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */,
  11.176  			);
  11.177  			runOnlyForDeploymentPostprocessing = 0;
  11.178  		};
  11.179 @@ -2318,6 +2393,9 @@
  11.180  				04DB838F10FD8C81000519B5 /* SDL_drawrect.c in Sources */,
  11.181  				04F2AF671104AC0800D6DDF7 /* SDL_assert.c in Sources */,
  11.182  				006E95B311952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
  11.183 +				04DEA57611E6009000386CAC /* SDL_clipboard.c in Sources */,
  11.184 +				04DEA57C11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */,
  11.185 +				0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */,
  11.186  			);
  11.187  			runOnlyForDeploymentPostprocessing = 0;
  11.188  		};
    12.1 --- a/include/SDL.h	Tue Jul 13 15:05:45 2010 -0400
    12.2 +++ b/include/SDL.h	Sun Jul 18 13:48:23 2010 -0400
    12.3 @@ -78,6 +78,7 @@
    12.4  #include "SDL_stdinc.h"
    12.5  #include "SDL_atomic.h"
    12.6  #include "SDL_audio.h"
    12.7 +#include "SDL_clipboard.h"
    12.8  #include "SDL_cpuinfo.h"
    12.9  #include "SDL_endian.h"
   12.10  #include "SDL_error.h"
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/include/SDL_clipboard.h	Sun Jul 18 13:48:23 2010 -0400
    13.3 @@ -0,0 +1,76 @@
    13.4 +/*
    13.5 +    SDL - Simple DirectMedia Layer
    13.6 +    Copyright (C) 1997-2010 Sam Lantinga
    13.7 +
    13.8 +    This library is free software; you can redistribute it and/or
    13.9 +    modify it under the terms of the GNU Lesser General Public
   13.10 +    License as published by the Free Software Foundation; either
   13.11 +    version 2.1 of the License, or (at your option) any later version.
   13.12 +
   13.13 +    This library is distributed in the hope that it will be useful,
   13.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 +    Lesser General Public License for more details.
   13.17 +
   13.18 +    You should have received a copy of the GNU Lesser General Public
   13.19 +    License along with this library; if not, write to the Free Software
   13.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 +
   13.22 +    Sam Lantinga
   13.23 +    slouken@libsdl.org
   13.24 +*/
   13.25 +
   13.26 +/**
   13.27 + * \file SDL_clipboard.h
   13.28 + *
   13.29 + * Include file for SDL clipboard handling
   13.30 + */
   13.31 +
   13.32 +#ifndef _SDL_clipboard_h
   13.33 +#define _SDL_clipboard_h
   13.34 +
   13.35 +#include "SDL_stdinc.h"
   13.36 +
   13.37 +#include "begin_code.h"
   13.38 +/* Set up for C function definitions, even when using C++ */
   13.39 +#ifdef __cplusplus
   13.40 +/* *INDENT-OFF* */
   13.41 +extern "C" {
   13.42 +/* *INDENT-ON* */
   13.43 +#endif
   13.44 +
   13.45 +/* Function prototypes */
   13.46 +
   13.47 +/**
   13.48 + * \brief Put UTF-8 text into the clipboard
   13.49 + *
   13.50 + * \sa SDL_GetClipboardText()
   13.51 + */
   13.52 +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
   13.53 +
   13.54 +/**
   13.55 + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
   13.56 + *
   13.57 + * \sa SDL_SetClipboardText()
   13.58 + */
   13.59 +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
   13.60 +
   13.61 +/**
   13.62 + * \brief Returns whether the clipboard has text
   13.63 + *
   13.64 + * \sa SDL_GetClipboardText()
   13.65 + */
   13.66 +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
   13.67 +
   13.68 +
   13.69 +/* Ends C function definitions when using C++ */
   13.70 +#ifdef __cplusplus
   13.71 +/* *INDENT-OFF* */
   13.72 +}
   13.73 +/* *INDENT-ON* */
   13.74 +#endif
   13.75 +#include "close_code.h"
   13.76 +
   13.77 +#endif /* _SDL_clipboard_h */
   13.78 +
   13.79 +/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/include/SDL_config_iphoneos.h	Tue Jul 13 15:05:45 2010 -0400
    14.2 +++ b/include/SDL_config_iphoneos.h	Sun Jul 18 13:48:23 2010 -0400
    14.3 @@ -145,12 +145,9 @@
    14.4  #define SDL_POWER_UIKIT 1
    14.5  
    14.6  /* enable iPhone keyboard support */
    14.7 -#define SDL_IPHONE_KEYBOARD 0
    14.8 +#define SDL_IPHONE_KEYBOARD 1
    14.9  
   14.10 -/* Enable emulation of multiple mice through multi-touch */
   14.11 -#define SDL_IPHONE_MULTIPLE_MICE 1
   14.12 -
   14.13 -/* Set max recognized G-force from acceleromter
   14.14 +/* Set max recognized G-force from accelerometer
   14.15     See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
   14.16   */
   14.17  #define SDL_IPHONE_MAX_GFORCE 5.0
    15.1 --- a/include/SDL_events.h	Tue Jul 13 15:05:45 2010 -0400
    15.2 +++ b/include/SDL_events.h	Sun Jul 18 13:48:23 2010 -0400
    15.3 @@ -90,6 +90,9 @@
    15.4      SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
    15.5      SDL_JOYBUTTONUP,            /**< Joystick button released */
    15.6  
    15.7 +    /* Clipboard events */
    15.8 +    SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */
    15.9 +
   15.10      /* Obsolete events */
   15.11      SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
   15.12      SDL_EVENT_COMPAT2,
    16.1 --- a/include/SDL_pixels.h	Tue Jul 13 15:05:45 2010 -0400
    16.2 +++ b/include/SDL_pixels.h	Sun Jul 18 13:48:23 2010 -0400
    16.3 @@ -112,8 +112,7 @@
    16.4      SDL_PACKEDLAYOUT_1010102
    16.5  };
    16.6  
    16.7 -#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \
    16.8 -    ((A) | ((B) << 8) | ((C) << 16) | ((D) << 24))
    16.9 +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
   16.10  
   16.11  #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
   16.12      ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
    17.1 --- a/include/SDL_stdinc.h	Tue Jul 13 15:05:45 2010 -0400
    17.2 +++ b/include/SDL_stdinc.h	Sun Jul 18 13:48:23 2010 -0400
    17.3 @@ -1,788 +1,795 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2010 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -*/
   17.25 -
   17.26 -/**
   17.27 - *  \file SDL_stdinc.h
   17.28 - *  
   17.29 - *  This is a general header that includes C language support.
   17.30 - */
   17.31 -
   17.32 -#ifndef _SDL_stdinc_h
   17.33 -#define _SDL_stdinc_h
   17.34 -
   17.35 -#include "SDL_config.h"
   17.36 -
   17.37 -
   17.38 -#ifdef HAVE_SYS_TYPES_H
   17.39 -#include <sys/types.h>
   17.40 -#endif
   17.41 -#ifdef HAVE_STDIO_H
   17.42 -#include <stdio.h>
   17.43 -#endif
   17.44 -#if defined(STDC_HEADERS)
   17.45 -# include <stdlib.h>
   17.46 -# include <stddef.h>
   17.47 -# include <stdarg.h>
   17.48 -#else
   17.49 -# if defined(HAVE_STDLIB_H)
   17.50 -#  include <stdlib.h>
   17.51 -# elif defined(HAVE_MALLOC_H)
   17.52 -#  include <malloc.h>
   17.53 -# endif
   17.54 -# if defined(HAVE_STDDEF_H)
   17.55 -#  include <stddef.h>
   17.56 -# endif
   17.57 -# if defined(HAVE_STDARG_H)
   17.58 -#  include <stdarg.h>
   17.59 -# endif
   17.60 -#endif
   17.61 -#ifdef HAVE_STRING_H
   17.62 -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
   17.63 -#  include <memory.h>
   17.64 -# endif
   17.65 -# include <string.h>
   17.66 -#endif
   17.67 -#ifdef HAVE_STRINGS_H
   17.68 -# include <strings.h>
   17.69 -#endif
   17.70 -#if defined(HAVE_INTTYPES_H)
   17.71 -# include <inttypes.h>
   17.72 -#elif defined(HAVE_STDINT_H)
   17.73 -# include <stdint.h>
   17.74 -#endif
   17.75 -#ifdef HAVE_CTYPE_H
   17.76 -# include <ctype.h>
   17.77 -#endif
   17.78 -#ifdef HAVE_MATH_H
   17.79 -# include <math.h>
   17.80 -#endif
   17.81 -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
   17.82 -# include <iconv.h>
   17.83 -#endif
   17.84 -
   17.85 -/**
   17.86 - *  The number of elements in an array.
   17.87 - */
   17.88 -#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
   17.89 -#define SDL_TABLESIZE(table)	SDL_arraysize(table)
   17.90 -
   17.91 -/**
   17.92 - *  \name Cast operators
   17.93 - *  
   17.94 - *  Use proper C++ casts when compiled as C++ to be compatible with the option
   17.95 - *  -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
   17.96 - */
   17.97 -/*@{*/
   17.98 -#ifdef __cplusplus
   17.99 -#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
  17.100 -#define SDL_static_cast(type, expression) static_cast<type>(expression)
  17.101 -#else
  17.102 -#define SDL_reinterpret_cast(type, expression) ((type)(expression))
  17.103 -#define SDL_static_cast(type, expression) ((type)(expression))
  17.104 -#endif
  17.105 -/*@}*//*Cast operators*/
  17.106 -
  17.107 -/**
  17.108 - *  \name Basic data types
  17.109 - */
  17.110 -/*@{*/
  17.111 -
  17.112 -typedef enum
  17.113 -{
  17.114 -    SDL_FALSE = 0,
  17.115 -    SDL_TRUE = 1
  17.116 -} SDL_bool;
  17.117 -
  17.118 -/**
  17.119 - * \brief A signed 8-bit integer type.
  17.120 - */
  17.121 -typedef int8_t Sint8;
  17.122 -/**
  17.123 - * \brief An unsigned 8-bit integer type.
  17.124 - */
  17.125 -typedef uint8_t Uint8;
  17.126 -/**
  17.127 - * \brief A signed 16-bit integer type.
  17.128 - */
  17.129 -typedef int16_t Sint16;
  17.130 -/**
  17.131 - * \brief An unsigned 16-bit integer type.
  17.132 - */
  17.133 -typedef uint16_t Uint16;
  17.134 -/**
  17.135 - * \brief A signed 32-bit integer type.
  17.136 - */
  17.137 -typedef int32_t Sint32;
  17.138 -/**
  17.139 - * \brief An unsigned 32-bit integer type.
  17.140 - */
  17.141 -typedef uint32_t Uint32;
  17.142 -
  17.143 -#ifdef SDL_HAS_64BIT_TYPE
  17.144 -/**
  17.145 - * \brief A signed 64-bit integer type.
  17.146 - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
  17.147 - */
  17.148 -typedef int64_t Sint64;
  17.149 -/**
  17.150 - * \brief An unsigned 64-bit integer type.
  17.151 - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
  17.152 - */
  17.153 -typedef uint64_t Uint64;
  17.154 -#else
  17.155 -/* This is really just a hack to prevent the compiler from complaining */
  17.156 -typedef Sint32 Sint64;
  17.157 -typedef Uint32 Uint64;
  17.158 -#endif
  17.159 -
  17.160 -/*@}*//*Basic data types*/
  17.161 -
  17.162 -
  17.163 -#define SDL_COMPILE_TIME_ASSERT(name, x)               \
  17.164 -       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
  17.165 -/** \cond */
  17.166 -#ifndef DOXYGEN_SHOULD_IGNORE_THIS
  17.167 -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
  17.168 -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
  17.169 -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
  17.170 -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
  17.171 -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
  17.172 -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
  17.173 -#ifndef __NINTENDODS__          /* TODO: figure out why the following happens:
  17.174 -                                   include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
  17.175 -                                   include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
  17.176 -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
  17.177 -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
  17.178 -#endif
  17.179 -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  17.180 -/** \endcond */
  17.181 -
  17.182 -/* Check to make sure enums are the size of ints, for structure packing.
  17.183 -   For both Watcom C/C++ and Borland C/C++ the compiler option that makes
  17.184 -   enums having the size of an int must be enabled.
  17.185 -   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
  17.186 -*/
  17.187 -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
  17.188 -#ifdef __MWERKS__
  17.189 -#pragma enumsalwaysint on
  17.190 -#endif
  17.191 -
  17.192 -/** \cond */
  17.193 -#ifndef DOXYGEN_SHOULD_IGNORE_THIS
  17.194 -#ifndef __NINTENDODS__          /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
  17.195 -typedef enum
  17.196 -{
  17.197 -    DUMMY_ENUM_VALUE
  17.198 -} SDL_DUMMY_ENUM;
  17.199 -
  17.200 -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
  17.201 -#endif
  17.202 -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  17.203 -/** \endcond */
  17.204 -
  17.205 -#include "begin_code.h"
  17.206 -/* Set up for C function definitions, even when using C++ */
  17.207 -#ifdef __cplusplus
  17.208 -/* *INDENT-OFF* */
  17.209 -extern "C" {
  17.210 -/* *INDENT-ON* */
  17.211 -#endif
  17.212 -
  17.213 -#ifdef HAVE_MALLOC
  17.214 -#define SDL_malloc	malloc
  17.215 -#else
  17.216 -extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
  17.217 -#endif
  17.218 -
  17.219 -#ifdef HAVE_CALLOC
  17.220 -#define SDL_calloc	calloc
  17.221 -#else
  17.222 -extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
  17.223 -#endif
  17.224 -
  17.225 -#ifdef HAVE_REALLOC
  17.226 -#define SDL_realloc	realloc
  17.227 -#else
  17.228 -extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
  17.229 -#endif
  17.230 -
  17.231 -#ifdef HAVE_FREE
  17.232 -#define SDL_free	free
  17.233 -#else
  17.234 -extern DECLSPEC void SDLCALL SDL_free(void *mem);
  17.235 -#endif
  17.236 -
  17.237 -#if defined(HAVE_ALLOCA) && !defined(alloca)
  17.238 -# if defined(HAVE_ALLOCA_H)
  17.239 -#  include <alloca.h>
  17.240 -# elif defined(__GNUC__)
  17.241 -#  define alloca __builtin_alloca
  17.242 -# elif defined(_MSC_VER)
  17.243 -#  include <malloc.h>
  17.244 -#  define alloca _alloca
  17.245 -# elif defined(__WATCOMC__)
  17.246 -#  include <malloc.h>
  17.247 -# elif defined(__BORLANDC__)
  17.248 -#  include <malloc.h>
  17.249 -# elif defined(__DMC__)
  17.250 -#  include <stdlib.h>
  17.251 -# elif defined(__AIX__)
  17.252 -#pragma alloca
  17.253 -# elif defined(__MRC__)
  17.254 -void *alloca(unsigned);
  17.255 -# else
  17.256 -char *alloca();
  17.257 -# endif
  17.258 -#endif
  17.259 -#ifdef HAVE_ALLOCA
  17.260 -#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*(count))
  17.261 -#define SDL_stack_free(data)
  17.262 -#else
  17.263 -#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*(count))
  17.264 -#define SDL_stack_free(data)            SDL_free(data)
  17.265 -#endif
  17.266 -
  17.267 -#ifdef HAVE_GETENV
  17.268 -#define SDL_getenv	getenv
  17.269 -#else
  17.270 -extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
  17.271 -#endif
  17.272 -
  17.273 -/* SDL_putenv() has moved to SDL_compat. */
  17.274 -#ifdef HAVE_SETENV
  17.275 -#define SDL_setenv	setenv
  17.276 -#else
  17.277 -extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
  17.278 -                                       int overwrite);
  17.279 -#endif
  17.280 -
  17.281 -#ifdef HAVE_QSORT
  17.282 -#define SDL_qsort	qsort
  17.283 -#else
  17.284 -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
  17.285 -                                       int (*compare) (const void *,
  17.286 -                                                       const void *));
  17.287 -#endif
  17.288 -
  17.289 -#ifdef HAVE_ABS
  17.290 -#define SDL_abs		abs
  17.291 -#else
  17.292 -#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
  17.293 -#endif
  17.294 -
  17.295 -#define SDL_min(x, y)	(((x) < (y)) ? (x) : (y))
  17.296 -#define SDL_max(x, y)	(((x) > (y)) ? (x) : (y))
  17.297 -
  17.298 -#ifdef HAVE_CTYPE_H
  17.299 -#define SDL_isdigit(X)  isdigit(X)
  17.300 -#define SDL_isspace(X)  isspace(X)
  17.301 -#define SDL_toupper(X)  toupper(X)
  17.302 -#define SDL_tolower(X)  tolower(X)
  17.303 -#else
  17.304 -#define SDL_isdigit(X)  (((X) >= '0') && ((X) <= '9'))
  17.305 -#define SDL_isspace(X)  (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
  17.306 -#define SDL_toupper(X)  (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
  17.307 -#define SDL_tolower(X)  (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
  17.308 -#endif
  17.309 -
  17.310 -#ifdef HAVE_MEMSET
  17.311 -#define SDL_memset      memset
  17.312 -#else
  17.313 -extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
  17.314 -#endif
  17.315 -#define SDL_zero(x)	SDL_memset(&(x), 0, sizeof((x)))
  17.316 -#define SDL_zerop(x)	SDL_memset((x), 0, sizeof(*(x)))
  17.317 -
  17.318 -#if defined(__GNUC__) && defined(i386)
  17.319 -#define SDL_memset4(dst, val, len)				\
  17.320 -do {								\
  17.321 -	int u0, u1, u2;						\
  17.322 -	__asm__ __volatile__ (					\
  17.323 -		"cld\n\t"					\
  17.324 -		"rep ; stosl\n\t"				\
  17.325 -		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
  17.326 -		: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))	\
  17.327 -		: "memory" );					\
  17.328 -} while(0)
  17.329 -#endif
  17.330 -#ifndef SDL_memset4
  17.331 -#define SDL_memset4(dst, val, len)		\
  17.332 -do {						\
  17.333 -	unsigned _count = (len);		\
  17.334 -	unsigned _n = (_count + 3) / 4;		\
  17.335 -	Uint32 *_p = SDL_static_cast(Uint32 *, dst);		\
  17.336 -	Uint32 _val = (val);			\
  17.337 -	if (len == 0) break;			\
  17.338 -        switch (_count % 4) {			\
  17.339 -        case 0: do {    *_p++ = _val;		\
  17.340 -        case 3:         *_p++ = _val;		\
  17.341 -        case 2:         *_p++ = _val;		\
  17.342 -        case 1:         *_p++ = _val;		\
  17.343 -		} while ( --_n );		\
  17.344 -	}					\
  17.345 -} while(0)
  17.346 -#endif
  17.347 -
  17.348 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
  17.349 -#if defined(__MACH__) && defined(__APPLE__)
  17.350 -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
  17.351 -#elif defined(__GNUC__) && defined(i386)
  17.352 -#define SDL_memcpy(dst, src, len)					  \
  17.353 -do {									  \
  17.354 -	int u0, u1, u2;						  	  \
  17.355 -	__asm__ __volatile__ (						  \
  17.356 -		"cld\n\t"						  \
  17.357 -		"rep ; movsl\n\t"					  \
  17.358 -		"testb $2,%b4\n\t"					  \
  17.359 -		"je 1f\n\t"						  \
  17.360 -		"movsw\n"						  \
  17.361 -		"1:\ttestb $1,%b4\n\t"					  \
  17.362 -		"je 2f\n\t"						  \
  17.363 -		"movsb\n"						  \
  17.364 -		"2:"							  \
  17.365 -		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
  17.366 -		: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
  17.367 -		: "memory" );						  \
  17.368 -} while(0)
  17.369 -#endif
  17.370 -#ifndef SDL_memcpy
  17.371 -#ifdef HAVE_MEMCPY
  17.372 -#define SDL_memcpy      memcpy
  17.373 -#elif defined(HAVE_BCOPY)
  17.374 -#define SDL_memcpy(d, s, n)	bcopy((s), (d), (n))
  17.375 -#else
  17.376 -extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
  17.377 -                                         size_t len);
  17.378 -#endif
  17.379 -#endif
  17.380 -
  17.381 -/* We can count on memcpy existing on Mac OS X and being well-tuned. */
  17.382 -#if defined(__MACH__) && defined(__APPLE__)
  17.383 -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
  17.384 -#elif defined(__GNUC__) && defined(i386)
  17.385 -#define SDL_memcpy4(dst, src, len)				\
  17.386 -do {								\
  17.387 -	int ecx, edi, esi;					\
  17.388 -	__asm__ __volatile__ (					\
  17.389 -		"cld\n\t"					\
  17.390 -		"rep ; movsl"					\
  17.391 -		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
  17.392 -		: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)	\
  17.393 -		: "memory" );					\
  17.394 -} while(0)
  17.395 -#endif
  17.396 -#ifndef SDL_memcpy4
  17.397 -#define SDL_memcpy4(dst, src, len)	SDL_memcpy(dst, src, (len) << 2)
  17.398 -#endif
  17.399 -
  17.400 -#if defined(__GNUC__) && defined(i386)
  17.401 -#define SDL_revcpy(dst, src, len)			\
  17.402 -do {							\
  17.403 -	int u0, u1, u2;					\
  17.404 -	char *dstp = SDL_static_cast(char *, dst);			\
  17.405 -	char *srcp = SDL_static_cast(char *, src);			\
  17.406 -	int n = (len);					\
  17.407 -	if ( n >= 4 ) {					\
  17.408 -	__asm__ __volatile__ (				\
  17.409 -		"std\n\t"				\
  17.410 -		"rep ; movsl\n\t"			\
  17.411 -		"cld\n\t"				\
  17.412 -		: "=&c" (u0), "=&D" (u1), "=&S" (u2)	\
  17.413 -		: "0" (n >> 2),				\
  17.414 -		  "1" (dstp+(n-4)), "2" (srcp+(n-4))	\
  17.415 -		: "memory" );				\
  17.416 -	}						\
  17.417 -	switch (n & 3) {				\
  17.418 -		case 3: dstp[2] = srcp[2];		\
  17.419 -		case 2: dstp[1] = srcp[1];		\
  17.420 -		case 1: dstp[0] = srcp[0];		\
  17.421 -			break;				\
  17.422 -		default:				\
  17.423 -			break;				\
  17.424 -	}						\
  17.425 -} while(0)
  17.426 -#endif
  17.427 -#ifndef SDL_revcpy
  17.428 -extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
  17.429 -                                         size_t len);
  17.430 -#endif
  17.431 -
  17.432 -#ifdef HAVE_MEMMOVE
  17.433 -#define SDL_memmove     memmove
  17.434 -#elif defined(HAVE_BCOPY)
  17.435 -#define SDL_memmove(d, s, n)	bcopy((s), (d), (n))
  17.436 -#else
  17.437 -#define SDL_memmove(dst, src, len)			\
  17.438 -do {							\
  17.439 -	if ( dst < src ) {				\
  17.440 -		SDL_memcpy(dst, src, len);		\
  17.441 -	} else {					\
  17.442 -		SDL_revcpy(dst, src, len);		\
  17.443 -	}						\
  17.444 -} while(0)
  17.445 -#endif
  17.446 -
  17.447 -#ifdef HAVE_MEMCMP
  17.448 -#define SDL_memcmp      memcmp
  17.449 -#else
  17.450 -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
  17.451 -                                       size_t len);
  17.452 -#endif
  17.453 -
  17.454 -#ifdef HAVE_STRLEN
  17.455 -#define SDL_strlen      strlen
  17.456 -#else
  17.457 -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
  17.458 -#endif
  17.459 -
  17.460 -#ifdef HAVE_WCSLEN
  17.461 -#define SDL_wcslen      wcslen
  17.462 -#else
  17.463 -#if !defined(wchar_t) && defined(__NINTENDODS__)
  17.464 -#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
  17.465 -#endif
  17.466 -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
  17.467 -#endif
  17.468 -
  17.469 -#ifdef HAVE_STRLCPY
  17.470 -#define SDL_strlcpy     strlcpy
  17.471 -#else
  17.472 -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
  17.473 -                                           size_t maxlen);
  17.474 -#endif
  17.475 -
  17.476 +/*
  17.477 +    SDL - Simple DirectMedia Layer
  17.478 +    Copyright (C) 1997-2010 Sam Lantinga
  17.479 +
  17.480 +    This library is free software; you can redistribute it and/or
  17.481 +    modify it under the terms of the GNU Lesser General Public
  17.482 +    License as published by the Free Software Foundation; either
  17.483 +    version 2.1 of the License, or (at your option) any later version.
  17.484 +
  17.485 +    This library is distributed in the hope that it will be useful,
  17.486 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.487 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.488 +    Lesser General Public License for more details.
  17.489 +
  17.490 +    You should have received a copy of the GNU Lesser General Public
  17.491 +    License along with this library; if not, write to the Free Software
  17.492 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17.493 +
  17.494 +    Sam Lantinga
  17.495 +    slouken@libsdl.org
  17.496 +*/
  17.497 +
  17.498 +/**
  17.499 + *  \file SDL_stdinc.h
  17.500 + *  
  17.501 + *  This is a general header that includes C language support.
  17.502 + */
  17.503 +
  17.504 +#ifndef _SDL_stdinc_h
  17.505 +#define _SDL_stdinc_h
  17.506 +
  17.507 +#include "SDL_config.h"
  17.508 +
  17.509 +
  17.510 +#ifdef HAVE_SYS_TYPES_H
  17.511 +#include <sys/types.h>
  17.512 +#endif
  17.513 +#ifdef HAVE_STDIO_H
  17.514 +#include <stdio.h>
  17.515 +#endif
  17.516 +#if defined(STDC_HEADERS)
  17.517 +# include <stdlib.h>
  17.518 +# include <stddef.h>
  17.519 +# include <stdarg.h>
  17.520 +#else
  17.521 +# if defined(HAVE_STDLIB_H)
  17.522 +#  include <stdlib.h>
  17.523 +# elif defined(HAVE_MALLOC_H)
  17.524 +#  include <malloc.h>
  17.525 +# endif
  17.526 +# if defined(HAVE_STDDEF_H)
  17.527 +#  include <stddef.h>
  17.528 +# endif
  17.529 +# if defined(HAVE_STDARG_H)
  17.530 +#  include <stdarg.h>
  17.531 +# endif
  17.532 +#endif
  17.533 +#ifdef HAVE_STRING_H
  17.534 +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
  17.535 +#  include <memory.h>
  17.536 +# endif
  17.537 +# include <string.h>
  17.538 +#endif
  17.539 +#ifdef HAVE_STRINGS_H
  17.540 +# include <strings.h>
  17.541 +#endif
  17.542 +#if defined(HAVE_INTTYPES_H)
  17.543 +# include <inttypes.h>
  17.544 +#elif defined(HAVE_STDINT_H)
  17.545 +# include <stdint.h>
  17.546 +#endif
  17.547 +#ifdef HAVE_CTYPE_H
  17.548 +# include <ctype.h>
  17.549 +#endif
  17.550 +#ifdef HAVE_MATH_H
  17.551 +# include <math.h>
  17.552 +#endif
  17.553 +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
  17.554 +# include <iconv.h>
  17.555 +#endif
  17.556 +
  17.557 +/**
  17.558 + *  The number of elements in an array.
  17.559 + */
  17.560 +#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
  17.561 +#define SDL_TABLESIZE(table)	SDL_arraysize(table)
  17.562 +
  17.563 +/**
  17.564 + *  \name Cast operators
  17.565 + *  
  17.566 + *  Use proper C++ casts when compiled as C++ to be compatible with the option
  17.567 + *  -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
  17.568 + */
  17.569 +/*@{*/
  17.570 +#ifdef __cplusplus
  17.571 +#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
  17.572 +#define SDL_static_cast(type, expression) static_cast<type>(expression)
  17.573 +#else
  17.574 +#define SDL_reinterpret_cast(type, expression) ((type)(expression))
  17.575 +#define SDL_static_cast(type, expression) ((type)(expression))
  17.576 +#endif
  17.577 +/*@}*//*Cast operators*/
  17.578 +
  17.579 +/* Define a four character code as a Uint32 */
  17.580 +#define SDL_FOURCC(A, B, C, D) \
  17.581 +    ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
  17.582 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
  17.583 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
  17.584 +     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
  17.585 +
  17.586 +/**
  17.587 + *  \name Basic data types
  17.588 + */
  17.589 +/*@{*/
  17.590 +
  17.591 +typedef enum
  17.592 +{
  17.593 +    SDL_FALSE = 0,
  17.594 +    SDL_TRUE = 1
  17.595 +} SDL_bool;
  17.596 +
  17.597 +/**
  17.598 + * \brief A signed 8-bit integer type.
  17.599 + */
  17.600 +typedef int8_t Sint8;
  17.601 +/**
  17.602 + * \brief An unsigned 8-bit integer type.
  17.603 + */
  17.604 +typedef uint8_t Uint8;
  17.605 +/**
  17.606 + * \brief A signed 16-bit integer type.
  17.607 + */
  17.608 +typedef int16_t Sint16;
  17.609 +/**
  17.610 + * \brief An unsigned 16-bit integer type.
  17.611 + */
  17.612 +typedef uint16_t Uint16;
  17.613 +/**
  17.614 + * \brief A signed 32-bit integer type.
  17.615 + */
  17.616 +typedef int32_t Sint32;
  17.617 +/**
  17.618 + * \brief An unsigned 32-bit integer type.
  17.619 + */
  17.620 +typedef uint32_t Uint32;
  17.621 +
  17.622 +#ifdef SDL_HAS_64BIT_TYPE
  17.623 +/**
  17.624 + * \brief A signed 64-bit integer type.
  17.625 + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32!
  17.626 + */
  17.627 +typedef int64_t Sint64;
  17.628 +/**
  17.629 + * \brief An unsigned 64-bit integer type.
  17.630 + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32!
  17.631 + */
  17.632 +typedef uint64_t Uint64;
  17.633 +#else
  17.634 +/* This is really just a hack to prevent the compiler from complaining */
  17.635 +typedef Sint32 Sint64;
  17.636 +typedef Uint32 Uint64;
  17.637 +#endif
  17.638 +
  17.639 +/*@}*//*Basic data types*/
  17.640 +
  17.641 +
  17.642 +#define SDL_COMPILE_TIME_ASSERT(name, x)               \
  17.643 +       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
  17.644 +/** \cond */
  17.645 +#ifndef DOXYGEN_SHOULD_IGNORE_THIS
  17.646 +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
  17.647 +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
  17.648 +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
  17.649 +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
  17.650 +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
  17.651 +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
  17.652 +#ifndef __NINTENDODS__          /* TODO: figure out why the following happens:
  17.653 +                                   include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
  17.654 +                                   include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
  17.655 +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
  17.656 +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
  17.657 +#endif
  17.658 +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  17.659 +/** \endcond */
  17.660 +
  17.661 +/* Check to make sure enums are the size of ints, for structure packing.
  17.662 +   For both Watcom C/C++ and Borland C/C++ the compiler option that makes
  17.663 +   enums having the size of an int must be enabled.
  17.664 +   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
  17.665 +*/
  17.666 +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */
  17.667 +#ifdef __MWERKS__
  17.668 +#pragma enumsalwaysint on
  17.669 +#endif
  17.670 +
  17.671 +/** \cond */
  17.672 +#ifndef DOXYGEN_SHOULD_IGNORE_THIS
  17.673 +#ifndef __NINTENDODS__          /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
  17.674 +typedef enum
  17.675 +{
  17.676 +    DUMMY_ENUM_VALUE
  17.677 +} SDL_DUMMY_ENUM;
  17.678 +
  17.679 +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
  17.680 +#endif
  17.681 +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  17.682 +/** \endcond */
  17.683 +
  17.684 +#include "begin_code.h"
  17.685 +/* Set up for C function definitions, even when using C++ */
  17.686 +#ifdef __cplusplus
  17.687 +/* *INDENT-OFF* */
  17.688 +extern "C" {
  17.689 +/* *INDENT-ON* */
  17.690 +#endif
  17.691 +
  17.692 +#ifdef HAVE_MALLOC
  17.693 +#define SDL_malloc	malloc
  17.694 +#else
  17.695 +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
  17.696 +#endif
  17.697 +
  17.698 +#ifdef HAVE_CALLOC
  17.699 +#define SDL_calloc	calloc
  17.700 +#else
  17.701 +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
  17.702 +#endif
  17.703 +
  17.704 +#ifdef HAVE_REALLOC
  17.705 +#define SDL_realloc	realloc
  17.706 +#else
  17.707 +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
  17.708 +#endif
  17.709 +
  17.710 +#ifdef HAVE_FREE
  17.711 +#define SDL_free	free
  17.712 +#else
  17.713 +extern DECLSPEC void SDLCALL SDL_free(void *mem);
  17.714 +#endif
  17.715 +
  17.716 +#if defined(HAVE_ALLOCA) && !defined(alloca)
  17.717 +# if defined(HAVE_ALLOCA_H)
  17.718 +#  include <alloca.h>
  17.719 +# elif defined(__GNUC__)
  17.720 +#  define alloca __builtin_alloca
  17.721 +# elif defined(_MSC_VER)
  17.722 +#  include <malloc.h>
  17.723 +#  define alloca _alloca
  17.724 +# elif defined(__WATCOMC__)
  17.725 +#  include <malloc.h>
  17.726 +# elif defined(__BORLANDC__)
  17.727 +#  include <malloc.h>
  17.728 +# elif defined(__DMC__)
  17.729 +#  include <stdlib.h>
  17.730 +# elif defined(__AIX__)
  17.731 +#pragma alloca
  17.732 +# elif defined(__MRC__)
  17.733 +void *alloca(unsigned);
  17.734 +# else
  17.735 +char *alloca();
  17.736 +# endif
  17.737 +#endif
  17.738 +#ifdef HAVE_ALLOCA
  17.739 +#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*(count))
  17.740 +#define SDL_stack_free(data)
  17.741 +#else
  17.742 +#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*(count))
  17.743 +#define SDL_stack_free(data)            SDL_free(data)
  17.744 +#endif
  17.745 +
  17.746 +#ifdef HAVE_GETENV
  17.747 +#define SDL_getenv	getenv
  17.748 +#else
  17.749 +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
  17.750 +#endif
  17.751 +
  17.752 +/* SDL_putenv() has moved to SDL_compat. */
  17.753 +#ifdef HAVE_SETENV
  17.754 +#define SDL_setenv	setenv
  17.755 +#else
  17.756 +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value,
  17.757 +                                       int overwrite);
  17.758 +#endif
  17.759 +
  17.760 +#ifdef HAVE_QSORT
  17.761 +#define SDL_qsort	qsort
  17.762 +#else
  17.763 +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
  17.764 +                                       int (*compare) (const void *,
  17.765 +                                                       const void *));
  17.766 +#endif
  17.767 +
  17.768 +#ifdef HAVE_ABS
  17.769 +#define SDL_abs		abs
  17.770 +#else
  17.771 +#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
  17.772 +#endif
  17.773 +
  17.774 +#define SDL_min(x, y)	(((x) < (y)) ? (x) : (y))
  17.775 +#define SDL_max(x, y)	(((x) > (y)) ? (x) : (y))
  17.776 +
  17.777 +#ifdef HAVE_CTYPE_H
  17.778 +#define SDL_isdigit(X)  isdigit(X)
  17.779 +#define SDL_isspace(X)  isspace(X)
  17.780 +#define SDL_toupper(X)  toupper(X)
  17.781 +#define SDL_tolower(X)  tolower(X)
  17.782 +#else
  17.783 +#define SDL_isdigit(X)  (((X) >= '0') && ((X) <= '9'))
  17.784 +#define SDL_isspace(X)  (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
  17.785 +#define SDL_toupper(X)  (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
  17.786 +#define SDL_tolower(X)  (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
  17.787 +#endif
  17.788 +
  17.789 +#ifdef HAVE_MEMSET
  17.790 +#define SDL_memset      memset
  17.791 +#else
  17.792 +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
  17.793 +#endif
  17.794 +#define SDL_zero(x)	SDL_memset(&(x), 0, sizeof((x)))
  17.795 +#define SDL_zerop(x)	SDL_memset((x), 0, sizeof(*(x)))
  17.796 +
  17.797 +#if defined(__GNUC__) && defined(i386)
  17.798 +#define SDL_memset4(dst, val, len)				\
  17.799 +do {								\
  17.800 +	int u0, u1, u2;						\
  17.801 +	__asm__ __volatile__ (					\
  17.802 +		"cld\n\t"					\
  17.803 +		"rep ; stosl\n\t"				\
  17.804 +		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
  17.805 +		: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))	\
  17.806 +		: "memory" );					\
  17.807 +} while(0)
  17.808 +#endif
  17.809 +#ifndef SDL_memset4
  17.810 +#define SDL_memset4(dst, val, len)		\
  17.811 +do {						\
  17.812 +	unsigned _count = (len);		\
  17.813 +	unsigned _n = (_count + 3) / 4;		\
  17.814 +	Uint32 *_p = SDL_static_cast(Uint32 *, dst);		\
  17.815 +	Uint32 _val = (val);			\
  17.816 +	if (len == 0) break;			\
  17.817 +        switch (_count % 4) {			\
  17.818 +        case 0: do {    *_p++ = _val;		\
  17.819 +        case 3:         *_p++ = _val;		\
  17.820 +        case 2:         *_p++ = _val;		\
  17.821 +        case 1:         *_p++ = _val;		\
  17.822 +		} while ( --_n );		\
  17.823 +	}					\
  17.824 +} while(0)
  17.825 +#endif
  17.826 +
  17.827 +/* We can count on memcpy existing on Mac OS X and being well-tuned. */
  17.828 +#if defined(__MACH__) && defined(__APPLE__)
  17.829 +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len)
  17.830 +#elif defined(__GNUC__) && defined(i386)
  17.831 +#define SDL_memcpy(dst, src, len)					  \
  17.832 +do {									  \
  17.833 +	int u0, u1, u2;						  	  \
  17.834 +	__asm__ __volatile__ (						  \
  17.835 +		"cld\n\t"						  \
  17.836 +		"rep ; movsl\n\t"					  \
  17.837 +		"testb $2,%b4\n\t"					  \
  17.838 +		"je 1f\n\t"						  \
  17.839 +		"movsw\n"						  \
  17.840 +		"1:\ttestb $1,%b4\n\t"					  \
  17.841 +		"je 2f\n\t"						  \
  17.842 +		"movsb\n"						  \
  17.843 +		"2:"							  \
  17.844 +		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
  17.845 +		: "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \
  17.846 +		: "memory" );						  \
  17.847 +} while(0)
  17.848 +#endif
  17.849 +#ifndef SDL_memcpy
  17.850 +#ifdef HAVE_MEMCPY
  17.851 +#define SDL_memcpy      memcpy
  17.852 +#elif defined(HAVE_BCOPY)
  17.853 +#define SDL_memcpy(d, s, n)	bcopy((s), (d), (n))
  17.854 +#else
  17.855 +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src,
  17.856 +                                         size_t len);
  17.857 +#endif
  17.858 +#endif
  17.859 +
  17.860 +/* We can count on memcpy existing on Mac OS X and being well-tuned. */
  17.861 +#if defined(__MACH__) && defined(__APPLE__)
  17.862 +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
  17.863 +#elif defined(__GNUC__) && defined(i386)
  17.864 +#define SDL_memcpy4(dst, src, len)				\
  17.865 +do {								\
  17.866 +	int ecx, edi, esi;					\
  17.867 +	__asm__ __volatile__ (					\
  17.868 +		"cld\n\t"					\
  17.869 +		"rep ; movsl"					\
  17.870 +		: "=&c" (ecx), "=&D" (edi), "=&S" (esi)		\
  17.871 +		: "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src)	\
  17.872 +		: "memory" );					\
  17.873 +} while(0)
  17.874 +#endif
  17.875 +#ifndef SDL_memcpy4
  17.876 +#define SDL_memcpy4(dst, src, len)	SDL_memcpy(dst, src, (len) << 2)
  17.877 +#endif
  17.878 +
  17.879 +#if defined(__GNUC__) && defined(i386)
  17.880 +#define SDL_revcpy(dst, src, len)			\
  17.881 +do {							\
  17.882 +	int u0, u1, u2;					\
  17.883 +	char *dstp = SDL_static_cast(char *, dst);			\
  17.884 +	char *srcp = SDL_static_cast(char *, src);			\
  17.885 +	int n = (len);					\
  17.886 +	if ( n >= 4 ) {					\
  17.887 +	__asm__ __volatile__ (				\
  17.888 +		"std\n\t"				\
  17.889 +		"rep ; movsl\n\t"			\
  17.890 +		"cld\n\t"				\
  17.891 +		: "=&c" (u0), "=&D" (u1), "=&S" (u2)	\
  17.892 +		: "0" (n >> 2),				\
  17.893 +		  "1" (dstp+(n-4)), "2" (srcp+(n-4))	\
  17.894 +		: "memory" );				\
  17.895 +	}						\
  17.896 +	switch (n & 3) {				\
  17.897 +		case 3: dstp[2] = srcp[2];		\
  17.898 +		case 2: dstp[1] = srcp[1];		\
  17.899 +		case 1: dstp[0] = srcp[0];		\
  17.900 +			break;				\
  17.901 +		default:				\
  17.902 +			break;				\
  17.903 +	}						\
  17.904 +} while(0)
  17.905 +#endif
  17.906 +#ifndef SDL_revcpy
  17.907 +extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src,
  17.908 +                                         size_t len);
  17.909 +#endif
  17.910 +
  17.911 +#ifdef HAVE_MEMMOVE
  17.912 +#define SDL_memmove     memmove
  17.913 +#elif defined(HAVE_BCOPY)
  17.914 +#define SDL_memmove(d, s, n)	bcopy((s), (d), (n))
  17.915 +#else
  17.916 +#define SDL_memmove(dst, src, len)			\
  17.917 +do {							\
  17.918 +	if ( dst < src ) {				\
  17.919 +		SDL_memcpy(dst, src, len);		\
  17.920 +	} else {					\
  17.921 +		SDL_revcpy(dst, src, len);		\
  17.922 +	}						\
  17.923 +} while(0)
  17.924 +#endif
  17.925 +
  17.926 +#ifdef HAVE_MEMCMP
  17.927 +#define SDL_memcmp      memcmp
  17.928 +#else
  17.929 +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2,
  17.930 +                                       size_t len);
  17.931 +#endif
  17.932 +
  17.933 +#ifdef HAVE_STRLEN
  17.934 +#define SDL_strlen      strlen
  17.935 +#else
  17.936 +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
  17.937 +#endif
  17.938 +
  17.939 +#ifdef HAVE_WCSLEN
  17.940 +#define SDL_wcslen      wcslen
  17.941 +#else
  17.942 +#if !defined(wchar_t) && defined(__NINTENDODS__)
  17.943 +#define wchar_t short           /* TODO: figure out why libnds doesn't have this */
  17.944 +#endif
  17.945 +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
  17.946 +#endif
  17.947 +
  17.948 +#ifdef HAVE_STRLCPY
  17.949 +#define SDL_strlcpy     strlcpy
  17.950 +#else
  17.951 +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src,
  17.952 +                                           size_t maxlen);
  17.953 +#endif
  17.954 +
  17.955  extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src,
  17.956                                              size_t dst_bytes);
  17.957 -
  17.958 -#ifdef HAVE_STRLCAT
  17.959 -#define SDL_strlcat    strlcat
  17.960 -#else
  17.961 -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
  17.962 -                                           size_t maxlen);
  17.963 -#endif
  17.964 -
  17.965 -#ifdef HAVE_STRDUP
  17.966 -#define SDL_strdup     strdup
  17.967 -#else
  17.968 -extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
  17.969 -#endif
  17.970 -
  17.971 -#ifdef HAVE__STRREV
  17.972 -#define SDL_strrev      _strrev
  17.973 -#else
  17.974 -extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
  17.975 -#endif
  17.976 -
  17.977 -#ifdef HAVE__STRUPR
  17.978 -#define SDL_strupr      _strupr
  17.979 -#else
  17.980 -extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
  17.981 -#endif
  17.982 -
  17.983 -#ifdef HAVE__STRLWR
  17.984 -#define SDL_strlwr      _strlwr
  17.985 -#else
  17.986 -extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
  17.987 -#endif
  17.988 -
  17.989 -#ifdef HAVE_STRCHR
  17.990 -#define SDL_strchr      strchr
  17.991 -#elif defined(HAVE_INDEX)
  17.992 -#define SDL_strchr      index
  17.993 -#else
  17.994 -extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
  17.995 -#endif
  17.996 -
  17.997 -#ifdef HAVE_STRRCHR
  17.998 -#define SDL_strrchr     strrchr
  17.999 -#elif defined(HAVE_RINDEX)
 17.1000 -#define SDL_strrchr     rindex
 17.1001 -#else
 17.1002 -extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
 17.1003 -#endif
 17.1004 -
 17.1005 -#ifdef HAVE_STRSTR
 17.1006 -#define SDL_strstr      strstr
 17.1007 -#else
 17.1008 -extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
 17.1009 -                                         const char *needle);
 17.1010 -#endif
 17.1011 -
 17.1012 -#ifdef HAVE_ITOA
 17.1013 -#define SDL_itoa        itoa
 17.1014 -#else
 17.1015 -#define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
 17.1016 -#endif
 17.1017 -
 17.1018 -#ifdef HAVE__LTOA
 17.1019 -#define SDL_ltoa        _ltoa
 17.1020 -#else
 17.1021 -extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
 17.1022 -#endif
 17.1023 -
 17.1024 -#ifdef HAVE__UITOA
 17.1025 -#define SDL_uitoa       _uitoa
 17.1026 -#else
 17.1027 -#define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
 17.1028 -#endif
 17.1029 -
 17.1030 -#ifdef HAVE__ULTOA
 17.1031 -#define SDL_ultoa       _ultoa
 17.1032 -#else
 17.1033 -extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
 17.1034 -                                        int radix);
 17.1035 -#endif
 17.1036 -
 17.1037 -#ifdef HAVE_STRTOL
 17.1038 -#define SDL_strtol      strtol
 17.1039 -#else
 17.1040 -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
 17.1041 -                                        int base);
 17.1042 -#endif
 17.1043 -
 17.1044 -#ifdef HAVE_STRTOUL
 17.1045 -#define SDL_strtoul      strtoul
 17.1046 -#else
 17.1047 -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
 17.1048 -                                                  char **endp, int base);
 17.1049 -#endif
 17.1050 -
 17.1051 -#ifdef SDL_HAS_64BIT_TYPE
 17.1052 -
 17.1053 -#ifdef HAVE__I64TOA
 17.1054 -#define SDL_lltoa       _i64toa
 17.1055 -#else
 17.1056 -extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
 17.1057 -                                        int radix);
 17.1058 -#endif
 17.1059 -
 17.1060 -#ifdef HAVE__UI64TOA
 17.1061 -#define SDL_ulltoa      _ui64toa
 17.1062 -#else
 17.1063 -extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
 17.1064 -                                         int radix);
 17.1065 -#endif
 17.1066 -
 17.1067 -#ifdef HAVE_STRTOLL
 17.1068 -#define SDL_strtoll     strtoll
 17.1069 -#else
 17.1070 -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
 17.1071 -                                           int base);
 17.1072 -#endif
 17.1073 -
 17.1074 -#ifdef HAVE_STRTOULL
 17.1075 -#define SDL_strtoull     strtoull
 17.1076 -#else
 17.1077 -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
 17.1078 -                                            int base);
 17.1079 -#endif
 17.1080 -
 17.1081 -#endif /* SDL_HAS_64BIT_TYPE */
 17.1082 -
 17.1083 -#ifdef HAVE_STRTOD
 17.1084 -#define SDL_strtod      strtod
 17.1085 -#else
 17.1086 -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
 17.1087 -#endif
 17.1088 -
 17.1089 -#ifdef HAVE_ATOI
 17.1090 -#define SDL_atoi        atoi
 17.1091 -#else
 17.1092 -#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
 17.1093 -#endif
 17.1094 -
 17.1095 -#ifdef HAVE_ATOF
 17.1096 -#define SDL_atof        atof
 17.1097 -#else
 17.1098 -#define SDL_atof(X)     SDL_strtod(X, NULL)
 17.1099 -#endif
 17.1100 -
 17.1101 -#ifdef HAVE_STRCMP
 17.1102 -#define SDL_strcmp      strcmp
 17.1103 -#else
 17.1104 -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
 17.1105 -#endif
 17.1106 -
 17.1107 -#ifdef HAVE_STRNCMP
 17.1108 -#define SDL_strncmp     strncmp
 17.1109 -#else
 17.1110 -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
 17.1111 -                                        size_t maxlen);
 17.1112 -#endif
 17.1113 -
 17.1114 -#ifdef HAVE_STRCASECMP
 17.1115 -#define SDL_strcasecmp  strcasecmp
 17.1116 -#elif defined(HAVE__STRICMP)
 17.1117 -#define SDL_strcasecmp  _stricmp
 17.1118 -#else
 17.1119 -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
 17.1120 -                                           const char *str2);
 17.1121 -#endif
 17.1122 -
 17.1123 -#ifdef HAVE_STRNCASECMP
 17.1124 -#define SDL_strncasecmp strncasecmp
 17.1125 -#elif defined(HAVE__STRNICMP)
 17.1126 -#define SDL_strncasecmp _strnicmp
 17.1127 -#else
 17.1128 -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
 17.1129 -                                            const char *str2, size_t maxlen);
 17.1130 -#endif
 17.1131 -
 17.1132 -#ifdef HAVE_SSCANF
 17.1133 -#define SDL_sscanf      sscanf
 17.1134 -#else
 17.1135 -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
 17.1136 -                                       ...);
 17.1137 -#endif
 17.1138 -
 17.1139 -#ifdef HAVE_SNPRINTF
 17.1140 -#define SDL_snprintf    snprintf
 17.1141 -#else
 17.1142 -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
 17.1143 -                                         const char *fmt, ...);
 17.1144 -#endif
 17.1145 -
 17.1146 -#ifdef HAVE_VSNPRINTF
 17.1147 -#define SDL_vsnprintf   vsnprintf
 17.1148 -#else
 17.1149 -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
 17.1150 -                                          const char *fmt, va_list ap);
 17.1151 -#endif
 17.1152 -
 17.1153 -#ifndef HAVE_M_PI
 17.1154 -#define M_PI    3.14159265358979323846264338327950288   /* pi */
 17.1155 -#endif
 17.1156 -
 17.1157 -#ifdef HAVE_CEIL
 17.1158 -#define SDL_ceil        ceil
 17.1159 -#else
 17.1160 -#define SDL_ceil(x)     ((double)(int)((x)+0.5))
 17.1161 -#endif
 17.1162 -
 17.1163 -#ifdef HAVE_COPYSIGN
 17.1164 -#define SDL_copysign    copysign
 17.1165 -#else
 17.1166 -extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
 17.1167 -#endif
 17.1168 -
 17.1169 -#ifdef HAVE_COS
 17.1170 -#define SDL_cos         cos
 17.1171 -#else
 17.1172 -extern DECLSPEC double SDLCALL SDL_cos(double x);
 17.1173 -#endif
 17.1174 -
 17.1175 -#ifdef HAVE_COSF
 17.1176 -#define SDL_cosf        cosf
 17.1177 -#else
 17.1178 -#define SDL_cosf(x) (float)SDL_cos((double)x)
 17.1179 -#endif
 17.1180 -
 17.1181 -#ifdef HAVE_FABS
 17.1182 -#define SDL_fabs        fabs
 17.1183 -#else
 17.1184 -extern DECLSPEC double SDLCALL SDL_fabs(double x);
 17.1185 -#endif
 17.1186 -
 17.1187 -#ifdef HAVE_FLOOR
 17.1188 -#define SDL_floor       floor
 17.1189 -#else
 17.1190 -extern DECLSPEC double SDLCALL SDL_floor(double x);
 17.1191 -#endif
 17.1192 -
 17.1193 -#ifdef HAVE_LOG
 17.1194 -#define SDL_log         log
 17.1195 -#else
 17.1196 -extern DECLSPEC double SDLCALL SDL_log(double x);
 17.1197 -#endif
 17.1198 -
 17.1199 -#ifdef HAVE_POW
 17.1200 -#define SDL_pow         pow
 17.1201 -#else
 17.1202 -extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
 17.1203 -#endif
 17.1204 -
 17.1205 -#ifdef HAVE_SCALBN
 17.1206 -#define SDL_scalbn      scalbn
 17.1207 -#else
 17.1208 -extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
 17.1209 -#endif
 17.1210 -
 17.1211 -#ifdef HAVE_SIN
 17.1212 -#define SDL_sin         sin
 17.1213 -#else
 17.1214 -extern DECLSPEC double SDLCALL SDL_sin(double x);
 17.1215 -#endif
 17.1216 -
 17.1217 -#ifdef HAVE_SINF
 17.1218 -#define SDL_sinf        sinf
 17.1219 -#else
 17.1220 -#define SDL_sinf(x) (float)SDL_sin((double)x)
 17.1221 -#endif
 17.1222 -
 17.1223 -#ifdef HAVE_SQRT
 17.1224 -#define SDL_sqrt        sqrt
 17.1225 -#else
 17.1226 -extern DECLSPEC double SDLCALL SDL_sqrt(double x);
 17.1227 -#endif
 17.1228 -
 17.1229 -/* The SDL implementation of iconv() returns these error codes */
 17.1230 -#define SDL_ICONV_ERROR		(size_t)-1
 17.1231 -#define SDL_ICONV_E2BIG		(size_t)-2
 17.1232 -#define SDL_ICONV_EILSEQ	(size_t)-3
 17.1233 -#define SDL_ICONV_EINVAL	(size_t)-4
 17.1234 -
 17.1235 -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
 17.1236 -#define SDL_iconv_t     iconv_t
 17.1237 -#define SDL_iconv_open  iconv_open
 17.1238 -#define SDL_iconv_close iconv_close
 17.1239 -#else
 17.1240 -typedef struct _SDL_iconv_t *SDL_iconv_t;
 17.1241 -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
 17.1242 -                                                   const char *fromcode);
 17.1243 -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
 17.1244 -#endif
 17.1245 -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
 17.1246 -                                         size_t * inbytesleft, char **outbuf,
 17.1247 -                                         size_t * outbytesleft);
 17.1248 -/**
 17.1249 - *  This function converts a string between encodings in one pass, returning a
 17.1250 - *  string that must be freed with SDL_free() or NULL on error.
 17.1251 - */
 17.1252 -extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
 17.1253 -                                               const char *fromcode,
 17.1254 -                                               const char *inbuf,
 17.1255 -                                               size_t inbytesleft);
 17.1256 -#define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
 17.1257 -#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
 17.1258 -#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
 17.1259 -
 17.1260 -/* Ends C function definitions when using C++ */
 17.1261 -#ifdef __cplusplus
 17.1262 -/* *INDENT-OFF* */
 17.1263 -}
 17.1264 -/* *INDENT-ON* */
 17.1265 -#endif
 17.1266 -#include "close_code.h"
 17.1267 -
 17.1268 -#endif /* _SDL_stdinc_h */
 17.1269 -
 17.1270 -/* vi: set ts=4 sw=4 expandtab: */
 17.1271 +
 17.1272 +#ifdef HAVE_STRLCAT
 17.1273 +#define SDL_strlcat    strlcat
 17.1274 +#else
 17.1275 +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src,
 17.1276 +                                           size_t maxlen);
 17.1277 +#endif
 17.1278 +
 17.1279 +#ifdef HAVE_STRDUP
 17.1280 +#define SDL_strdup     strdup
 17.1281 +#else
 17.1282 +extern DECLSPEC char *SDLCALL SDL_strdup(const char *string);
 17.1283 +#endif
 17.1284 +
 17.1285 +#ifdef HAVE__STRREV
 17.1286 +#define SDL_strrev      _strrev
 17.1287 +#else
 17.1288 +extern DECLSPEC char *SDLCALL SDL_strrev(char *string);
 17.1289 +#endif
 17.1290 +
 17.1291 +#ifdef HAVE__STRUPR
 17.1292 +#define SDL_strupr      _strupr
 17.1293 +#else
 17.1294 +extern DECLSPEC char *SDLCALL SDL_strupr(char *string);
 17.1295 +#endif
 17.1296 +
 17.1297 +#ifdef HAVE__STRLWR
 17.1298 +#define SDL_strlwr      _strlwr
 17.1299 +#else
 17.1300 +extern DECLSPEC char *SDLCALL SDL_strlwr(char *string);
 17.1301 +#endif
 17.1302 +
 17.1303 +#ifdef HAVE_STRCHR
 17.1304 +#define SDL_strchr      strchr
 17.1305 +#elif defined(HAVE_INDEX)
 17.1306 +#define SDL_strchr      index
 17.1307 +#else
 17.1308 +extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c);
 17.1309 +#endif
 17.1310 +
 17.1311 +#ifdef HAVE_STRRCHR
 17.1312 +#define SDL_strrchr     strrchr
 17.1313 +#elif defined(HAVE_RINDEX)
 17.1314 +#define SDL_strrchr     rindex
 17.1315 +#else
 17.1316 +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c);
 17.1317 +#endif
 17.1318 +
 17.1319 +#ifdef HAVE_STRSTR
 17.1320 +#define SDL_strstr      strstr
 17.1321 +#else
 17.1322 +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack,
 17.1323 +                                         const char *needle);
 17.1324 +#endif
 17.1325 +
 17.1326 +#ifdef HAVE_ITOA
 17.1327 +#define SDL_itoa        itoa
 17.1328 +#else
 17.1329 +#define SDL_itoa(value, string, radix)	SDL_ltoa((long)value, string, radix)
 17.1330 +#endif
 17.1331 +
 17.1332 +#ifdef HAVE__LTOA
 17.1333 +#define SDL_ltoa        _ltoa
 17.1334 +#else
 17.1335 +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix);
 17.1336 +#endif
 17.1337 +
 17.1338 +#ifdef HAVE__UITOA
 17.1339 +#define SDL_uitoa       _uitoa
 17.1340 +#else
 17.1341 +#define SDL_uitoa(value, string, radix)	SDL_ultoa((long)value, string, radix)
 17.1342 +#endif
 17.1343 +
 17.1344 +#ifdef HAVE__ULTOA
 17.1345 +#define SDL_ultoa       _ultoa
 17.1346 +#else
 17.1347 +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string,
 17.1348 +                                        int radix);
 17.1349 +#endif
 17.1350 +
 17.1351 +#ifdef HAVE_STRTOL
 17.1352 +#define SDL_strtol      strtol
 17.1353 +#else
 17.1354 +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp,
 17.1355 +                                        int base);
 17.1356 +#endif
 17.1357 +
 17.1358 +#ifdef HAVE_STRTOUL
 17.1359 +#define SDL_strtoul      strtoul
 17.1360 +#else
 17.1361 +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string,
 17.1362 +                                                  char **endp, int base);
 17.1363 +#endif
 17.1364 +
 17.1365 +#ifdef SDL_HAS_64BIT_TYPE
 17.1366 +
 17.1367 +#ifdef HAVE__I64TOA
 17.1368 +#define SDL_lltoa       _i64toa
 17.1369 +#else
 17.1370 +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string,
 17.1371 +                                        int radix);
 17.1372 +#endif
 17.1373 +
 17.1374 +#ifdef HAVE__UI64TOA
 17.1375 +#define SDL_ulltoa      _ui64toa
 17.1376 +#else
 17.1377 +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string,
 17.1378 +                                         int radix);
 17.1379 +#endif
 17.1380 +
 17.1381 +#ifdef HAVE_STRTOLL
 17.1382 +#define SDL_strtoll     strtoll
 17.1383 +#else
 17.1384 +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp,
 17.1385 +                                           int base);
 17.1386 +#endif
 17.1387 +
 17.1388 +#ifdef HAVE_STRTOULL
 17.1389 +#define SDL_strtoull     strtoull
 17.1390 +#else
 17.1391 +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp,
 17.1392 +                                            int base);
 17.1393 +#endif
 17.1394 +
 17.1395 +#endif /* SDL_HAS_64BIT_TYPE */
 17.1396 +
 17.1397 +#ifdef HAVE_STRTOD
 17.1398 +#define SDL_strtod      strtod
 17.1399 +#else
 17.1400 +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
 17.1401 +#endif
 17.1402 +
 17.1403 +#ifdef HAVE_ATOI
 17.1404 +#define SDL_atoi        atoi
 17.1405 +#else
 17.1406 +#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
 17.1407 +#endif
 17.1408 +
 17.1409 +#ifdef HAVE_ATOF
 17.1410 +#define SDL_atof        atof
 17.1411 +#else
 17.1412 +#define SDL_atof(X)     SDL_strtod(X, NULL)
 17.1413 +#endif
 17.1414 +
 17.1415 +#ifdef HAVE_STRCMP
 17.1416 +#define SDL_strcmp      strcmp
 17.1417 +#else
 17.1418 +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
 17.1419 +#endif
 17.1420 +
 17.1421 +#ifdef HAVE_STRNCMP
 17.1422 +#define SDL_strncmp     strncmp
 17.1423 +#else
 17.1424 +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2,
 17.1425 +                                        size_t maxlen);
 17.1426 +#endif
 17.1427 +
 17.1428 +#ifdef HAVE_STRCASECMP
 17.1429 +#define SDL_strcasecmp  strcasecmp
 17.1430 +#elif defined(HAVE__STRICMP)
 17.1431 +#define SDL_strcasecmp  _stricmp
 17.1432 +#else
 17.1433 +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1,
 17.1434 +                                           const char *str2);
 17.1435 +#endif
 17.1436 +
 17.1437 +#ifdef HAVE_STRNCASECMP
 17.1438 +#define SDL_strncasecmp strncasecmp
 17.1439 +#elif defined(HAVE__STRNICMP)
 17.1440 +#define SDL_strncasecmp _strnicmp
 17.1441 +#else
 17.1442 +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1,
 17.1443 +                                            const char *str2, size_t maxlen);
 17.1444 +#endif
 17.1445 +
 17.1446 +#ifdef HAVE_SSCANF
 17.1447 +#define SDL_sscanf      sscanf
 17.1448 +#else
 17.1449 +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt,
 17.1450 +                                       ...);
 17.1451 +#endif
 17.1452 +
 17.1453 +#ifdef HAVE_SNPRINTF
 17.1454 +#define SDL_snprintf    snprintf
 17.1455 +#else
 17.1456 +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen,
 17.1457 +                                         const char *fmt, ...);
 17.1458 +#endif
 17.1459 +
 17.1460 +#ifdef HAVE_VSNPRINTF
 17.1461 +#define SDL_vsnprintf   vsnprintf
 17.1462 +#else
 17.1463 +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen,
 17.1464 +                                          const char *fmt, va_list ap);
 17.1465 +#endif
 17.1466 +
 17.1467 +#ifndef HAVE_M_PI
 17.1468 +#define M_PI    3.14159265358979323846264338327950288   /* pi */
 17.1469 +#endif
 17.1470 +
 17.1471 +#ifdef HAVE_CEIL
 17.1472 +#define SDL_ceil        ceil
 17.1473 +#else
 17.1474 +#define SDL_ceil(x)     ((double)(int)((x)+0.5))
 17.1475 +#endif
 17.1476 +
 17.1477 +#ifdef HAVE_COPYSIGN
 17.1478 +#define SDL_copysign    copysign
 17.1479 +#else
 17.1480 +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
 17.1481 +#endif
 17.1482 +
 17.1483 +#ifdef HAVE_COS
 17.1484 +#define SDL_cos         cos
 17.1485 +#else
 17.1486 +extern DECLSPEC double SDLCALL SDL_cos(double x);
 17.1487 +#endif
 17.1488 +
 17.1489 +#ifdef HAVE_COSF
 17.1490 +#define SDL_cosf        cosf
 17.1491 +#else
 17.1492 +#define SDL_cosf(x) (float)SDL_cos((double)x)
 17.1493 +#endif
 17.1494 +
 17.1495 +#ifdef HAVE_FABS
 17.1496 +#define SDL_fabs        fabs
 17.1497 +#else
 17.1498 +extern DECLSPEC double SDLCALL SDL_fabs(double x);
 17.1499 +#endif
 17.1500 +
 17.1501 +#ifdef HAVE_FLOOR
 17.1502 +#define SDL_floor       floor
 17.1503 +#else
 17.1504 +extern DECLSPEC double SDLCALL SDL_floor(double x);
 17.1505 +#endif
 17.1506 +
 17.1507 +#ifdef HAVE_LOG
 17.1508 +#define SDL_log         log
 17.1509 +#else
 17.1510 +extern DECLSPEC double SDLCALL SDL_log(double x);
 17.1511 +#endif
 17.1512 +
 17.1513 +#ifdef HAVE_POW
 17.1514 +#define SDL_pow         pow
 17.1515 +#else
 17.1516 +extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
 17.1517 +#endif
 17.1518 +
 17.1519 +#ifdef HAVE_SCALBN
 17.1520 +#define SDL_scalbn      scalbn
 17.1521 +#else
 17.1522 +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
 17.1523 +#endif
 17.1524 +
 17.1525 +#ifdef HAVE_SIN
 17.1526 +#define SDL_sin         sin
 17.1527 +#else
 17.1528 +extern DECLSPEC double SDLCALL SDL_sin(double x);
 17.1529 +#endif
 17.1530 +
 17.1531 +#ifdef HAVE_SINF
 17.1532 +#define SDL_sinf        sinf
 17.1533 +#else
 17.1534 +#define SDL_sinf(x) (float)SDL_sin((double)x)
 17.1535 +#endif
 17.1536 +
 17.1537 +#ifdef HAVE_SQRT
 17.1538 +#define SDL_sqrt        sqrt
 17.1539 +#else
 17.1540 +extern DECLSPEC double SDLCALL SDL_sqrt(double x);
 17.1541 +#endif
 17.1542 +
 17.1543 +/* The SDL implementation of iconv() returns these error codes */
 17.1544 +#define SDL_ICONV_ERROR		(size_t)-1
 17.1545 +#define SDL_ICONV_E2BIG		(size_t)-2
 17.1546 +#define SDL_ICONV_EILSEQ	(size_t)-3
 17.1547 +#define SDL_ICONV_EINVAL	(size_t)-4
 17.1548 +
 17.1549 +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
 17.1550 +#define SDL_iconv_t     iconv_t
 17.1551 +#define SDL_iconv_open  iconv_open
 17.1552 +#define SDL_iconv_close iconv_close
 17.1553 +#else
 17.1554 +typedef struct _SDL_iconv_t *SDL_iconv_t;
 17.1555 +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
 17.1556 +                                                   const char *fromcode);
 17.1557 +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
 17.1558 +#endif
 17.1559 +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
 17.1560 +                                         size_t * inbytesleft, char **outbuf,
 17.1561 +                                         size_t * outbytesleft);
 17.1562 +/**
 17.1563 + *  This function converts a string between encodings in one pass, returning a
 17.1564 + *  string that must be freed with SDL_free() or NULL on error.
 17.1565 + */
 17.1566 +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
 17.1567 +                                               const char *fromcode,
 17.1568 +                                               const char *inbuf,
 17.1569 +                                               size_t inbytesleft);
 17.1570 +#define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
 17.1571 +#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
 17.1572 +#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
 17.1573 +
 17.1574 +/* Ends C function definitions when using C++ */
 17.1575 +#ifdef __cplusplus
 17.1576 +/* *INDENT-OFF* */
 17.1577 +}
 17.1578 +/* *INDENT-ON* */
 17.1579 +#endif
 17.1580 +#include "close_code.h"
 17.1581 +
 17.1582 +#endif /* _SDL_stdinc_h */
 17.1583 +
 17.1584 +/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/include/SDL_syswm.h	Tue Jul 13 15:05:45 2010 -0400
    18.2 +++ b/include/SDL_syswm.h	Sun Jul 18 13:48:23 2010 -0400
    18.3 @@ -106,24 +106,6 @@
    18.4          {
    18.5              Display *display;   /**< The X11 display */
    18.6              Window window;      /**< The X11 display window */
    18.7 -            /**
    18.8 -             *  These locking functions should be called around
    18.9 -             *  any X11 functions using the display variable.
   18.10 -             *  They lock the event thread, so should not be
   18.11 -             *  called around event functions or from event filters.
   18.12 -             */
   18.13 -            /*@{*/
   18.14 -            void (*lock_func) (void);
   18.15 -            void (*unlock_func) (void);
   18.16 -            /*@}*/
   18.17 -
   18.18 -            /**
   18.19 -             *  Introduced in SDL 1.0.2.
   18.20 -             */
   18.21 -            /*@{*/
   18.22 -            Window fswindow;    /**< The X11 fullscreen window */
   18.23 -            Window wmwindow;    /**< The X11 managed input window */
   18.24 -            /*@}*/
   18.25          } x11;
   18.26      } info;
   18.27  };
   18.28 @@ -231,7 +213,7 @@
   18.29  /**
   18.30   *  \brief This function allows access to driver-dependent window information.
   18.31   *  
   18.32 - *  \param windowID The window about which information is being requested
   18.33 + *  \param window The window about which information is being requested
   18.34   *  \param info This structure must be initialized with the SDL version, and is 
   18.35   *              then filled in with information about the given window.
   18.36   *  
    19.1 --- a/src/audio/SDL_audio.c	Tue Jul 13 15:05:45 2010 -0400
    19.2 +++ b/src/audio/SDL_audio.c	Sun Jul 18 13:48:23 2010 -0400
    19.3 @@ -287,6 +287,7 @@
    19.4  }
    19.5  
    19.6  /* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */
    19.7 +#if 0
    19.8  static int
    19.9  SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
   19.10  {
   19.11 @@ -305,6 +306,7 @@
   19.12  
   19.13      return 0;
   19.14  }
   19.15 +#endif
   19.16  
   19.17  /* Deinitialize the stream simply by freeing the buffer */
   19.18  static void
    20.1 --- a/src/audio/SDL_audiodev.c	Tue Jul 13 15:05:45 2010 -0400
    20.2 +++ b/src/audio/SDL_audiodev.c	Sun Jul 18 13:48:23 2010 -0400
    20.3 @@ -28,6 +28,7 @@
    20.4  #include <fcntl.h>
    20.5  #include <sys/types.h>
    20.6  #include <sys/stat.h>
    20.7 +#include <unistd.h> /* For close() */
    20.8  
    20.9  #include "SDL_stdinc.h"
   20.10  #include "SDL_audiodev_c.h"
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/events/SDL_clipboardevents.c	Sun Jul 18 13:48:23 2010 -0400
    21.3 @@ -0,0 +1,47 @@
    21.4 +/*
    21.5 +    SDL - Simple DirectMedia Layer
    21.6 +    Copyright (C) 1997-2010 Sam Lantinga
    21.7 +
    21.8 +    This library is free software; you can redistribute it and/or
    21.9 +    modify it under the terms of the GNU Lesser General Public
   21.10 +    License as published by the Free Software Foundation; either
   21.11 +    version 2.1 of the License, or (at your option) any later version.
   21.12 +
   21.13 +    This library is distributed in the hope that it will be useful,
   21.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 +    Lesser General Public License for more details.
   21.17 +
   21.18 +    You should have received a copy of the GNU Lesser General Public
   21.19 +    License along with this library; if not, write to the Free Software
   21.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 +
   21.22 +    Sam Lantinga
   21.23 +    slouken@libsdl.org
   21.24 +*/
   21.25 +#include "SDL_config.h"
   21.26 +
   21.27 +/* Clipboard event handling code for SDL */
   21.28 +
   21.29 +#include "SDL_events.h"
   21.30 +#include "SDL_events_c.h"
   21.31 +#include "SDL_clipboardevents_c.h"
   21.32 +
   21.33 +
   21.34 +int
   21.35 +SDL_SendClipboardUpdate(void)
   21.36 +{
   21.37 +    int posted;
   21.38 +
   21.39 +    /* Post the event, if desired */
   21.40 +    posted = 0;
   21.41 +    if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
   21.42 +        SDL_Event event;
   21.43 +        event.type = SDL_CLIPBOARDUPDATE;
   21.44 +
   21.45 +        posted = (SDL_PushEvent(&event) > 0);
   21.46 +    }
   21.47 +    return (posted);
   21.48 +}
   21.49 +
   21.50 +/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/events/SDL_clipboardevents_c.h	Sun Jul 18 13:48:23 2010 -0400
    22.3 @@ -0,0 +1,31 @@
    22.4 +/*
    22.5 +    SDL - Simple DirectMedia Layer
    22.6 +    Copyright (C) 1997-2010 Sam Lantinga
    22.7 +
    22.8 +    This library is free software; you can redistribute it and/or
    22.9 +    modify it under the terms of the GNU Lesser General Public
   22.10 +    License as published by the Free Software Foundation; either
   22.11 +    version 2.1 of the License, or (at your option) any later version.
   22.12 +
   22.13 +    This library is distributed in the hope that it will be useful,
   22.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 +    Lesser General Public License for more details.
   22.17 +
   22.18 +    You should have received a copy of the GNU Lesser General Public
   22.19 +    License along with this library; if not, write to the Free Software
   22.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 +
   22.22 +    Sam Lantinga
   22.23 +    slouken@libsdl.org
   22.24 +*/
   22.25 +#include "SDL_config.h"
   22.26 +
   22.27 +#ifndef _SDL_clipboardevents_c_h
   22.28 +#define _SDL_clipboardevents_c_h
   22.29 +
   22.30 +extern int SDL_SendClipboardUpdate(void);
   22.31 +
   22.32 +#endif /* _SDL_clipboardevents_c_h */
   22.33 +
   22.34 +/* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/events/SDL_keyboard.c	Tue Jul 13 15:05:45 2010 -0400
    23.2 +++ b/src/events/SDL_keyboard.c	Sun Jul 18 13:48:23 2010 -0400
    23.3 @@ -551,6 +551,10 @@
    23.4  int
    23.5  SDL_KeyboardInit(void)
    23.6  {
    23.7 +    SDL_Keyboard *keyboard = &SDL_keyboard;
    23.8 +
    23.9 +    /* Set the default keymap */
   23.10 +    SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
   23.11      return (0);
   23.12  }
   23.13  
   23.14 @@ -760,6 +764,11 @@
   23.15      SDL_Keyboard *keyboard = &SDL_keyboard;
   23.16      int posted;
   23.17  
   23.18 +    /* Don't post text events for unprintable characters */
   23.19 +    if (*text < ' ') {
   23.20 +        return 0;
   23.21 +    }
   23.22 +
   23.23      /* Post the event, if desired */
   23.24      posted = 0;
   23.25      if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
    24.1 --- a/src/events/scancodes_xfree86.h	Tue Jul 13 15:05:45 2010 -0400
    24.2 +++ b/src/events/scancodes_xfree86.h	Sun Jul 18 13:48:23 2010 -0400
    24.3 @@ -262,24 +262,24 @@
    24.4      /*  81 */   SDL_SCANCODE_KP_3,
    24.5      /*  82 */   SDL_SCANCODE_KP_0,
    24.6      /*  83 */   SDL_SCANCODE_KP_PERIOD,
    24.7 -    /*  84 */   SDL_SCANCODE_SYSREQ,		/* ???? */
    24.8 -    /*  85 */   SDL_SCANCODE_MODE,			/* ???? */
    24.9 +    /*  84 */   SDL_SCANCODE_SYSREQ,    /* ???? */
   24.10 +    /*  85 */   SDL_SCANCODE_MODE,      /* ???? */
   24.11      /*  86 */   SDL_SCANCODE_NONUSBACKSLASH,
   24.12      /*  87 */   SDL_SCANCODE_F11,
   24.13      /*  88 */   SDL_SCANCODE_F12,
   24.14      /*  89 */   SDL_SCANCODE_UNKNOWN,
   24.15 -    /*  90 */   SDL_SCANCODE_UNKNOWN,
   24.16 -    /*  91 */   SDL_SCANCODE_UNKNOWN,
   24.17 -    /*  92 */   SDL_SCANCODE_UNKNOWN,
   24.18 -    /*  93 */   SDL_SCANCODE_UNKNOWN,
   24.19 -    /*  94 */   SDL_SCANCODE_UNKNOWN,
   24.20 +    /*  90 */   SDL_SCANCODE_UNKNOWN,   /* Katakana */
   24.21 +    /*  91 */   SDL_SCANCODE_UNKNOWN,   /* Hiragana */
   24.22 +    /*  92 */   SDL_SCANCODE_UNKNOWN,   /* Henkan_Mode */
   24.23 +    /*  93 */   SDL_SCANCODE_UNKNOWN,   /* Hiragana_Katakana */
   24.24 +    /*  94 */   SDL_SCANCODE_UNKNOWN,   /* Muhenkan */
   24.25      /*  95 */   SDL_SCANCODE_UNKNOWN,
   24.26 -    /*  96 */   SDL_SCANCODE_UNKNOWN,
   24.27 +    /*  96 */   SDL_SCANCODE_KP_ENTER,
   24.28      /*  97 */   SDL_SCANCODE_RCTRL,
   24.29      /*  98 */   SDL_SCANCODE_KP_DIVIDE,
   24.30 -    /*  99 */   SDL_SCANCODE_UNKNOWN,
   24.31 -    /* 100 */   SDL_SCANCODE_RALT,	 /* ISO_Level3_Shift, ALTGR, RALT */
   24.32 -    /* 101 */   SDL_SCANCODE_UNKNOWN,
   24.33 +    /*  99 */   SDL_SCANCODE_PRINTSCREEN,
   24.34 +    /* 100 */   SDL_SCANCODE_RALT,      /* ISO_Level3_Shift, ALTGR, RALT */
   24.35 +    /* 101 */   SDL_SCANCODE_UNKNOWN,   /* Linefeed */
   24.36      /* 102 */   SDL_SCANCODE_HOME,
   24.37      /* 103 */   SDL_SCANCODE_UP,
   24.38      /* 104 */   SDL_SCANCODE_PAGEUP,
   24.39 @@ -291,40 +291,132 @@
   24.40      /* 110 */   SDL_SCANCODE_INSERT,
   24.41      /* 111 */   SDL_SCANCODE_DELETE,
   24.42      /* 112 */   SDL_SCANCODE_UNKNOWN,
   24.43 -    /* 113 */   SDL_SCANCODE_UNKNOWN,
   24.44 -    /* 114 */   SDL_SCANCODE_UNKNOWN,
   24.45 -    /* 115 */   SDL_SCANCODE_UNKNOWN,
   24.46 -    /* 116 */   SDL_SCANCODE_UNKNOWN,
   24.47 -    /* 117 */   SDL_SCANCODE_UNKNOWN,
   24.48 -    /* 118 */   SDL_SCANCODE_UNKNOWN,
   24.49 -    /* 119 */   SDL_SCANCODE_UNKNOWN,
   24.50 -    /* 120 */   SDL_SCANCODE_UNKNOWN,
   24.51 -    /* 121 */ 	SDL_SCANCODE_PAUSE,
   24.52 -    /* 122 */   SDL_SCANCODE_UNKNOWN,
   24.53 -    /* 123 */   SDL_SCANCODE_UNKNOWN,
   24.54 +    /* 113 */   SDL_SCANCODE_MUTE,
   24.55 +    /* 114 */   SDL_SCANCODE_VOLUMEDOWN,
   24.56 +    /* 115 */   SDL_SCANCODE_VOLUMEUP,
   24.57 +    /* 116 */   SDL_SCANCODE_POWER,
   24.58 +    /* 117 */   SDL_SCANCODE_KP_EQUALS,
   24.59 +    /* 118 */   SDL_SCANCODE_UNKNOWN,   /* plusminus */
   24.60 +    /* 119 */   SDL_SCANCODE_PAUSE,
   24.61 +    /* 120 */   SDL_SCANCODE_UNKNOWN,   /* XF86LaunchA */
   24.62 +    /* 121 */   SDL_SCANCODE_UNKNOWN,	/* KP_Decimal */
   24.63 +    /* 122 */   SDL_SCANCODE_UNKNOWN,   /* Hangul */
   24.64 +    /* 123 */   SDL_SCANCODE_UNKNOWN,   /* Hangul_Hanja */
   24.65      /* 124 */   SDL_SCANCODE_UNKNOWN,
   24.66 -    /* 125 */  SDL_SCANCODE_LGUI,
   24.67 -    /* 126 */  SDL_SCANCODE_RGUI,
   24.68 -    /* 127 */  SDL_SCANCODE_APPLICATION,
   24.69 -    /* 128 */  SDL_SCANCODE_UNKNOWN,
   24.70 -    /* 129 */  SDL_SCANCODE_UNKNOWN,
   24.71 -    /* 130 */  SDL_SCANCODE_UNKNOWN,
   24.72 -    /* 131 */  SDL_SCANCODE_UNKNOWN,
   24.73 -    /* 132 */  SDL_SCANCODE_UNKNOWN,
   24.74 -    /* 133 */  SDL_SCANCODE_UNKNOWN,
   24.75 -    /* 134 */  SDL_SCANCODE_UNKNOWN,
   24.76 -    /* 135 */  SDL_SCANCODE_UNKNOWN,
   24.77 -    /* 136 */  SDL_SCANCODE_UNKNOWN,
   24.78 -    /* 137 */  SDL_SCANCODE_UNKNOWN,
   24.79 -    /* 138 */  SDL_SCANCODE_UNKNOWN,
   24.80 -    /* 139 */  SDL_SCANCODE_UNKNOWN,
   24.81 -    /* 140 */  SDL_SCANCODE_UNKNOWN,
   24.82 -    /* 141 */  SDL_SCANCODE_UNKNOWN,
   24.83 -    /* 142 */  SDL_SCANCODE_UNKNOWN,
   24.84 -    /* 143 */  SDL_SCANCODE_UNKNOWN,
   24.85 -    /* 144 */  SDL_SCANCODE_UNKNOWN,
   24.86 -    /* 145 */  SDL_SCANCODE_UNKNOWN,
   24.87 -    /* 146 */  SDL_SCANCODE_UNKNOWN,
   24.88 +    /* 125 */   SDL_SCANCODE_LGUI,
   24.89 +    /* 126 */   SDL_SCANCODE_RGUI,
   24.90 +    /* 127 */   SDL_SCANCODE_APPLICATION,
   24.91 +    /* 128 */   SDL_SCANCODE_CANCEL,
   24.92 +    /* 129 */   SDL_SCANCODE_AGAIN,
   24.93 +    /* 130 */   SDL_SCANCODE_UNKNOWN,   /* SunProps */
   24.94 +    /* 131 */   SDL_SCANCODE_UNDO,
   24.95 +    /* 132 */   SDL_SCANCODE_UNKNOWN,   /* SunFront */
   24.96 +    /* 133 */   SDL_SCANCODE_COPY,
   24.97 +    /* 134 */   SDL_SCANCODE_UNKNOWN,   /* SunOpen */
   24.98 +    /* 135 */   SDL_SCANCODE_PASTE,
   24.99 +    /* 136 */   SDL_SCANCODE_FIND,
  24.100 +    /* 137 */   SDL_SCANCODE_CUT,
  24.101 +    /* 138 */   SDL_SCANCODE_HELP,
  24.102 +    /* 139 */   SDL_SCANCODE_UNKNOWN,   /* XF86MenuKB */
  24.103 +    /* 140 */   SDL_SCANCODE_CALCULATOR,
  24.104 +    /* 141 */   SDL_SCANCODE_UNKNOWN,
  24.105 +    /* 142 */   SDL_SCANCODE_SLEEP,
  24.106 +    /* 143 */   SDL_SCANCODE_UNKNOWN,   /* XF86WakeUp */
  24.107 +    /* 144 */   SDL_SCANCODE_UNKNOWN,   /* XF86Explorer */
  24.108 +    /* 145 */   SDL_SCANCODE_UNKNOWN,   /* XF86Send */
  24.109 +    /* 146 */   SDL_SCANCODE_UNKNOWN,
  24.110 +    /* 147 */   SDL_SCANCODE_UNKNOWN,   /* XF86Xfer */
  24.111 +    /* 148 */   SDL_SCANCODE_UNKNOWN,   /* XF86Launch1 */
  24.112 +    /* 149 */   SDL_SCANCODE_UNKNOWN,   /* XF86Launch2 */
  24.113 +    /* 150 */   SDL_SCANCODE_WWW,
  24.114 +    /* 151 */   SDL_SCANCODE_UNKNOWN,   /* XF86DOS */
  24.115 +    /* 152 */   SDL_SCANCODE_UNKNOWN,   /* XF86ScreenSaver */
  24.116 +    /* 153 */   SDL_SCANCODE_UNKNOWN,
  24.117 +    /* 154 */   SDL_SCANCODE_UNKNOWN,   /* XF86RotateWindows */
  24.118 +    /* 155 */   SDL_SCANCODE_MAIL,
  24.119 +    /* 156 */   SDL_SCANCODE_UNKNOWN,   /* XF86Favorites */
  24.120 +    /* 157 */   SDL_SCANCODE_COMPUTER,
  24.121 +    /* 158 */   SDL_SCANCODE_AC_BACK,
  24.122 +    /* 159 */   SDL_SCANCODE_AC_FORWARD,
  24.123 +    /* 160 */   SDL_SCANCODE_UNKNOWN,
  24.124 +    /* 161 */   SDL_SCANCODE_EJECT,
  24.125 +    /* 162 */   SDL_SCANCODE_EJECT,
  24.126 +    /* 163 */   SDL_SCANCODE_AUDIONEXT,
  24.127 +    /* 164 */   SDL_SCANCODE_AUDIOPLAY,
  24.128 +    /* 165 */   SDL_SCANCODE_AUDIOPREV,
  24.129 +    /* 166 */   SDL_SCANCODE_AUDIOSTOP,
  24.130 +    /* 167 */   SDL_SCANCODE_UNKNOWN,   /* XF86AudioRecord */
  24.131 +    /* 168 */   SDL_SCANCODE_UNKNOWN,   /* XF86AudioRewind */
  24.132 +    /* 169 */   SDL_SCANCODE_UNKNOWN,   /* XF86Phone */
  24.133 +    /* 170 */   SDL_SCANCODE_UNKNOWN,
  24.134 +    /* 171 */   SDL_SCANCODE_UNKNOWN,   /* XF86Tools */
  24.135 +    /* 172 */   SDL_SCANCODE_AC_HOME,
  24.136 +    /* 173 */   SDL_SCANCODE_AC_REFRESH,
  24.137 +    /* 174 */   SDL_SCANCODE_UNKNOWN,   /* XF86Close */
  24.138 +    /* 175 */   SDL_SCANCODE_UNKNOWN,
  24.139 +    /* 176 */   SDL_SCANCODE_UNKNOWN,
  24.140 +    /* 177 */   SDL_SCANCODE_UNKNOWN,   /* XF86ScrollUp */
  24.141 +    /* 178 */   SDL_SCANCODE_UNKNOWN,   /* XF86ScrollDown */
  24.142 +    /* 179 */   SDL_SCANCODE_UNKNOWN,   /* parenleft */
  24.143 +    /* 180 */   SDL_SCANCODE_UNKNOWN,   /* parenright */
  24.144 +    /* 181 */   SDL_SCANCODE_UNKNOWN,   /* XF86New */
  24.145 +    /* 182 */   SDL_SCANCODE_AGAIN,
  24.146 +    /* 183 */   SDL_SCANCODE_UNKNOWN,   /* XF86Tools */
  24.147 +    /* 184 */   SDL_SCANCODE_UNKNOWN,   /* XF86Launch5 */
  24.148 +    /* 185 */   SDL_SCANCODE_UNKNOWN,   /* XF86MenuKB */
  24.149 +    /* 186 */   SDL_SCANCODE_UNKNOWN,
  24.150 +    /* 187 */   SDL_SCANCODE_UNKNOWN,
  24.151 +    /* 188 */   SDL_SCANCODE_UNKNOWN,
  24.152 +    /* 189 */   SDL_SCANCODE_UNKNOWN,
  24.153 +    /* 190 */   SDL_SCANCODE_UNKNOWN,
  24.154 +    /* 191 */   SDL_SCANCODE_UNKNOWN,
  24.155 +    /* 192 */   SDL_SCANCODE_UNKNOWN,   /* XF86TouchpadToggle */
  24.156 +    /* 193 */   SDL_SCANCODE_UNKNOWN,
  24.157 +    /* 194 */   SDL_SCANCODE_UNKNOWN,
  24.158 +    /* 195 */   SDL_SCANCODE_MODE,
  24.159 +    /* 196 */   SDL_SCANCODE_UNKNOWN,
  24.160 +    /* 197 */   SDL_SCANCODE_UNKNOWN,
  24.161 +    /* 198 */   SDL_SCANCODE_UNKNOWN,
  24.162 +    /* 199 */   SDL_SCANCODE_UNKNOWN,
  24.163 +    /* 200 */   SDL_SCANCODE_AUDIOPLAY,
  24.164 +    /* 201 */   SDL_SCANCODE_UNKNOWN,   /* XF86AudioPause */
  24.165 +    /* 202 */   SDL_SCANCODE_UNKNOWN,   /* XF86Launch3 */
  24.166 +    /* 203 */   SDL_SCANCODE_UNKNOWN,   /* XF86Launch4 */
  24.167 +    /* 204 */   SDL_SCANCODE_UNKNOWN,   /* XF86LaunchB */
  24.168 +    /* 205 */   SDL_SCANCODE_UNKNOWN,   /* XF86Suspend */
  24.169 +    /* 206 */   SDL_SCANCODE_UNKNOWN,   /* XF86Close */
  24.170 +    /* 207 */   SDL_SCANCODE_AUDIOPLAY,
  24.171 +    /* 208 */   SDL_SCANCODE_AUDIONEXT,
  24.172 +    /* 209 */   SDL_SCANCODE_UNKNOWN,
  24.173 +    /* 210 */   SDL_SCANCODE_PRINTSCREEN,
  24.174 +    /* 211 */   SDL_SCANCODE_UNKNOWN,
  24.175 +    /* 212 */   SDL_SCANCODE_UNKNOWN,   /* XF86WebCam */
  24.176 +    /* 213 */   SDL_SCANCODE_UNKNOWN,
  24.177 +    /* 214 */   SDL_SCANCODE_UNKNOWN,
  24.178 +    /* 215 */   SDL_SCANCODE_MAIL,
  24.179 +    /* 216 */   SDL_SCANCODE_UNKNOWN,
  24.180 +    /* 217 */   SDL_SCANCODE_AC_SEARCH,
  24.181 +    /* 218 */   SDL_SCANCODE_UNKNOWN,
  24.182 +    /* 219 */   SDL_SCANCODE_UNKNOWN,   /* XF86Finance */
  24.183 +    /* 220 */   SDL_SCANCODE_UNKNOWN,
  24.184 +    /* 221 */   SDL_SCANCODE_UNKNOWN,   /* XF86Shop */
  24.185 +    /* 222 */   SDL_SCANCODE_UNKNOWN,
  24.186 +    /* 223 */   SDL_SCANCODE_STOP,
  24.187 +    /* 224 */   SDL_SCANCODE_BRIGHTNESSDOWN,
  24.188 +    /* 225 */   SDL_SCANCODE_BRIGHTNESSUP,
  24.189 +    /* 226 */   SDL_SCANCODE_MEDIASELECT,
  24.190 +    /* 227 */   SDL_SCANCODE_DISPLAYSWITCH,
  24.191 +    /* 228 */   SDL_SCANCODE_KBDILLUMTOGGLE,
  24.192 +    /* 229 */   SDL_SCANCODE_KBDILLUMDOWN,
  24.193 +    /* 230 */   SDL_SCANCODE_KBDILLUMUP,
  24.194 +    /* 231 */   SDL_SCANCODE_UNKNOWN,   /* XF86Send */
  24.195 +    /* 232 */   SDL_SCANCODE_UNKNOWN,   /* XF86Reply */
  24.196 +    /* 233 */   SDL_SCANCODE_UNKNOWN,   /* XF86MailForward */
  24.197 +    /* 234 */   SDL_SCANCODE_UNKNOWN,   /* XF86Save */
  24.198 +    /* 235 */   SDL_SCANCODE_UNKNOWN,   /* XF86Documents */
  24.199 +    /* 236 */   SDL_SCANCODE_UNKNOWN,   /* XF86Battery */
  24.200 +    /* 237 */   SDL_SCANCODE_UNKNOWN,   /* XF86Bluetooth */
  24.201 +    /* 238 */   SDL_SCANCODE_UNKNOWN,   /* XF86WLAN */
  24.202  };
  24.203  
  24.204  /* *INDENT-ON* */
    25.1 --- a/src/haptic/linux/SDL_syshaptic.c	Tue Jul 13 15:05:45 2010 -0400
    25.2 +++ b/src/haptic/linux/SDL_syshaptic.c	Sun Jul 18 13:48:23 2010 -0400
    25.3 @@ -254,8 +254,6 @@
    25.4  static int
    25.5  SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd)
    25.6  {
    25.7 -    const char *name;
    25.8 -
    25.9      /* Allocate the hwdata */
   25.10      haptic->hwdata = (struct haptic_hwdata *)
   25.11          SDL_malloc(sizeof(*haptic->hwdata));
    26.1 --- a/src/joystick/bsd/SDL_sysjoystick.c	Tue Jul 13 15:05:45 2010 -0400
    26.2 +++ b/src/joystick/bsd/SDL_sysjoystick.c	Sun Jul 18 13:48:23 2010 -0400
    26.3 @@ -59,7 +59,7 @@
    26.4  #include <libusbhid.h>
    26.5  #endif
    26.6  
    26.7 -#ifdef __FREEBSD__
    26.8 +#ifdef defined(__FREEBSD__) || defined(__FreeBSD_kernel__)
    26.9  #ifndef __DragonFly__
   26.10  #include <osreldate.h>
   26.11  #endif
   26.12 @@ -78,7 +78,7 @@
   26.13  #define MAX_JOY_JOYS	2
   26.14  #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
   26.15  
   26.16 -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
   26.17 +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) && false
   26.18  struct usb_ctl_report {
   26.19      int     ucr_report;
   26.20      u_char  ucr_data[1024]; /* filled data size will vary */
   26.21 @@ -149,7 +149,7 @@
   26.22  static int report_alloc(struct report *, struct report_desc *, int);
   26.23  static void report_free(struct report *);
   26.24  
   26.25 -#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
   26.26 +#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__)
   26.27  #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
   26.28  #else
   26.29  #define REP_BUF_DATA(rep) ((rep)->buf->data)
   26.30 @@ -308,7 +308,7 @@
   26.31          goto usberr;
   26.32      }
   26.33      rep = &hw->inreport;
   26.34 -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
   26.35 +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__)
   26.36      rep->rid = hid_get_report_id(fd);
   26.37      if (rep->rid < 0) {
   26.38  #else
   26.39 @@ -324,7 +324,7 @@
   26.40                       hw->path);
   26.41          goto usberr;
   26.42      }
   26.43 -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111)
   26.44 +#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
   26.45      hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
   26.46  #else
   26.47      hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
   26.48 @@ -409,7 +409,7 @@
   26.49      int nbutton, naxe = -1;
   26.50      Sint32 v;
   26.51  
   26.52 -#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
   26.53 +#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__)
   26.54      struct joystick gameport;
   26.55      static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
   26.56  
   26.57 @@ -466,7 +466,7 @@
   26.58      if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
   26.59          return;
   26.60      }
   26.61 -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111)
   26.62 +#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
   26.63      hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
   26.64  #else
   26.65      hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
    27.1 --- a/src/main/win32/SDL_win32_main.c	Tue Jul 13 15:05:45 2010 -0400
    27.2 +++ b/src/main/win32/SDL_win32_main.c	Sun Jul 18 13:48:23 2010 -0400
    27.3 @@ -71,6 +71,7 @@
    27.4                  ++argc;
    27.5              }
    27.6              /* Skip over word */
    27.7 +            lastp = bufp;
    27.8              while (*bufp && (*bufp != '"' || *lastp == '\\')) {
    27.9                  lastp = bufp;
   27.10                  ++bufp;
    28.1 --- a/src/timer/SDL_systimer.h	Tue Jul 13 15:05:45 2010 -0400
    28.2 +++ b/src/timer/SDL_systimer.h	Sun Jul 18 13:48:23 2010 -0400
    28.3 @@ -38,4 +38,5 @@
    28.4  
    28.5  /* Stop a previously started timer */
    28.6  extern void SDL_SYS_StopTimer(void);
    28.7 +
    28.8  /* vi: set ts=4 sw=4 expandtab: */
    29.1 --- a/src/timer/unix/SDL_systimer.c	Tue Jul 13 15:05:45 2010 -0400
    29.2 +++ b/src/timer/unix/SDL_systimer.c	Sun Jul 18 13:48:23 2010 -0400
    29.3 @@ -31,6 +31,7 @@
    29.4  #include <errno.h>
    29.5  
    29.6  #include "SDL_timer.h"
    29.7 +#include "../SDL_systimer.h"
    29.8  #include "../SDL_timer_c.h"
    29.9  
   29.10  /* The clock_gettime provides monotonous time, so we should use it if
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/video/SDL_clipboard.c	Sun Jul 18 13:48:23 2010 -0400
    30.3 @@ -0,0 +1,76 @@
    30.4 +/*
    30.5 +    SDL - Simple DirectMedia Layer
    30.6 +    Copyright (C) 1997-2010 Sam Lantinga
    30.7 +
    30.8 +    This library is free software; you can redistribute it and/or
    30.9 +    modify it under the terms of the GNU Lesser General Public
   30.10 +    License as published by the Free Software Foundation; either
   30.11 +    version 2.1 of the License, or (at your option) any later version.
   30.12 +
   30.13 +    This library is distributed in the hope that it will be useful,
   30.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.16 +    Lesser General Public License for more details.
   30.17 +
   30.18 +    You should have received a copy of the GNU Lesser General Public
   30.19 +    License along with this library; if not, write to the Free Software
   30.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   30.21 +
   30.22 +    Sam Lantinga
   30.23 +    slouken@libsdl.org
   30.24 +*/
   30.25 +#include "SDL_config.h"
   30.26 +
   30.27 +#include "SDL_clipboard.h"
   30.28 +#include "SDL_sysvideo.h"
   30.29 +
   30.30 +
   30.31 +int
   30.32 +SDL_SetClipboardText(const char *text)
   30.33 +{
   30.34 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   30.35 +
   30.36 +    if (!text) {
   30.37 +        text = "";
   30.38 +    }
   30.39 +    if (_this->SetClipboardText) {
   30.40 +        return _this->SetClipboardText(_this, text);
   30.41 +    } else {
   30.42 +        _this->clipboard_text = SDL_strdup(text);
   30.43 +        return 0;
   30.44 +    }
   30.45 +}
   30.46 +
   30.47 +char *
   30.48 +SDL_GetClipboardText(void)
   30.49 +{
   30.50 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   30.51 +
   30.52 +    if (_this->GetClipboardText) {
   30.53 +        return _this->GetClipboardText(_this);
   30.54 +    } else {
   30.55 +        const char *text = _this->clipboard_text;
   30.56 +        if (!text) {
   30.57 +            text = "";
   30.58 +        }
   30.59 +        return SDL_strdup(text);
   30.60 +    }
   30.61 +}
   30.62 +
   30.63 +SDL_bool
   30.64 +SDL_HasClipboardText(void)
   30.65 +{
   30.66 +    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   30.67 +
   30.68 +    if (_this->HasClipboardText) {
   30.69 +        return _this->HasClipboardText(_this);
   30.70 +    } else {
   30.71 +        if (_this->clipboard_text) {
   30.72 +            return SDL_TRUE;
   30.73 +        } else {
   30.74 +            return SDL_FALSE;
   30.75 +        }
   30.76 +    }
   30.77 +}
   30.78 +
   30.79 +/* vi: set ts=4 sw=4 expandtab: */
    31.1 --- a/src/video/SDL_renderer_gles.c	Tue Jul 13 15:05:45 2010 -0400
    31.2 +++ b/src/video/SDL_renderer_gles.c	Sun Jul 18 13:48:23 2010 -0400
    31.3 @@ -822,20 +822,25 @@
    31.4                 maybe it'd be a good idea to keep a temp buffer around
    31.5                 for this purpose rather than allocating it each time
    31.6               */
    31.7 -            temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
    31.8 -            temp_ptr = temp_buffer;
    31.9 -            for (i = 0; i < rect->h; i++) {
   31.10 -                SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
   31.11 -                temp_ptr += rect->w * bpp;
   31.12 -                pixels += pitch;
   31.13 +            if( rect->x == 0 && rect->w * bpp == pitch ) {
   31.14 +                temp_buffer = pixels; /* Updating whole texture, no need to reformat */
   31.15 +            } else {
   31.16 +                temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
   31.17 +                temp_ptr = temp_buffer;
   31.18 +                for (i = 0; i < rect->h; i++) {
   31.19 +                    SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
   31.20 +                    temp_ptr += rect->w * bpp;
   31.21 +                    pixels += pitch;
   31.22 +                }
   31.23              }
   31.24  
   31.25              data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
   31.26                                    rect->w, rect->h, texturedata->format,
   31.27                                    texturedata->formattype, temp_buffer);
   31.28  
   31.29 -            SDL_free(temp_buffer);
   31.30 -
   31.31 +            if( temp_buffer != pixels ) {
   31.32 +                SDL_free(temp_buffer);
   31.33 +            }
   31.34          }
   31.35          SDL_ClearDirtyRects(&texturedata->dirty);
   31.36      }
    32.1 --- a/src/video/SDL_renderer_sw.c	Tue Jul 13 15:05:45 2010 -0400
    32.2 +++ b/src/video/SDL_renderer_sw.c	Sun Jul 18 13:48:23 2010 -0400
    32.3 @@ -795,7 +795,6 @@
    32.4                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
    32.5  {
    32.6      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    32.7 -    SDL_Window *window = renderer->window;
    32.8      int status;
    32.9  
   32.10      if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
    33.1 --- a/src/video/SDL_stretch.c	Tue Jul 13 15:05:45 2010 -0400
    33.2 +++ b/src/video/SDL_stretch.c	Sun Jul 18 13:48:23 2010 -0400
    33.3 @@ -80,7 +80,7 @@
    33.4  
    33.5      int i;
    33.6      int pos, inc;
    33.7 -    unsigned char *eip;
    33.8 +    unsigned char *eip, *fence;
    33.9      unsigned char load, store;
   33.10  
   33.11      /* See if we need to regenerate the copy buffer */
   33.12 @@ -116,14 +116,21 @@
   33.13      pos = 0x10000;
   33.14      inc = (src_w << 16) / dst_w;
   33.15      eip = copy_row;
   33.16 +    fence = copy_row + sizeof(copy_row)-2;
   33.17      for (i = 0; i < dst_w; ++i) {
   33.18          while (pos >= 0x10000L) {
   33.19 +            if (eip == fence) {
   33.20 +                return -1;
   33.21 +            }
   33.22              if (bpp == 2) {
   33.23                  *eip++ = PREFIX16;
   33.24              }
   33.25              *eip++ = load;
   33.26              pos -= 0x10000L;
   33.27          }
   33.28 +        if (eip == fence) {
   33.29 +            return -1;
   33.30 +        }
   33.31          if (bpp == 2) {
   33.32              *eip++ = PREFIX16;
   33.33          }
   33.34 @@ -132,11 +139,6 @@
   33.35      }
   33.36      *eip++ = RETURN;
   33.37  
   33.38 -    /* Verify that we didn't overflow (too late!!!) */
   33.39 -    if (eip > (copy_row + sizeof(copy_row))) {
   33.40 -        SDL_SetError("Copy buffer overflow");
   33.41 -        return (-1);
   33.42 -    }
   33.43  #ifdef HAVE_MPROTECT
   33.44      /* Make the code executable but not writeable */
   33.45      if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) {
    34.1 --- a/src/video/SDL_surface.c	Tue Jul 13 15:05:45 2010 -0400
    34.2 +++ b/src/video/SDL_surface.c	Sun Jul 18 13:48:23 2010 -0400
    34.3 @@ -851,7 +851,7 @@
    34.4      /* Enable alpha blending by default if the new surface has an
    34.5       * alpha channel or alpha modulation */
    34.6      if ((surface->format->Amask && format->Amask) ||
    34.7 -        (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
    34.8 +        (copy_flags & (SDL_COPY_COLORKEY|SDL_COPY_MODULATE_ALPHA))) {
    34.9          SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
   34.10      }
   34.11      if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
    35.1 --- a/src/video/SDL_sysvideo.h	Tue Jul 13 15:05:45 2010 -0400
    35.2 +++ b/src/video/SDL_sysvideo.h	Sun Jul 18 13:48:23 2010 -0400
    35.3 @@ -303,6 +303,11 @@
    35.4      void (*StopTextInput) (_THIS);
    35.5      void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
    35.6  
    35.7 +    /* Clipboard */
    35.8 +    int (*SetClipboardText) (_THIS, const char *text);
    35.9 +    char * (*GetClipboardText) (_THIS);
   35.10 +    SDL_bool (*HasClipboardText) (_THIS);
   35.11 +
   35.12      /* * * */
   35.13      /* Data common to all drivers */
   35.14      SDL_bool suspend_screensaver;
   35.15 @@ -312,6 +317,7 @@
   35.16      Uint8 window_magic;
   35.17      Uint8 texture_magic;
   35.18      Uint32 next_object_id;
   35.19 +    char * clipboard_text;
   35.20  
   35.21      /* * * */
   35.22      /* Data used by the GL drivers */
    36.1 --- a/src/video/SDL_video.c	Tue Jul 13 15:05:45 2010 -0400
    36.2 +++ b/src/video/SDL_video.c	Sun Jul 18 13:48:23 2010 -0400
    36.3 @@ -2833,6 +2833,10 @@
    36.4          SDL_free(_this->displays);
    36.5          _this->displays = NULL;
    36.6      }
    36.7 +    if (_this->clipboard_text) {
    36.8 +        SDL_free(_this->clipboard_text);
    36.9 +        _this->clipboard_text = NULL;
   36.10 +    }
   36.11      _this->free(_this);
   36.12      _this = NULL;
   36.13  }
   36.14 @@ -3267,7 +3271,7 @@
   36.15  void
   36.16  SDL_GL_DeleteContext(SDL_GLContext context)
   36.17  {
   36.18 -    if (!_this || !context) {
   36.19 +    if (!_this || !_this->gl_data || !context) {
   36.20          return;
   36.21      }
   36.22      _this->GL_MakeCurrent(_this, NULL, NULL);
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.h	Sun Jul 18 13:48:23 2010 -0400
    37.3 @@ -0,0 +1,37 @@
    37.4 +/*
    37.5 +    SDL - Simple DirectMedia Layer
    37.6 +    Copyright (C) 1997-2010 Sam Lantinga
    37.7 +
    37.8 +    This library is free software; you can redistribute it and/or
    37.9 +    modify it under the terms of the GNU Lesser General Public
   37.10 +    License as published by the Free Software Foundation; either
   37.11 +    version 2.1 of the License, or (at your option) any later version.
   37.12 +
   37.13 +    This library is distributed in the hope that it will be useful,
   37.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   37.16 +    Lesser General Public License for more details.
   37.17 +
   37.18 +    You should have received a copy of the GNU Lesser General Public
   37.19 +    License along with this library; if not, write to the Free Software
   37.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   37.21 +
   37.22 +    Sam Lantinga
   37.23 +    slouken@libsdl.org
   37.24 +*/
   37.25 +#include "SDL_config.h"
   37.26 +
   37.27 +#ifndef _SDL_cocoaclipboard_h
   37.28 +#define _SDL_cocoaclipboard_h
   37.29 +
   37.30 +/* Forward declaration */
   37.31 +struct SDL_VideoData;
   37.32 +
   37.33 +extern int Cocoa_SetClipboardText(_THIS, const char *text);
   37.34 +extern char *Cocoa_GetClipboardText(_THIS);
   37.35 +extern SDL_bool Cocoa_HasClipboardText(_THIS);
   37.36 +extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data);
   37.37 +
   37.38 +#endif /* _SDL_cocoaclipboard_h */
   37.39 +
   37.40 +/* vi: set ts=4 sw=4 expandtab: */
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Sun Jul 18 13:48:23 2010 -0400
    38.3 @@ -0,0 +1,140 @@
    38.4 +/*
    38.5 +    SDL - Simple DirectMedia Layer
    38.6 +    Copyright (C) 1997-2010 Sam Lantinga
    38.7 +
    38.8 +    This library is free software; you can redistribute it and/or
    38.9 +    modify it under the terms of the GNU Lesser General Public
   38.10 +    License as published by the Free Software Foundation; either
   38.11 +    version 2.1 of the License, or (at your option) any later version.
   38.12 +
   38.13 +    This library is distributed in the hope that it will be useful,
   38.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   38.16 +    Lesser General Public License for more details.
   38.17 +
   38.18 +    You should have received a copy of the GNU Lesser General Public
   38.19 +    License along with this library; if not, write to the Free Software
   38.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   38.21 +
   38.22 +    Sam Lantinga
   38.23 +    slouken@libsdl.org
   38.24 +*/
   38.25 +#include "SDL_config.h"
   38.26 +
   38.27 +#include "SDL_cocoavideo.h"
   38.28 +#include "../../events/SDL_clipboardevents_c.h"
   38.29 +
   38.30 +static NSString *
   38.31 +GetTextFormat(_THIS)
   38.32 +{
   38.33 +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
   38.34 +    return NSStringPboardType;
   38.35 +#else
   38.36 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   38.37 +
   38.38 +    if (data->osversion >= 0x1060) {
   38.39 +        return NSPasteboardTypeString;
   38.40 +    } else {
   38.41 +        return NSStringPboardType;
   38.42 +    }
   38.43 +#endif
   38.44 +}
   38.45 +
   38.46 +int
   38.47 +Cocoa_SetClipboardText(_THIS, const char *text)
   38.48 +{
   38.49 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   38.50 +    NSAutoreleasePool *pool;
   38.51 +    NSPasteboard *pasteboard;
   38.52 +    NSString *format = GetTextFormat(_this);
   38.53 +
   38.54 +    pool = [[NSAutoreleasePool alloc] init];
   38.55 +
   38.56 +    pasteboard = [NSPasteboard generalPasteboard];
   38.57 +    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
   38.58 +    [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
   38.59 +
   38.60 +    [pool release];
   38.61 +
   38.62 +    return 0;
   38.63 +}
   38.64 +
   38.65 +char *
   38.66 +Cocoa_GetClipboardText(_THIS)
   38.67 +{
   38.68 +    NSAutoreleasePool *pool;
   38.69 +    NSPasteboard *pasteboard;
   38.70 +    NSString *format = GetTextFormat(_this);
   38.71 +    NSString *available;
   38.72 +    char *text;
   38.73 +
   38.74 +    pool = [[NSAutoreleasePool alloc] init];
   38.75 +
   38.76 +    pasteboard = [NSPasteboard generalPasteboard];
   38.77 +    available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
   38.78 +    if ([available isEqualToString:format]) {
   38.79 +        NSString* string;
   38.80 +        const char *utf8;
   38.81 +
   38.82 +        string = [pasteboard stringForType:format];
   38.83 +        if (string == nil) {
   38.84 +            utf8 = "";
   38.85 +        } else {
   38.86 +            utf8 = [string UTF8String];
   38.87 +        }
   38.88 +        text = SDL_strdup(utf8);
   38.89 +    } else {
   38.90 +        text = SDL_strdup("");
   38.91 +    }
   38.92 +
   38.93 +    [pool release];
   38.94 +
   38.95 +    return text;
   38.96 +}
   38.97 +
   38.98 +SDL_bool
   38.99 +Cocoa_HasClipboardText(_THIS)
  38.100 +{
  38.101 +    NSAutoreleasePool *pool;
  38.102 +    NSPasteboard *pasteboard;
  38.103 +    NSString *format = GetTextFormat(_this);
  38.104 +    NSString *available;
  38.105 +    SDL_bool result;
  38.106 +
  38.107 +    pool = [[NSAutoreleasePool alloc] init];
  38.108 +
  38.109 +    pasteboard = [NSPasteboard generalPasteboard];
  38.110 +    available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
  38.111 +    if ([available isEqualToString:format]) {
  38.112 +        result = SDL_TRUE;
  38.113 +    } else {
  38.114 +        result = SDL_FALSE;
  38.115 +    }
  38.116 +
  38.117 +    [pool release];
  38.118 +
  38.119 +    return result;
  38.120 +}
  38.121 +
  38.122 +void
  38.123 +Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
  38.124 +{
  38.125 +    NSAutoreleasePool *pool;
  38.126 +    NSPasteboard *pasteboard;
  38.127 +    NSInteger count;
  38.128 +
  38.129 +    pool = [[NSAutoreleasePool alloc] init];
  38.130 +
  38.131 +    pasteboard = [NSPasteboard generalPasteboard];
  38.132 +    count = [pasteboard changeCount];
  38.133 +    if (count != data->clipboard_count) {
  38.134 +        if (data->clipboard_count) {
  38.135 +            SDL_SendClipboardUpdate();
  38.136 +        }
  38.137 +        data->clipboard_count = count;
  38.138 +    }
  38.139 +
  38.140 +    [pool release];
  38.141 +}
  38.142 +
  38.143 +/* vi: set ts=4 sw=4 expandtab: */
    39.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 13 15:05:45 2010 -0400
    39.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Sun Jul 18 13:48:23 2010 -0400
    39.3 @@ -1,6 +1,6 @@
    39.4  /*
    39.5      SDL - Simple DirectMedia Layer
    39.6 -    Copyright (C) 1997-2009 Sam Lantinga
    39.7 +    Copyright (C) 1997-2010 Sam Lantinga
    39.8  
    39.9      This library is free software; you can redistribute it and/or
   39.10      modify it under the terms of the GNU Lesser General Public
    40.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Tue Jul 13 15:05:45 2010 -0400
    40.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sun Jul 18 13:48:23 2010 -0400
    40.3 @@ -1,6 +1,6 @@
    40.4  /*
    40.5      SDL - Simple DirectMedia Layer
    40.6 -    Copyright (C) 1997-2009 Sam Lantinga
    40.7 +    Copyright (C) 1997-2010 Sam Lantinga
    40.8  
    40.9      This library is free software; you can redistribute it and/or
   40.10      modify it under the terms of the GNU Lesser General Public
    41.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Tue Jul 13 15:05:45 2010 -0400
    41.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Sun Jul 18 13:48:23 2010 -0400
    41.3 @@ -1,6 +1,6 @@
    41.4  /*
    41.5      SDL - Simple DirectMedia Layer
    41.6 -    Copyright (C) 1997-2009 Sam Lantinga
    41.7 +    Copyright (C) 1997-2010 Sam Lantinga
    41.8  
    41.9      This library is free software; you can redistribute it and/or
   41.10      modify it under the terms of the GNU Lesser General Public
    42.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Tue Jul 13 15:05:45 2010 -0400
    42.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sun Jul 18 13:48:23 2010 -0400
    42.3 @@ -1,6 +1,6 @@
    42.4  /*
    42.5      SDL - Simple DirectMedia Layer
    42.6 -    Copyright (C) 1997-2009 Sam Lantinga
    42.7 +    Copyright (C) 1997-2010 Sam Lantinga
    42.8  
    42.9      This library is free software; you can redistribute it and/or
   42.10      modify it under the terms of the GNU Lesser General Public
    43.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Tue Jul 13 15:05:45 2010 -0400
    43.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Sun Jul 18 13:48:23 2010 -0400
    43.3 @@ -1,6 +1,6 @@
    43.4  /*
    43.5      SDL - Simple DirectMedia Layer
    43.6 -    Copyright (C) 1997-2009 Sam Lantinga
    43.7 +    Copyright (C) 1997-2010 Sam Lantinga
    43.8  
    43.9      This library is free software; you can redistribute it and/or
   43.10      modify it under the terms of the GNU Lesser General Public
    44.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Tue Jul 13 15:05:45 2010 -0400
    44.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Sun Jul 18 13:48:23 2010 -0400
    44.3 @@ -32,6 +32,7 @@
    44.4  #include "SDL_keysym.h"
    44.5  #include "../SDL_sysvideo.h"
    44.6  
    44.7 +#include "SDL_cocoaclipboard.h"
    44.8  #include "SDL_cocoaevents.h"
    44.9  #include "SDL_cocoakeyboard.h"
   44.10  #include "SDL_cocoamodes.h"
   44.11 @@ -59,6 +60,7 @@
   44.12      unsigned int modifierFlags;
   44.13      void *key_layout;
   44.14      SDLTranslatorResponder *fieldEdit;
   44.15 +    NSInteger clipboard_count;
   44.16      Uint32 screensaver_activity;
   44.17  } SDL_VideoData;
   44.18  
    45.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Tue Jul 13 15:05:45 2010 -0400
    45.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Sun Jul 18 13:48:23 2010 -0400
    45.3 @@ -1,6 +1,6 @@
    45.4  /*
    45.5      SDL - Simple DirectMedia Layer
    45.6 -    Copyright (C) 1997-2009 Sam Lantinga
    45.7 +    Copyright (C) 1997-2010 Sam Lantinga
    45.8  
    45.9      This library is free software; you can redistribute it and/or
   45.10      modify it under the terms of the GNU Lesser General Public
   45.11 @@ -108,6 +108,10 @@
   45.12      device->StopTextInput = Cocoa_StopTextInput;
   45.13      device->SetTextInputRect = Cocoa_SetTextInputRect;
   45.14  
   45.15 +    device->SetClipboardText = Cocoa_SetClipboardText;
   45.16 +    device->GetClipboardText = Cocoa_GetClipboardText;
   45.17 +    device->HasClipboardText = Cocoa_HasClipboardText;
   45.18 +
   45.19      device->free = Cocoa_DeleteDevice;
   45.20  
   45.21      return device;
    46.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Jul 13 15:05:45 2010 -0400
    46.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jul 18 13:48:23 2010 -0400
    46.3 @@ -1,6 +1,6 @@
    46.4  /*
    46.5      SDL - Simple DirectMedia Layer
    46.6 -    Copyright (C) 1997-2009 Sam Lantinga
    46.7 +    Copyright (C) 1997-2010 Sam Lantinga
    46.8  
    46.9      This library is free software; you can redistribute it and/or
   46.10      modify it under the terms of the GNU Lesser General Public
   46.11 @@ -128,6 +128,9 @@
   46.12  {
   46.13      /* We're going to get keyboard events, since we're key. */
   46.14      SDL_SetKeyboardFocus(_data->window);
   46.15 +
   46.16 +    /* Check to see if someone updated the clipboard */
   46.17 +    Cocoa_CheckClipboardUpdate(_data->videodata);
   46.18  }
   46.19  
   46.20  - (void)windowDidResignKey:(NSNotification *)aNotification
    47.1 --- a/src/video/uikit/SDL_uikitappdelegate.m	Tue Jul 13 15:05:45 2010 -0400
    47.2 +++ b/src/video/uikit/SDL_uikitappdelegate.m	Sun Jul 18 13:48:23 2010 -0400
    47.3 @@ -42,11 +42,12 @@
    47.4  	
    47.5  	/* store arguments */
    47.6  	forward_argc = argc;
    47.7 -	forward_argv = (char **)malloc(argc * sizeof(char *));
    47.8 +	forward_argv = (char **)malloc((argc+1) * sizeof(char *));
    47.9  	for (i=0; i<argc; i++) {
   47.10  		forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
   47.11  		strcpy(forward_argv[i], argv[i]);
   47.12  	}
   47.13 +	forward_argv[i] = NULL;
   47.14  
   47.15  	/* Give over control to run loop, SDLUIKitDelegate will handle most things from here */
   47.16  	UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate");
    48.1 --- a/src/video/uikit/SDL_uikitopengles.m	Tue Jul 13 15:05:45 2010 -0400
    48.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Sun Jul 18 13:48:23 2010 -0400
    48.3 @@ -26,6 +26,8 @@
    48.4  #include "SDL_uikitwindow.h"
    48.5  #include "jumphack.h"
    48.6  #include "SDL_sysvideo.h"
    48.7 +#include "../../events/SDL_keyboard_c.h"
    48.8 +#include "../../events/SDL_mouse_c.h"
    48.9  #include "SDL_loadso.h"
   48.10  #include <dlfcn.h>
   48.11  
   48.12 @@ -125,7 +127,11 @@
   48.13          UIKit_GL_DeleteContext(_this, view);
   48.14          return NULL;
   48.15      }
   48.16 -		
   48.17 +
   48.18 +	/* Make this window the current mouse focus for touch input */
   48.19 +	SDL_SetMouseFocus(window);
   48.20 +	SDL_SetKeyboardFocus(window);
   48.21 +
   48.22  	return view;
   48.23  }
   48.24  
    49.1 --- a/src/video/uikit/SDL_uikitview.h	Tue Jul 13 15:05:45 2010 -0400
    49.2 +++ b/src/video/uikit/SDL_uikitview.h	Sun Jul 18 13:48:23 2010 -0400
    49.3 @@ -22,8 +22,6 @@
    49.4  
    49.5  #import <UIKit/UIKit.h>
    49.6  #include "SDL_stdinc.h"
    49.7 -#include "SDL_mouse.h"
    49.8 -#include "SDL_mouse_c.h"
    49.9  #include "SDL_events.h"
   49.10  
   49.11  #if SDL_IPHONE_MULTIPLE_MICE
   49.12 @@ -38,7 +36,7 @@
   49.13  #else
   49.14  @interface SDL_uikitview : UIView {
   49.15  #endif
   49.16 -	
   49.17 +
   49.18  #if FIXME_MULTITOUCH
   49.19  	SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
   49.20  #endif
    50.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Jul 13 15:05:45 2010 -0400
    50.2 +++ b/src/video/uikit/SDL_uikitview.m	Sun Jul 18 13:48:23 2010 -0400
    50.3 @@ -22,8 +22,10 @@
    50.4  
    50.5  #import "SDL_uikitview.h"
    50.6  
    50.7 +#include "../../events/SDL_keyboard_c.h"
    50.8 +#include "../../events/SDL_mouse_c.h"
    50.9 +
   50.10  #if SDL_IPHONE_KEYBOARD
   50.11 -#import "SDL_keyboard_c.h"
   50.12  #import "keyinfotable.h"
   50.13  #import "SDL_uikitappdelegate.h"
   50.14  #import "SDL_uikitwindow.h"
   50.15 @@ -33,7 +35,6 @@
   50.16  
   50.17  - (void)dealloc {
   50.18  #if SDL_IPHONE_KEYBOARD
   50.19 -	SDL_DelKeyboard(0);
   50.20  	[textField release];
   50.21  #endif
   50.22  	[super dealloc];
   50.23 @@ -64,7 +65,7 @@
   50.24  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   50.25  
   50.26  	NSEnumerator *enumerator = [touches objectEnumerator];
   50.27 -	UITouch *touch =(UITouch*)[enumerator nextObject];
   50.28 +	UITouch *touch = (UITouch*)[enumerator nextObject];
   50.29  	
   50.30  #if FIXME_MULTITOUCH
   50.31  	/* associate touches with mice, so long as we have slots */
   50.32 @@ -101,12 +102,21 @@
   50.33  		/* re-calibrate relative mouse motion */
   50.34  		SDL_GetRelativeMouseState(i, NULL, NULL);
   50.35  		
   50.36 -		/* grab next touch */
   50.37 -		touch = (UITouch*)[enumerator nextObject]; 
   50.38 -		
   50.39  		/* switch back to our old mouse */
   50.40  		SDL_SelectMouse(oldMouse);
   50.41  		
   50.42 +		/* grab next touch */
   50.43 +		touch = (UITouch*)[enumerator nextObject]; 
   50.44 +	}
   50.45 +#else
   50.46 +	if (touch) {
   50.47 +		CGPoint locationInView = [touch locationInView: self];
   50.48 +			
   50.49 +		/* send moved event */
   50.50 +		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   50.51 +
   50.52 +		/* send mouse down event */
   50.53 +		SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
   50.54  	}
   50.55  #endif
   50.56  }
   50.57 @@ -114,10 +124,10 @@
   50.58  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   50.59  	
   50.60  	NSEnumerator *enumerator = [touches objectEnumerator];
   50.61 -	UITouch *touch=nil;
   50.62 +	UITouch *touch = (UITouch*)[enumerator nextObject];
   50.63  	
   50.64  #if FIXME_MULTITOUCH
   50.65 -	while(touch = (UITouch *)[enumerator nextObject]) {
   50.66 +	while(touch) {
   50.67  		/* search for the mouse slot associated with this touch */
   50.68  		int i, found = NO;
   50.69  		for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
   50.70 @@ -131,6 +141,14 @@
   50.71  				found = YES;
   50.72  			}
   50.73  		}
   50.74 +		
   50.75 +		/* grab next touch */
   50.76 +		touch = (UITouch*)[enumerator nextObject]; 
   50.77 +	}
   50.78 +#else
   50.79 +	if (touch) {
   50.80 +		/* send mouse up */
   50.81 +		SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
   50.82  	}
   50.83  #endif
   50.84  }
   50.85 @@ -147,10 +165,10 @@
   50.86  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
   50.87  	
   50.88  	NSEnumerator *enumerator = [touches objectEnumerator];
   50.89 -	UITouch *touch=nil;
   50.90 +	UITouch *touch = (UITouch*)[enumerator nextObject];
   50.91  	
   50.92  #if FIXME_MULTITOUCH
   50.93 -	while(touch = (UITouch *)[enumerator nextObject]) {
   50.94 +	while(touch) {
   50.95  		/* try to find the mouse associated with this touch */
   50.96  		int i, found = NO;
   50.97  		for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
   50.98 @@ -163,6 +181,16 @@
   50.99  				found = YES;
  50.100  			}
  50.101  		}
  50.102 +		
  50.103 +		/* grab next touch */
  50.104 +		touch = (UITouch*)[enumerator nextObject]; 
  50.105 +	}
  50.106 +#else
  50.107 +	if (touch) {
  50.108 +		CGPoint locationInView = [touch locationInView: self];
  50.109 +
  50.110 +		/* send moved event */
  50.111 +		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
  50.112  	}
  50.113  #endif
  50.114  }
  50.115 @@ -198,15 +226,6 @@
  50.116  	keyboardVisible = NO;
  50.117  	/* add the UITextField (hidden) to our view */
  50.118  	[self addSubview: textField];
  50.119 -	
  50.120 -	/* create our SDL_Keyboard */
  50.121 -	SDL_Keyboard keyboard;
  50.122 -	SDL_zero(keyboard);
  50.123 -	SDL_AddKeyboard(&keyboard, 0);
  50.124 -	SDLKey keymap[SDL_NUM_SCANCODES];
  50.125 -	SDL_GetDefaultKeymap(keymap);
  50.126 -	SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
  50.127 -	
  50.128  }
  50.129  
  50.130  /* reveal onscreen virtual keyboard */
  50.131 @@ -226,8 +245,8 @@
  50.132  	
  50.133  	if ([string length] == 0) {
  50.134  		/* it wants to replace text with nothing, ie a delete */
  50.135 -		SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
  50.136 -		SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
  50.137 +		SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
  50.138 +		SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
  50.139  	}
  50.140  	else {
  50.141  		/* go through all the characters in the string we've been sent
  50.142 @@ -253,14 +272,14 @@
  50.143  			
  50.144  			if (mod & KMOD_SHIFT) {
  50.145  				/* If character uses shift, press shift down */
  50.146 -				SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
  50.147 +				SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
  50.148  			}
  50.149  			/* send a keydown and keyup even for the character */
  50.150 -			SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
  50.151 -			SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
  50.152 +			SDL_SendKeyboardKey(SDL_PRESSED, code);
  50.153 +			SDL_SendKeyboardKey(SDL_RELEASED, code);
  50.154  			if (mod & KMOD_SHIFT) {
  50.155  				/* If character uses shift, press shift back up */
  50.156 -				SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
  50.157 +				SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
  50.158  			}			
  50.159  		}
  50.160  	}
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/src/video/win32/SDL_win32clipboard.c	Sun Jul 18 13:48:23 2010 -0400
    51.3 @@ -0,0 +1,161 @@
    51.4 +/*
    51.5 +    SDL - Simple DirectMedia Layer
    51.6 +    Copyright (C) 1997-2010 Sam Lantinga
    51.7 +
    51.8 +    This library is free software; you can redistribute it and/or
    51.9 +    modify it under the terms of the GNU Lesser General Public
   51.10 +    License as published by the Free Software Foundation; either
   51.11 +    version 2.1 of the License, or (at your option) any later version.
   51.12 +
   51.13 +    This library is distributed in the hope that it will be useful,
   51.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   51.16 +    Lesser General Public License for more details.
   51.17 +
   51.18 +    You should have received a copy of the GNU Lesser General Public
   51.19 +    License along with this library; if not, write to the Free Software
   51.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   51.21 +
   51.22 +    Sam Lantinga
   51.23 +    slouken@libsdl.org
   51.24 +*/
   51.25 +#include "SDL_config.h"
   51.26 +
   51.27 +#include "SDL_win32video.h"
   51.28 +#include "SDL_win32window.h"
   51.29 +#include "../../events/SDL_clipboardevents_c.h"
   51.30 +
   51.31 +
   51.32 +#ifdef UNICODE
   51.33 +#define TEXT_FORMAT  CF_UNICODETEXT
   51.34 +#else
   51.35 +#define TEXT_FORMAT  CF_TEXT
   51.36 +#endif
   51.37 +
   51.38 +
   51.39 +/* Get any application owned window handle for clipboard association */
   51.40 +static HWND
   51.41 +GetWindowHandle(_THIS)
   51.42 +{
   51.43 +    SDL_VideoDisplay *display;
   51.44 +    SDL_Window *window;
   51.45 +
   51.46 +    display = _this->displays;
   51.47 +    if (display) {
   51.48 +        window = display->windows;
   51.49 +        if (window) {
   51.50 +            return ((SDL_WindowData *) window->driverdata)->hwnd;
   51.51 +        }
   51.52 +    }
   51.53 +    return NULL;
   51.54 +}
   51.55 +
   51.56 +int
   51.57 +WIN_SetClipboardText(_THIS, const char *text)
   51.58 +{
   51.59 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   51.60 +    int result = 0;
   51.61 +
   51.62 +    if (OpenClipboard(GetWindowHandle(_this))) {
   51.63 +        HANDLE hMem;
   51.64 +        LPTSTR tstr;
   51.65 +        SIZE_T i, size;
   51.66 +
   51.67 +        /* Convert the text from UTF-8 to Windows Unicode */
   51.68 +        tstr = WIN_UTF8ToString(text);
   51.69 +        if (!tstr) {
   51.70 +            return -1;
   51.71 +        }
   51.72 +
   51.73 +        /* Find out the size of the data */
   51.74 +        for (size = 0, i = 0; tstr[i]; ++i, ++size) {
   51.75 +            if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
   51.76 +                /* We're going to insert a carriage return */
   51.77 +                ++size;
   51.78 +            }
   51.79 +        }
   51.80 +        size = (size+1)*sizeof(*tstr);
   51.81 +
   51.82 +        /* Save the data to the clipboard */
   51.83 +        hMem = GlobalAlloc(GMEM_MOVEABLE, size);
   51.84 +        if (hMem) {
   51.85 +            LPTSTR dst = (LPTSTR)GlobalLock(hMem);
   51.86 +            /* Copy the text over, adding carriage returns as necessary */
   51.87 +            for (i = 0; tstr[i]; ++i) {
   51.88 +                if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
   51.89 +                    *dst++ = '\r';
   51.90 +                }
   51.91 +                *dst++ = tstr[i];
   51.92 +            }
   51.93 +            *dst = 0;
   51.94 +            GlobalUnlock(hMem);
   51.95 +
   51.96 +            EmptyClipboard();
   51.97 +            if (!SetClipboardData(TEXT_FORMAT, hMem)) {
   51.98 +                WIN_SetError("Couldn't set clipboard data");
   51.99 +                result = -1;
  51.100 +            }
  51.101 +            data->clipboard_count = GetClipboardSequenceNumber();
  51.102 +        }
  51.103 +        SDL_free(tstr);
  51.104 +
  51.105 +        CloseClipboard();
  51.106 +    } else {
  51.107 +        WIN_SetError("Couldn't open clipboard");
  51.108 +        result = -1;
  51.109 +    }
  51.110 +    return result;
  51.111 +}
  51.112 +
  51.113 +char *
  51.114 +WIN_GetClipboardText(_THIS)
  51.115 +{
  51.116 +    char *text;
  51.117 +
  51.118 +    text = NULL;
  51.119 +    if (IsClipboardFormatAvailable(TEXT_FORMAT) &&
  51.120 +        OpenClipboard(GetWindowHandle(_this))) {
  51.121 +        HANDLE hMem;
  51.122 +        LPTSTR tstr;
  51.123 +
  51.124 +        hMem = GetClipboardData(TEXT_FORMAT);
  51.125 +        if (hMem) {
  51.126 +            tstr = (LPTSTR)GlobalLock(hMem);
  51.127 +            text = WIN_StringToUTF8(tstr);
  51.128 +            GlobalUnlock(hMem);
  51.129 +        } else {
  51.130 +            WIN_SetError("Couldn't get clipboard data");
  51.131 +        }
  51.132 +        CloseClipboard();
  51.133 +    }
  51.134 +    if (!text) {
  51.135 +        text = SDL_strdup("");
  51.136 +    }
  51.137 +    return text;
  51.138 +}
  51.139 +
  51.140 +SDL_bool
  51.141 +WIN_HasClipboardText(_THIS)
  51.142 +{
  51.143 +    if (IsClipboardFormatAvailable(TEXT_FORMAT)) {
  51.144 +        return SDL_TRUE;
  51.145 +    } else {
  51.146 +        return SDL_FALSE;
  51.147 +    }
  51.148 +}
  51.149 +
  51.150 +void
  51.151 +WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
  51.152 +{
  51.153 +    DWORD count;
  51.154 +
  51.155 +    count = GetClipboardSequenceNumber();
  51.156 +    if (count != data->clipboard_count) {
  51.157 +        if (data->clipboard_count) {
  51.158 +            SDL_SendClipboardUpdate();
  51.159 +        }
  51.160 +        data->clipboard_count = count;
  51.161 +    }
  51.162 +}
  51.163 +
  51.164 +/* vi: set ts=4 sw=4 expandtab: */
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/src/video/win32/SDL_win32clipboard.h	Sun Jul 18 13:48:23 2010 -0400
    52.3 @@ -0,0 +1,37 @@
    52.4 +/*
    52.5 +    SDL - Simple DirectMedia Layer
    52.6 +    Copyright (C) 1997-2010 Sam Lantinga
    52.7 +
    52.8 +    This library is free software; you can redistribute it and/or
    52.9 +    modify it under the terms of the GNU Lesser General Public
   52.10 +    License as published by the Free Software Foundation; either
   52.11 +    version 2.1 of the License, or (at your option) any later version.
   52.12 +
   52.13 +    This library is distributed in the hope that it will be useful,
   52.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   52.16 +    Lesser General Public License for more details.
   52.17 +
   52.18 +    You should have received a copy of the GNU Lesser General Public
   52.19 +    License along with this library; if not, write to the Free Software
   52.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   52.21 +
   52.22 +    Sam Lantinga
   52.23 +    slouken@libsdl.org
   52.24 +*/
   52.25 +#include "SDL_config.h"
   52.26 +
   52.27 +#ifndef _SDL_win32clipboard_h
   52.28 +#define _SDL_win32clipboard_h
   52.29 +
   52.30 +/* Forward declaration */
   52.31 +struct SDL_VideoData;
   52.32 +
   52.33 +extern int WIN_SetClipboardText(_THIS, const char *text);
   52.34 +extern char *WIN_GetClipboardText(_THIS);
   52.35 +extern SDL_bool WIN_HasClipboardText(_THIS);
   52.36 +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data);
   52.37 +
   52.38 +#endif /* _SDL_win32clipboard_h */
   52.39 +
   52.40 +/* vi: set ts=4 sw=4 expandtab: */
    53.1 --- a/src/video/win32/SDL_win32events.c	Tue Jul 13 15:05:45 2010 -0400
    53.2 +++ b/src/video/win32/SDL_win32events.c	Sun Jul 18 13:48:23 2010 -0400
    53.3 @@ -164,7 +164,10 @@
    53.4                  if (SDL_GetKeyboardFocus() != data->window) {
    53.5                      SDL_SetKeyboardFocus(data->window);
    53.6                  }
    53.7 -                /* FIXME: Update keyboard state */
    53.8 +                /*
    53.9 +                 * FIXME: Update keyboard state
   53.10 +                 */
   53.11 +                WIN_CheckClipboardUpdate(data->videodata);
   53.12              } else {
   53.13                  if (SDL_GetKeyboardFocus() == data->window) {
   53.14                      SDL_SetKeyboardFocus(NULL);
   53.15 @@ -587,17 +590,4 @@
   53.16      }
   53.17  }
   53.18  
   53.19 -/* Sets an error message based on GetLastError() */
   53.20 -void
   53.21 -WIN_SetError(const char *prefix)
   53.22 -{
   53.23 -    TCHAR buffer[1024];
   53.24 -    char *message;
   53.25 -    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
   53.26 -                  buffer, SDL_arraysize(buffer), NULL);
   53.27 -    message = WIN_StringToUTF8(buffer);
   53.28 -    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
   53.29 -    SDL_free(message);
   53.30 -}
   53.31 -
   53.32  /* vi: set ts=4 sw=4 expandtab: */
    54.1 --- a/src/video/win32/SDL_win32events.h	Tue Jul 13 15:05:45 2010 -0400
    54.2 +++ b/src/video/win32/SDL_win32events.h	Sun Jul 18 13:48:23 2010 -0400
    54.3 @@ -31,7 +31,6 @@
    54.4  extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
    54.5                                         LPARAM lParam);
    54.6  extern void WIN_PumpEvents(_THIS);
    54.7 -extern void WIN_SetError(const char *prefix);
    54.8  
    54.9  #endif /* _SDL_win32events_h */
   54.10  
    55.1 --- a/src/video/win32/SDL_win32video.c	Tue Jul 13 15:05:45 2010 -0400
    55.2 +++ b/src/video/win32/SDL_win32video.c	Sun Jul 18 13:48:23 2010 -0400
    55.3 @@ -1,213 +1,230 @@
    55.4 -/*
    55.5 -    SDL - Simple DirectMedia Layer
    55.6 -    Copyright (C) 1997-2010 Sam Lantinga
    55.7 -
    55.8 -    This library is free software; you can redistribute it and/or
    55.9 -    modify it under the terms of the GNU Lesser General Public
   55.10 -    License as published by the Free Software Foundation; either
   55.11 -    version 2.1 of the License, or (at your option) any later version.
   55.12 -
   55.13 -    This library is distributed in the hope that it will be useful,
   55.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   55.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   55.16 -    Lesser General Public License for more details.
   55.17 -
   55.18 -    You should have received a copy of the GNU Lesser General Public
   55.19 -    License along with this library; if not, write to the Free Software
   55.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   55.21 -
   55.22 -    Sam Lantinga
   55.23 -    slouken@libsdl.org
   55.24 -*/
   55.25 -#include "SDL_config.h"
   55.26 -
   55.27 -#include "SDL_main.h"
   55.28 -#include "SDL_video.h"
   55.29 -#include "SDL_mouse.h"
   55.30 -#include "../SDL_sysvideo.h"
   55.31 -#include "../SDL_pixels_c.h"
   55.32 -
   55.33 -#include "SDL_win32video.h"
   55.34 -#include "SDL_d3drender.h"
   55.35 -#include "SDL_gdirender.h"
   55.36 -
   55.37 -/* Initialization/Query functions */
   55.38 -static int WIN_VideoInit(_THIS);
   55.39 -static void WIN_VideoQuit(_THIS);
   55.40 -
   55.41 -/* WIN32 driver bootstrap functions */
   55.42 -
   55.43 -static int
   55.44 -WIN_Available(void)
   55.45 -{
   55.46 -    return (1);
   55.47 -}
   55.48 -
   55.49 -static void
   55.50 -WIN_DeleteDevice(SDL_VideoDevice * device)
   55.51 -{
   55.52 -    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
   55.53 -
   55.54 -    SDL_UnregisterApp();
   55.55 -#if SDL_VIDEO_RENDER_D3D
   55.56 -    if (data->d3d) {
   55.57 -        IDirect3D9_Release(data->d3d);
   55.58 -        FreeLibrary(data->d3dDLL);
   55.59 -    }
   55.60 -#endif
   55.61 -#if SDL_VIDEO_RENDER_DDRAW
   55.62 -    if (data->ddraw) {
   55.63 -        data->ddraw->lpVtbl->Release(data->ddraw);
   55.64 -        FreeLibrary(data->ddrawDLL);
   55.65 -    }
   55.66 -#endif
   55.67 -    SDL_free(device->driverdata);
   55.68 -    SDL_free(device);
   55.69 -}
   55.70 -
   55.71 -static SDL_VideoDevice *
   55.72 -WIN_CreateDevice(int devindex)
   55.73 -{
   55.74 -    SDL_VideoDevice *device;
   55.75 -    SDL_VideoData *data;
   55.76 -
   55.77 -    SDL_RegisterApp(NULL, 0, NULL);
   55.78 -
   55.79 -    /* Initialize all variables that we clean on shutdown */
   55.80 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   55.81 -    if (device) {
   55.82 -        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   55.83 -    } else {
   55.84 -        data = NULL;
   55.85 -    }
   55.86 -    if (!data) {
   55.87 -        SDL_OutOfMemory();
   55.88 -        if (device) {
   55.89 -            SDL_free(device);
   55.90 -        }
   55.91 -        return NULL;
   55.92 -    }
   55.93 -    device->driverdata = data;
   55.94 -
   55.95 -#if SDL_VIDEO_RENDER_D3D
   55.96 -    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
   55.97 -    if (data->d3dDLL) {
   55.98 -        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
   55.99 -
  55.100 -        D3DCreate =
  55.101 -            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
  55.102 -                                                            "Direct3DCreate9");
  55.103 -        if (D3DCreate) {
  55.104 -            data->d3d = D3DCreate(D3D_SDK_VERSION);
  55.105 -        }
  55.106 -        if (!data->d3d) {
  55.107 -            FreeLibrary(data->d3dDLL);
  55.108 -            data->d3dDLL = NULL;
  55.109 -        }
  55.110 -    }
  55.111 -#endif /* SDL_VIDEO_RENDER_D3D */
  55.112 -#if SDL_VIDEO_RENDER_DDRAW
  55.113 -    data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
  55.114 -    if (data->ddrawDLL) {
  55.115 -        IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
  55.116 -                                          LPDIRECTDRAW FAR * lplpDD,
  55.117 -                                          IUnknown FAR * pUnkOuter);
  55.118 -
  55.119 -        DDCreate =
  55.120 -            (IDirectDraw *
  55.121 -             (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
  55.122 -            GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
  55.123 -        if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
  55.124 -            FreeLibrary(data->ddrawDLL);
  55.125 -            data->ddrawDLL = NULL;
  55.126 -            data->ddraw = NULL;
  55.127 -        }
  55.128 -    }
  55.129 -#endif /* SDL_VIDEO_RENDER_DDRAW */
  55.130 -
  55.131 -    /* Set the function pointers */
  55.132 -    device->VideoInit = WIN_VideoInit;
  55.133 -    device->VideoQuit = WIN_VideoQuit;
  55.134 -    device->GetDisplayBounds = WIN_GetDisplayBounds;
  55.135 -    device->GetDisplayModes = WIN_GetDisplayModes;
  55.136 -    device->SetDisplayMode = WIN_SetDisplayMode;
  55.137 -    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
  55.138 -    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
  55.139 -    device->PumpEvents = WIN_PumpEvents;
  55.140 -
  55.141 -#undef CreateWindow
  55.142 -    device->CreateWindow = WIN_CreateWindow;
  55.143 -    device->CreateWindowFrom = WIN_CreateWindowFrom;
  55.144 -    device->SetWindowTitle = WIN_SetWindowTitle;
  55.145 -    device->SetWindowIcon = WIN_SetWindowIcon;
  55.146 -    device->SetWindowPosition = WIN_SetWindowPosition;
  55.147 -    device->SetWindowSize = WIN_SetWindowSize;
  55.148 -    device->ShowWindow = WIN_ShowWindow;
  55.149 -    device->HideWindow = WIN_HideWindow;
  55.150 -    device->RaiseWindow = WIN_RaiseWindow;
  55.151 -    device->MaximizeWindow = WIN_MaximizeWindow;
  55.152 -    device->MinimizeWindow = WIN_MinimizeWindow;
  55.153 -    device->RestoreWindow = WIN_RestoreWindow;
  55.154 -    device->SetWindowGrab = WIN_SetWindowGrab;
  55.155 -    device->DestroyWindow = WIN_DestroyWindow;
  55.156 -    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
  55.157 -#ifdef SDL_VIDEO_OPENGL_WGL
  55.158 -    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
  55.159 -    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
  55.160 -    device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
  55.161 -    device->GL_CreateContext = WIN_GL_CreateContext;
  55.162 -    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
  55.163 -    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
  55.164 -    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
  55.165 -    device->GL_SwapWindow = WIN_GL_SwapWindow;
  55.166 -    device->GL_DeleteContext = WIN_GL_DeleteContext;
  55.167 -#endif
  55.168 -    device->StartTextInput = WIN_StartTextInput;
  55.169 -    device->StopTextInput = WIN_StopTextInput;
  55.170 -    device->SetTextInputRect = WIN_SetTextInputRect;
  55.171 -
  55.172 -    device->free = WIN_DeleteDevice;
  55.173 -
  55.174 -    return device;
  55.175 -}
  55.176 -
  55.177 -VideoBootStrap WIN32_bootstrap = {
  55.178 -    "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
  55.179 -};
  55.180 -
  55.181 -
  55.182 -int
  55.183 -WIN_VideoInit(_THIS)
  55.184 -{
  55.185 -    if (WIN_InitModes(_this) < 0) {
  55.186 -        return -1;
  55.187 -    }
  55.188 -
  55.189 -#if SDL_VIDEO_RENDER_D3D
  55.190 -    D3D_AddRenderDriver(_this);
  55.191 -#endif
  55.192 -#if SDL_VIDEO_RENDER_DDRAW
  55.193 -    DDRAW_AddRenderDriver(_this);
  55.194 -#endif
  55.195 -#if SDL_VIDEO_RENDER_GDI
  55.196 -    GDI_AddRenderDriver(_this);
  55.197 -#endif
  55.198 -#if SDL_VIDEO_RENDER_GAPI
  55.199 -    GAPI_AddRenderDriver(_this);
  55.200 -#endif
  55.201 -
  55.202 -    WIN_InitKeyboard(_this);
  55.203 -    WIN_InitMouse(_this);
  55.204 -
  55.205 -    return 0;
  55.206 -}
  55.207 -
  55.208 -void
  55.209 -WIN_VideoQuit(_THIS)
  55.210 -{
  55.211 -    WIN_QuitModes(_this);
  55.212 -    WIN_QuitKeyboard(_this);
  55.213 -    WIN_QuitMouse(_this);
  55.214 -}
  55.215 -
  55.216 -/* vim: set ts=4 sw=4 expandtab: */
  55.217 +/*
  55.218 +    SDL - Simple DirectMedia Layer
  55.219 +    Copyright (C) 1997-2010 Sam Lantinga
  55.220 +
  55.221 +    This library is free software; you can redistribute it and/or
  55.222 +    modify it under the terms of the GNU Lesser General Public
  55.223 +    License as published by the Free Software Foundation; either
  55.224 +    version 2.1 of the License, or (at your option) any later version.
  55.225 +
  55.226 +    This library is distributed in the hope that it will be useful,
  55.227 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
  55.228 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  55.229 +    Lesser General Public License for more details.
  55.230 +
  55.231 +    You should have received a copy of the GNU Lesser General Public
  55.232 +    License along with this library; if not, write to the Free Software
  55.233 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  55.234 +
  55.235 +    Sam Lantinga
  55.236 +    slouken@libsdl.org
  55.237 +*/
  55.238 +#include "SDL_config.h"
  55.239 +
  55.240 +#include "SDL_main.h"
  55.241 +#include "SDL_video.h"
  55.242 +#include "SDL_mouse.h"
  55.243 +#include "../SDL_sysvideo.h"
  55.244 +#include "../SDL_pixels_c.h"
  55.245 +
  55.246 +#include "SDL_win32video.h"
  55.247 +#include "SDL_d3drender.h"
  55.248 +#include "SDL_gdirender.h"
  55.249 +
  55.250 +/* Initialization/Query functions */
  55.251 +static int WIN_VideoInit(_THIS);
  55.252 +static void WIN_VideoQuit(_THIS);
  55.253 +
  55.254 +/* Sets an error message based on GetLastError() */
  55.255 +void
  55.256 +WIN_SetError(const char *prefix)
  55.257 +{
  55.258 +    TCHAR buffer[1024];
  55.259 +    char *message;
  55.260 +    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
  55.261 +                  buffer, SDL_arraysize(buffer), NULL);
  55.262 +    message = WIN_StringToUTF8(buffer);
  55.263 +    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
  55.264 +    SDL_free(message);
  55.265 +}
  55.266 +
  55.267 +/* WIN32 driver bootstrap functions */
  55.268 +
  55.269 +static int
  55.270 +WIN_Available(void)
  55.271 +{
  55.272 +    return (1);
  55.273 +}
  55.274 +
  55.275 +static void
  55.276 +WIN_DeleteDevice(SDL_VideoDevice * device)
  55.277 +{
  55.278 +    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
  55.279 +
  55.280 +    SDL_UnregisterApp();
  55.281 +#if SDL_VIDEO_RENDER_D3D
  55.282 +    if (data->d3d) {
  55.283 +        IDirect3D9_Release(data->d3d);
  55.284 +        FreeLibrary(data->d3dDLL);
  55.285 +    }
  55.286 +#endif
  55.287 +#if SDL_VIDEO_RENDER_DDRAW
  55.288 +    if (data->ddraw) {
  55.289 +        data->ddraw->lpVtbl->Release(data->ddraw);
  55.290 +        FreeLibrary(data->ddrawDLL);
  55.291 +    }
  55.292 +#endif
  55.293 +    SDL_free(device->driverdata);
  55.294 +    SDL_free(device);
  55.295 +}
  55.296 +
  55.297 +static SDL_VideoDevice *
  55.298 +WIN_CreateDevice(int devindex)
  55.299 +{
  55.300 +    SDL_VideoDevice *device;
  55.301 +    SDL_VideoData *data;
  55.302 +
  55.303 +    SDL_RegisterApp(NULL, 0, NULL);
  55.304 +
  55.305 +    /* Initialize all variables that we clean on shutdown */
  55.306 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
  55.307 +    if (device) {
  55.308 +        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
  55.309 +    } else {
  55.310 +        data = NULL;
  55.311 +    }
  55.312 +    if (!data) {
  55.313 +        SDL_OutOfMemory();
  55.314 +        if (device) {
  55.315 +            SDL_free(device);
  55.316 +        }
  55.317 +        return NULL;
  55.318 +    }
  55.319 +    device->driverdata = data;
  55.320 +
  55.321 +#if SDL_VIDEO_RENDER_D3D
  55.322 +    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
  55.323 +    if (data->d3dDLL) {
  55.324 +        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
  55.325 +
  55.326 +        D3DCreate =
  55.327 +            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
  55.328 +                                                            "Direct3DCreate9");
  55.329 +        if (D3DCreate) {
  55.330 +            data->d3d = D3DCreate(D3D_SDK_VERSION);
  55.331 +        }
  55.332 +        if (!data->d3d) {
  55.333 +            FreeLibrary(data->d3dDLL);
  55.334 +            data->d3dDLL = NULL;
  55.335 +        }
  55.336 +    }
  55.337 +#endif /* SDL_VIDEO_RENDER_D3D */
  55.338 +#if SDL_VIDEO_RENDER_DDRAW
  55.339 +    data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
  55.340 +    if (data->ddrawDLL) {
  55.341 +        IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
  55.342 +                                          LPDIRECTDRAW FAR * lplpDD,
  55.343 +                                          IUnknown FAR * pUnkOuter);
  55.344 +
  55.345 +        DDCreate =
  55.346 +            (IDirectDraw *
  55.347 +             (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
  55.348 +            GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
  55.349 +        if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
  55.350 +            FreeLibrary(data->ddrawDLL);
  55.351 +            data->ddrawDLL = NULL;
  55.352 +            data->ddraw = NULL;
  55.353 +        }
  55.354 +    }
  55.355 +#endif /* SDL_VIDEO_RENDER_DDRAW */
  55.356 +
  55.357 +    /* Set the function pointers */
  55.358 +    device->VideoInit = WIN_VideoInit;
  55.359 +    device->VideoQuit = WIN_VideoQuit;
  55.360 +    device->GetDisplayBounds = WIN_GetDisplayBounds;
  55.361 +    device->GetDisplayModes = WIN_GetDisplayModes;
  55.362 +    device->SetDisplayMode = WIN_SetDisplayMode;
  55.363 +    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
  55.364 +    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
  55.365 +    device->PumpEvents = WIN_PumpEvents;
  55.366 +
  55.367 +#undef CreateWindow
  55.368 +    device->CreateWindow = WIN_CreateWindow;
  55.369 +    device->CreateWindowFrom = WIN_CreateWindowFrom;
  55.370 +    device->SetWindowTitle = WIN_SetWindowTitle;
  55.371 +    device->SetWindowIcon = WIN_SetWindowIcon;
  55.372 +    device->SetWindowPosition = WIN_SetWindowPosition;
  55.373 +    device->SetWindowSize = WIN_SetWindowSize;
  55.374 +    device->ShowWindow = WIN_ShowWindow;
  55.375 +    device->HideWindow = WIN_HideWindow;
  55.376 +    device->RaiseWindow = WIN_RaiseWindow;
  55.377 +    device->MaximizeWindow = WIN_MaximizeWindow;
  55.378 +    device->MinimizeWindow = WIN_MinimizeWindow;
  55.379 +    device->RestoreWindow = WIN_RestoreWindow;
  55.380 +    device->SetWindowGrab = WIN_SetWindowGrab;
  55.381 +    device->DestroyWindow = WIN_DestroyWindow;
  55.382 +    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
  55.383 +#ifdef SDL_VIDEO_OPENGL_WGL
  55.384 +    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
  55.385 +    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
  55.386 +    device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
  55.387 +    device->GL_CreateContext = WIN_GL_CreateContext;
  55.388 +    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
  55.389 +    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
  55.390 +    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
  55.391 +    device->GL_SwapWindow = WIN_GL_SwapWindow;
  55.392 +    device->GL_DeleteContext = WIN_GL_DeleteContext;
  55.393 +#endif
  55.394 +    device->StartTextInput = WIN_StartTextInput;
  55.395 +    device->StopTextInput = WIN_StopTextInput;
  55.396 +    device->SetTextInputRect = WIN_SetTextInputRect;
  55.397 +
  55.398 +    device->SetClipboardText = WIN_SetClipboardText;
  55.399 +    device->GetClipboardText = WIN_GetClipboardText;
  55.400 +    device->HasClipboardText = WIN_HasClipboardText;
  55.401 +
  55.402 +    device->free = WIN_DeleteDevice;
  55.403 +
  55.404 +    return device;
  55.405 +}
  55.406 +
  55.407 +VideoBootStrap WIN32_bootstrap = {
  55.408 +    "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
  55.409 +};
  55.410 +
  55.411 +
  55.412 +int
  55.413 +WIN_VideoInit(_THIS)
  55.414 +{
  55.415 +    if (WIN_InitModes(_this) < 0) {
  55.416 +        return -1;
  55.417 +    }
  55.418 +
  55.419 +#if SDL_VIDEO_RENDER_D3D
  55.420 +    D3D_AddRenderDriver(_this);
  55.421 +#endif
  55.422 +#if SDL_VIDEO_RENDER_DDRAW
  55.423 +    DDRAW_AddRenderDriver(_this);
  55.424 +#endif
  55.425 +#if SDL_VIDEO_RENDER_GDI
  55.426 +    GDI_AddRenderDriver(_this);
  55.427 +#endif
  55.428 +#if SDL_VIDEO_RENDER_GAPI
  55.429 +    GAPI_AddRenderDriver(_this);
  55.430 +#endif
  55.431 +
  55.432 +    WIN_InitKeyboard(_this);
  55.433 +    WIN_InitMouse(_this);
  55.434 +
  55.435 +    return 0;
  55.436 +}
  55.437 +
  55.438 +void
  55.439 +WIN_VideoQuit(_THIS)
  55.440 +{
  55.441 +    WIN_QuitModes(_this);
  55.442 +    WIN_QuitKeyboard(_this);
  55.443 +    WIN_QuitMouse(_this);
  55.444 +}
  55.445 +
  55.446 +/* vim: set ts=4 sw=4 expandtab: */
    56.1 --- a/src/video/win32/SDL_win32video.h	Tue Jul 13 15:05:45 2010 -0400
    56.2 +++ b/src/video/win32/SDL_win32video.h	Sun Jul 18 13:48:23 2010 -0400
    56.3 @@ -1,92 +1,95 @@
    56.4 -/*
    56.5 -    SDL - Simple DirectMedia Layer
    56.6 -    Copyright (C) 1997-2010 Sam Lantinga
    56.7 -
    56.8 -    This library is free software; you can redistribute it and/or
    56.9 -    modify it under the terms of the GNU Lesser General Public
   56.10 -    License as published by the Free Software Foundation; either
   56.11 -    version 2.1 of the License, or (at your option) any later version.
   56.12 -
   56.13 -    This library is distributed in the hope that it will be useful,
   56.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   56.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   56.16 -    Lesser General Public License for more details.
   56.17 -
   56.18 -    You should have received a copy of the GNU Lesser General Public
   56.19 -    License along with this library; if not, write to the Free Software
   56.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   56.21 -
   56.22 -    Sam Lantinga
   56.23 -    slouken@libsdl.org
   56.24 -*/
   56.25 -#include "SDL_config.h"
   56.26 -
   56.27 -#ifndef _SDL_win32video_h
   56.28 -#define _SDL_win32video_h
   56.29 -
   56.30 -#include "../SDL_sysvideo.h"
   56.31 -
   56.32 -#define WIN32_LEAN_AND_MEAN
   56.33 -#define STRICT
   56.34 -#define UNICODE
   56.35 -#undef WINVER
   56.36 -#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
   56.37 -#include <windows.h>
   56.38 -
   56.39 -#if SDL_VIDEO_RENDER_D3D
   56.40 -//#include <d3d9.h>
   56.41 -#define D3D_DEBUG_INFO
   56.42 -#include "d3d9.h"
   56.43 -#endif
   56.44 -
   56.45 -#if SDL_VIDEO_RENDER_DDRAW
   56.46 -/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
   56.47 -#include <objbase.h>
   56.48 -#include "ddraw.h"
   56.49 -#endif
   56.50 -
   56.51 -#include "SDL_win32events.h"
   56.52 -#include "SDL_win32gamma.h"
   56.53 -#include "SDL_win32keyboard.h"
   56.54 -#include "SDL_win32modes.h"
   56.55 -#include "SDL_win32mouse.h"
   56.56 -#include "SDL_win32opengl.h"
   56.57 -#include "SDL_win32window.h"
   56.58 -
   56.59 -#ifdef UNICODE
   56.60 -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
   56.61 -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
   56.62 -#else
   56.63 -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
   56.64 -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
   56.65 -#endif
   56.66 -
   56.67 -/* Private display data */
   56.68 -
   56.69 -typedef struct SDL_VideoData
   56.70 -{
   56.71 -#if SDL_VIDEO_RENDER_D3D
   56.72 -    HANDLE d3dDLL;
   56.73 -    IDirect3D9 *d3d;
   56.74 -#endif
   56.75 -#if SDL_VIDEO_RENDER_DDRAW
   56.76 -    HANDLE ddrawDLL;
   56.77 -    IDirectDraw *ddraw;
   56.78 -#endif
   56.79 -
   56.80 -    const SDL_scancode *key_layout;
   56.81 -    
   56.82 -    SDL_bool ime_com_initialized;
   56.83 -    struct ITfThreadMgr *ime_thread_mgr;
   56.84 -    SDL_bool ime_initialized;
   56.85 -    SDL_bool ime_enabled;
   56.86 -    SDL_bool ime_available;
   56.87 -    HWND ime_hwnd_main;
   56.88 -    HWND ime_hwnd_current;
   56.89 -    HIMC ime_himc;
   56.90 -
   56.91 -} SDL_VideoData;
   56.92 -
   56.93 -#endif /* _SDL_win32video_h */
   56.94 -
   56.95 -/* vi: set ts=4 sw=4 expandtab: */
   56.96 +/*
   56.97 +    SDL - Simple DirectMedia Layer
   56.98 +    Copyright (C) 1997-2010 Sam Lantinga
   56.99 +
  56.100 +    This library is free software; you can redistribute it and/or
  56.101 +    modify it under the terms of the GNU Lesser General Public
  56.102 +    License as published by the Free Software Foundation; either
  56.103 +    version 2.1 of the License, or (at your option) any later version.
  56.104 +
  56.105 +    This library is distributed in the hope that it will be useful,
  56.106 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
  56.107 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  56.108 +    Lesser General Public License for more details.
  56.109 +
  56.110 +    You should have received a copy of the GNU Lesser General Public
  56.111 +    License along with this library; if not, write to the Free Software
  56.112 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  56.113 +
  56.114 +    Sam Lantinga
  56.115 +    slouken@libsdl.org
  56.116 +*/
  56.117 +#include "SDL_config.h"
  56.118 +
  56.119 +#ifndef _SDL_win32video_h
  56.120 +#define _SDL_win32video_h
  56.121 +
  56.122 +#include "../SDL_sysvideo.h"
  56.123 +
  56.124 +#define WIN32_LEAN_AND_MEAN
  56.125 +#define STRICT
  56.126 +#define UNICODE
  56.127 +#undef WINVER
  56.128 +#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
  56.129 +#include <windows.h>
  56.130 +
  56.131 +#if SDL_VIDEO_RENDER_D3D
  56.132 +//#include <d3d9.h>
  56.133 +#define D3D_DEBUG_INFO
  56.134 +#include "d3d9.h"
  56.135 +#endif
  56.136 +
  56.137 +#if SDL_VIDEO_RENDER_DDRAW
  56.138 +/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */
  56.139 +#include <objbase.h>
  56.140 +#include "ddraw.h"
  56.141 +#endif
  56.142 +
  56.143 +#include "SDL_win32clipboard.h"
  56.144 +#include "SDL_win32events.h"
  56.145 +#include "SDL_win32gamma.h"
  56.146 +#include "SDL_win32keyboard.h"
  56.147 +#include "SDL_win32modes.h"
  56.148 +#include "SDL_win32mouse.h"
  56.149 +#include "SDL_win32opengl.h"
  56.150 +#include "SDL_win32window.h"
  56.151 +
  56.152 +#ifdef UNICODE
  56.153 +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
  56.154 +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
  56.155 +#else
  56.156 +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
  56.157 +#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
  56.158 +#endif
  56.159 +extern void WIN_SetError(const char *prefix);
  56.160 +
  56.161 +/* Private display data */
  56.162 +
  56.163 +typedef struct SDL_VideoData
  56.164 +{
  56.165 +#if SDL_VIDEO_RENDER_D3D
  56.166 +    HANDLE d3dDLL;
  56.167 +    IDirect3D9 *d3d;
  56.168 +#endif
  56.169 +#if SDL_VIDEO_RENDER_DDRAW
  56.170 +    HANDLE ddrawDLL;
  56.171 +    IDirectDraw *ddraw;
  56.172 +#endif
  56.173 +
  56.174 +    const SDL_scancode *key_layout;
  56.175 +    DWORD clipboard_count;
  56.176 +
  56.177 +    SDL_bool ime_com_initialized;
  56.178 +    struct ITfThreadMgr *ime_thread_mgr;
  56.179 +    SDL_bool ime_initialized;
  56.180 +    SDL_bool ime_enabled;
  56.181 +    SDL_bool ime_available;
  56.182 +    HWND ime_hwnd_main;
  56.183 +    HWND ime_hwnd_current;
  56.184 +    HIMC ime_himc;
  56.185 +
  56.186 +} SDL_VideoData;
  56.187 +
  56.188 +#endif /* _SDL_win32video_h */
  56.189 +
  56.190 +/* vi: set ts=4 sw=4 expandtab: */
    57.1 --- a/src/video/win32/SDL_win32window.c	Tue Jul 13 15:05:45 2010 -0400
    57.2 +++ b/src/video/win32/SDL_win32window.c	Sun Jul 18 13:48:23 2010 -0400
    57.3 @@ -635,8 +635,7 @@
    57.4      /* Register the class. */
    57.5      SDL_HelperWindowClass = RegisterClass(&wce);
    57.6      if (SDL_HelperWindowClass == 0) {
    57.7 -        SDL_SetError("Unable to create Helper Window Class: error %d.",
    57.8 -                     GetLastError());
    57.9 +        WIN_SetError("Unable to create Helper Window Class");
   57.10          return -1;
   57.11      }
   57.12  
   57.13 @@ -654,8 +653,7 @@
   57.14                                        hInstance, NULL);
   57.15      if (SDL_HelperWindow == NULL) {
   57.16          UnregisterClass(SDL_HelperWindowClassName, hInstance);
   57.17 -        SDL_SetError("Unable to create Helper Window: error %d.",
   57.18 -                     GetLastError());
   57.19 +        WIN_SetError("Unable to create Helper Window");
   57.20          return -1;
   57.21      }
   57.22  
   57.23 @@ -674,8 +672,7 @@
   57.24      /* Destroy the window. */
   57.25      if (SDL_HelperWindow != NULL) {
   57.26          if (DestroyWindow(SDL_HelperWindow) == 0) {
   57.27 -            SDL_SetError("Unable to destroy Helper Window: error %d.",
   57.28 -                         GetLastError());
   57.29 +            WIN_SetError("Unable to destroy Helper Window");
   57.30              return;
   57.31          }
   57.32          SDL_HelperWindow = NULL;
   57.33 @@ -684,8 +681,7 @@
   57.34      /* Unregister the class. */
   57.35      if (SDL_HelperWindowClass != 0) {
   57.36          if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) {
   57.37 -            SDL_SetError("Unable to destroy Helper Window Class: error %d.",
   57.38 -                         GetLastError());
   57.39 +            WIN_SetError("Unable to destroy Helper Window Class");
   57.40              return;
   57.41          }
   57.42          SDL_HelperWindowClass = 0;
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/src/video/x11/SDL_x11clipboard.c	Sun Jul 18 13:48:23 2010 -0400
    58.3 @@ -0,0 +1,156 @@
    58.4 +/*
    58.5 +    SDL - Simple DirectMedia Layer
    58.6 +    Copyright (C) 1997-2010 Sam Lantinga
    58.7 +
    58.8 +    This library is free software; you can redistribute it and/or
    58.9 +    modify it under the terms of the GNU Lesser General Public
   58.10 +    License as published by the Free Software Foundation; either
   58.11 +    version 2.1 of the License, or (at your option) any later version.
   58.12 +
   58.13 +    This library is distributed in the hope that it will be useful,
   58.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   58.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   58.16 +    Lesser General Public License for more details.
   58.17 +
   58.18 +    You should have received a copy of the GNU Lesser General Public
   58.19 +    License along with this library; if not, write to the Free Software
   58.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   58.21 +
   58.22 +    Sam Lantinga
   58.23 +    slouken@libsdl.org
   58.24 +*/
   58.25 +#include "SDL_config.h"
   58.26 +
   58.27 +#include <limits.h> /* For INT_MAX */
   58.28 +
   58.29 +#include "SDL_events.h"
   58.30 +#include "SDL_x11video.h"
   58.31 +
   58.32 +
   58.33 +/* If you don't support UTF-8, you might use XA_STRING here */
   58.34 +#ifdef X_HAVE_UTF8_STRING
   58.35 +#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False)
   58.36 +#else
   58.37 +#define TEXT_FORMAT XA_STRING
   58.38 +#endif
   58.39 +
   58.40 +/* Get any application owned window handle for clipboard association */
   58.41 +static Window
   58.42 +GetWindow(_THIS)
   58.43 +{
   58.44 +    SDL_VideoDisplay *display;
   58.45 +    SDL_Window *window;
   58.46 +
   58.47 +    display = _this->displays;
   58.48 +    if (display) {
   58.49 +        window = display->windows;
   58.50 +        if (window) {
   58.51 +            return ((SDL_WindowData *) window->driverdata)->xwindow;
   58.52 +        }
   58.53 +    }
   58.54 +    return None;
   58.55 +}
   58.56 +
   58.57 +int
   58.58 +X11_SetClipboardText(_THIS, const char *text)
   58.59 +{
   58.60 +    Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   58.61 +    Atom format;
   58.62 +    Window window;
   58.63 +
   58.64 +    /* Get the SDL window that will own the selection */
   58.65 +    window = GetWindow(_this);
   58.66 +    if (window == None) {
   58.67 +        SDL_SetError("Couldn't find a window to own the selection");
   58.68 +        return -1;
   58.69 +    }
   58.70 +
   58.71 +    /* Save the selection on the root window */
   58.72 +    format = TEXT_FORMAT;
   58.73 +    XChangeProperty(display, DefaultRootWindow(display),
   58.74 +        XA_CUT_BUFFER0, format, 8, PropModeReplace,
   58.75 +        (const unsigned char *)text, SDL_strlen(text));
   58.76 +
   58.77 +    if (XGetSelectionOwner(display, XA_PRIMARY) != window) {
   58.78 +        XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
   58.79 +    }
   58.80 +    return 0;
   58.81 +}
   58.82 +
   58.83 +char *
   58.84 +X11_GetClipboardText(_THIS)
   58.85 +{
   58.86 +    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   58.87 +    Display *display = videodata->display;
   58.88 +    Atom format;
   58.89 +    Window window;
   58.90 +    Window owner;
   58.91 +    Atom selection;
   58.92 +    Atom seln_type;
   58.93 +    int seln_format;
   58.94 +    unsigned long nbytes;
   58.95 +    unsigned long overflow;
   58.96 +    unsigned char *src;
   58.97 +    char *text;
   58.98 +
   58.99 +    text = NULL;
  58.100 +
  58.101 +    /* Get the window that holds the selection */
  58.102 +    window = GetWindow(_this);
  58.103 +    format = TEXT_FORMAT;
  58.104 +    owner = XGetSelectionOwner(display, XA_PRIMARY);
  58.105 +    if ((owner == None) || (owner == window)) {
  58.106 +        owner = DefaultRootWindow(display);
  58.107 +        selection = XA_CUT_BUFFER0;
  58.108 +    } else {
  58.109 +        /* Request that the selection owner copy the data to our window */
  58.110 +        owner = window;
  58.111 +        selection = XInternAtom(display, "SDL_SELECTION", False);
  58.112 +        XConvertSelection(display, XA_PRIMARY, format, selection, owner,
  58.113 +            CurrentTime);
  58.114 +
  58.115 +        /* FIXME: Should we have a timeout here? */
  58.116 +        videodata->selection_waiting = SDL_TRUE;
  58.117 +        while (videodata->selection_waiting) {
  58.118 +            SDL_PumpEvents();
  58.119 +        }
  58.120 +    }
  58.121 +
  58.122 +    if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
  58.123 +            format, &seln_type, &seln_format, &nbytes, &overflow, &src)
  58.124 +            == Success) {
  58.125 +        if (seln_type == format) {
  58.126 +            text = (char *)SDL_malloc(nbytes+1);
  58.127 +            if (text) {
  58.128 +                SDL_memcpy(text, src, nbytes);
  58.129 +                text[nbytes] = '\0';
  58.130 +            }
  58.131 +        }
  58.132 +        XFree(src);
  58.133 +    }
  58.134 +
  58.135 +    if (!text) {
  58.136 +        text = SDL_strdup("");
  58.137 +    }
  58.138 +    return text;
  58.139 +}
  58.140 +
  58.141 +SDL_bool
  58.142 +X11_HasClipboardText(_THIS)
  58.143 +{
  58.144 +    /* Not an easy way to tell with X11, as far as I know... */
  58.145 +    char *text;
  58.146 +    SDL_bool retval;
  58.147 +
  58.148 +    text = X11_GetClipboardText(_this);
  58.149 +    if (*text) {
  58.150 +        retval = SDL_TRUE;
  58.151 +    } else {
  58.152 +        retval = SDL_FALSE;
  58.153 +    }
  58.154 +    SDL_free(text);
  58.155 +
  58.156 +    return retval;
  58.157 +}
  58.158 +
  58.159 +/* vi: set ts=4 sw=4 expandtab: */
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/src/video/x11/SDL_x11clipboard.h	Sun Jul 18 13:48:23 2010 -0400
    59.3 @@ -0,0 +1,33 @@
    59.4 +/*
    59.5 +    SDL - Simple DirectMedia Layer
    59.6 +    Copyright (C) 1997-2010 Sam Lantinga
    59.7 +
    59.8 +    This library is free software; you can redistribute it and/or
    59.9 +    modify it under the terms of the GNU Lesser General Public
   59.10 +    License as published by the Free Software Foundation; either
   59.11 +    version 2.1 of the License, or (at your option) any later version.
   59.12 +
   59.13 +    This library is distributed in the hope that it will be useful,
   59.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   59.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   59.16 +    Lesser General Public License for more details.
   59.17 +
   59.18 +    You should have received a copy of the GNU Lesser General Public
   59.19 +    License along with this library; if not, write to the Free Software
   59.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   59.21 +
   59.22 +    Sam Lantinga
   59.23 +    slouken@libsdl.org
   59.24 +*/
   59.25 +#include "SDL_config.h"
   59.26 +
   59.27 +#ifndef _SDL_x11clipboard_h
   59.28 +#define _SDL_x11clipboard_h
   59.29 +
   59.30 +extern int X11_SetClipboardText(_THIS, const char *text);
   59.31 +extern char *X11_GetClipboardText(_THIS);
   59.32 +extern SDL_bool X11_HasClipboardText(_THIS);
   59.33 +
   59.34 +#endif /* _SDL_x11clipboard_h */
   59.35 +
   59.36 +/* vi: set ts=4 sw=4 expandtab: */
    60.1 --- a/src/video/x11/SDL_x11events.c	Tue Jul 13 15:05:45 2010 -0400
    60.2 +++ b/src/video/x11/SDL_x11events.c	Sun Jul 18 13:48:23 2010 -0400
    60.3 @@ -25,6 +25,7 @@
    60.4  #include <sys/time.h>
    60.5  #include <signal.h>
    60.6  #include <unistd.h>
    60.7 +#include <limits.h>	/* For INT_MAX */
    60.8  
    60.9  #include "SDL_x11video.h"
   60.10  #include "../../events/SDL_events_c.h"
   60.11 @@ -33,16 +34,19 @@
   60.12  #include "SDL_timer.h"
   60.13  #include "SDL_syswm.h"
   60.14  
   60.15 +#define DEBUG_XEVENTS
   60.16 +
   60.17  static void
   60.18  X11_DispatchEvent(_THIS)
   60.19  {
   60.20      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   60.21 +    Display *display = videodata->display;
   60.22      SDL_WindowData *data;
   60.23      XEvent xevent;
   60.24      int i;
   60.25  
   60.26      SDL_zero(xevent);           /* valgrind fix. --ryan. */
   60.27 -    XNextEvent(videodata->display, &xevent);
   60.28 +    XNextEvent(display, &xevent);
   60.29  
   60.30      /* filter events catchs XIM events and sends them to the correct
   60.31         handler */
   60.32 @@ -77,6 +81,7 @@
   60.33      if (!data) {
   60.34          return;
   60.35      }
   60.36 +
   60.37  #if 0
   60.38      printf("type = %d display = %d window = %d\n",
   60.39             xevent.type, xevent.xany.display, xevent.xany.window);
   60.40 @@ -176,12 +181,11 @@
   60.41              printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
   60.42  #endif
   60.43              SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
   60.44 -#if 0
   60.45 +#if 1
   60.46              if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
   60.47                  int min_keycode, max_keycode;
   60.48 -                XDisplayKeycodes(videodata->display, &min_keycode,
   60.49 -                                 &max_keycode);
   60.50 -                keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
   60.51 +                XDisplayKeycodes(display, &min_keycode, &max_keycode);
   60.52 +                keysym = XKeycodeToKeysym(display, keycode, 0);
   60.53                  fprintf(stderr,
   60.54                          "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n",
   60.55                          keycode, keycode - min_keycode, keysym,
   60.56 @@ -286,6 +290,130 @@
   60.57          }
   60.58          break;
   60.59  
   60.60 +    case PropertyNotify:{
   60.61 +#ifdef DEBUG_XEVENTS
   60.62 +            unsigned char *propdata;
   60.63 +            int status, real_format;
   60.64 +            Atom real_type;
   60.65 +            unsigned long items_read, items_left, i;
   60.66 +
   60.67 +            char *name = XGetAtomName(display, xevent.xproperty.atom);
   60.68 +            if (name) {
   60.69 +                printf("PropertyNotify: %s\n", name);
   60.70 +                XFree(name);
   60.71 +            }
   60.72 +
   60.73 +            status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
   60.74 +            if (status == Success) {
   60.75 +                if (real_type == XA_INTEGER) {
   60.76 +                    int *values = (int *)propdata;
   60.77 +
   60.78 +                    printf("{");
   60.79 +                    for (i = 0; i < items_read; i++) {
   60.80 +                        printf(" %d", values[i]);
   60.81 +                    }
   60.82 +                    printf(" }\n");
   60.83 +                } else if (real_type == XA_CARDINAL) {
   60.84 +                    if (real_format == 32) {
   60.85 +                        Uint32 *values = (Uint32 *)propdata;
   60.86 +
   60.87 +                        printf("{");
   60.88 +                        for (i = 0; i < items_read; i++) {
   60.89 +                            printf(" %d", values[i]);
   60.90 +                        }
   60.91 +                        printf(" }\n");
   60.92 +                    } else if (real_format == 16) {
   60.93 +                        Uint16 *values = (Uint16 *)propdata;
   60.94 +
   60.95 +                        printf("{");
   60.96 +                        for (i = 0; i < items_read; i++) {
   60.97 +                            printf(" %d", values[i]);
   60.98 +                        }
   60.99 +                        printf(" }\n");
  60.100 +                    } else if (real_format == 8) {
  60.101 +                        Uint8 *values = (Uint8 *)propdata;
  60.102 +
  60.103 +                        printf("{");
  60.104 +                        for (i = 0; i < items_read; i++) {
  60.105 +                            printf(" %d", values[i]);
  60.106 +                        }
  60.107 +                        printf(" }\n");
  60.108 +                    }
  60.109 +                } else if (real_type == XA_STRING ||
  60.110 +                           real_type == videodata->UTF8_STRING) {
  60.111 +                    printf("{ \"%s\" }\n", propdata);
  60.112 +                } else if (real_type == XA_ATOM) {
  60.113 +                    Atom *atoms = (Atom *)propdata;
  60.114 +
  60.115 +                    printf("{");
  60.116 +                    for (i = 0; i < items_read; i++) {
  60.117 +                        char *name = XGetAtomName(display, atoms[i]);
  60.118 +                        if (name) {
  60.119 +                            printf(" %s", name);
  60.120 +                            XFree(name);
  60.121 +                        }
  60.122 +                    }
  60.123 +                    printf(" }\n");
  60.124 +                } else {
  60.125 +                    char *name = XGetAtomName(display, real_type);
  60.126 +                    printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
  60.127 +                    if (name) {
  60.128 +                        XFree(name);
  60.129 +                    }
  60.130 +                }
  60.131 +            }
  60.132 +#endif
  60.133 +        }
  60.134 +        break;
  60.135 +
  60.136 +    /* Copy the selection from XA_CUT_BUFFER0 to the requested property */
  60.137 +    case SelectionRequest: {
  60.138 +            XSelectionRequestEvent *req;
  60.139 +            XEvent sevent;
  60.140 +            int seln_format;
  60.141 +            unsigned long nbytes;
  60.142 +            unsigned long overflow;
  60.143 +            unsigned char *seln_data;
  60.144 +
  60.145 +            req = &xevent.xselectionrequest;
  60.146 +#ifdef DEBUG_XEVENTS
  60.147 +            printf("SelectionRequest (requestor = %ld, target = %ld)\n",
  60.148 +                req->requestor, req->target);
  60.149 +#endif
  60.150 +
  60.151 +            SDL_zero(sevent);
  60.152 +            sevent.xany.type = SelectionNotify;
  60.153 +            sevent.xselection.selection = req->selection;
  60.154 +            sevent.xselection.target = None;
  60.155 +            sevent.xselection.property = None;
  60.156 +            sevent.xselection.requestor = req->requestor;
  60.157 +            sevent.xselection.time = req->time;
  60.158 +            if (XGetWindowProperty(display, DefaultRootWindow(display),
  60.159 +                    XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
  60.160 +                    &sevent.xselection.target, &seln_format, &nbytes,
  60.161 +                    &overflow, &seln_data) == Success) {
  60.162 +                if (sevent.xselection.target == req->target) {
  60.163 +                    XChangeProperty(display, req->requestor, req->property,
  60.164 +                        sevent.xselection.target, seln_format, PropModeReplace,
  60.165 +                        seln_data, nbytes);
  60.166 +                    sevent.xselection.property = req->property;
  60.167 +                }
  60.168 +                XFree(seln_data);
  60.169 +            }
  60.170 +            XSendEvent(display, req->requestor, False, 0, &sevent);
  60.171 +            XSync(display, False);
  60.172 +        }
  60.173 +        break;
  60.174 +
  60.175 +    case SelectionNotify: {
  60.176 +#ifdef DEBUG_XEVENTS
  60.177 +            printf("SelectionNotify (requestor = %ld, target = %ld)\n",
  60.178 +                xevent.xselection.requestor, xevent.xselection.target);
  60.179 +#endif
  60.180 +            videodata->selection_waiting = SDL_FALSE;
  60.181 +        }
  60.182 +        break;
  60.183 +
  60.184      default:{
  60.185  #ifdef DEBUG_XEVENTS
  60.186              printf("Unhandled event %d\n", xevent.type);
    61.1 --- a/src/video/x11/SDL_x11keyboard.c	Tue Jul 13 15:05:45 2010 -0400
    61.2 +++ b/src/video/x11/SDL_x11keyboard.c	Sun Jul 18 13:48:23 2010 -0400
    61.3 @@ -211,7 +211,9 @@
    61.4              }
    61.5          }
    61.6          if (j == SDL_arraysize(fingerprint)) {
    61.7 -            /* printf("Using scancode set %d\n", i); */
    61.8 +#ifdef DEBUG_KEYBOARD
    61.9 +            printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size);
   61.10 +#endif
   61.11              SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
   61.12                         sizeof(SDL_scancode) * scancode_set[i].table_size);
   61.13              fingerprint_detected = SDL_TRUE;
    62.1 --- a/src/video/x11/SDL_x11modes.c	Tue Jul 13 15:05:45 2010 -0400
    62.2 +++ b/src/video/x11/SDL_x11modes.c	Sun Jul 18 13:48:23 2010 -0400
    62.3 @@ -23,10 +23,7 @@
    62.4  
    62.5  #include "SDL_x11video.h"
    62.6  
    62.7 -//#define X11MODES_DEBUG
    62.8 -#undef SDL_VIDEO_DRIVER_X11_XINERAMA
    62.9 -#undef SDL_VIDEO_DRIVER_X11_XRANDR
   62.10 -#undef SDL_VIDEO_DRIVER_X11_VIDMODE
   62.11 +/*#define X11MODES_DEBUG*/
   62.12  
   62.13  static int
   62.14  get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
   62.15 @@ -253,6 +250,7 @@
   62.16      return SDL_TRUE;
   62.17  }
   62.18  
   62.19 +static
   62.20  Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr,
   62.21                                         SDL_NAME(XF86VidModeModeInfo) * info)
   62.22  {
   62.23 @@ -296,6 +294,7 @@
   62.24                                        &data->saved_view.y);
   62.25  }
   62.26  
   62.27 +/*
   62.28  static void
   62.29  restore_mode(Display * display, SDL_DisplayData * data)
   62.30  {
   62.31 @@ -313,6 +312,7 @@
   62.32                                            data->saved_view.y);
   62.33      }
   62.34  }
   62.35 +*/
   62.36  #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
   62.37  
   62.38  void
    63.1 --- a/src/video/x11/SDL_x11sym.h	Tue Jul 13 15:05:45 2010 -0400
    63.2 +++ b/src/video/x11/SDL_x11sym.h	Sun Jul 18 13:48:23 2010 -0400
    63.3 @@ -37,6 +37,7 @@
    63.4  SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return)
    63.5  SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
    63.6  SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
    63.7 +SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
    63.8  SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return)
    63.9  SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
   63.10  SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
   63.11 @@ -66,15 +67,18 @@
   63.12  SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
   63.13  SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
   63.14  SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
   63.15 +SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
   63.16  SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
   63.17  SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,unsigned int f,unsigned long g, int h),(a,b,c,d,e,f,g,h),return)
   63.18  SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
   63.19  SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
   63.20  SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
   63.21 +SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
   63.22 +SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return)
   63.23  SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
   63.24 -SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
   63.25  SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
   63.26  SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
   63.27 +SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
   63.28  SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return)
   63.29  SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
   63.30  SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return)
   63.31 @@ -114,14 +118,15 @@
   63.32  SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
   63.33  SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
   63.34  SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return)
   63.35 +SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
   63.36  SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
   63.37 -SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
   63.38  SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
   63.39 -SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
   63.40 -SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
   63.41  SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return)
   63.42  SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return)
   63.43  SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return)
   63.44 +SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return)
   63.45 +SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),)
   63.46 +SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return)
   63.47  SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
   63.48  SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return)
   63.49  SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return)
    64.1 --- a/src/video/x11/SDL_x11video.c	Tue Jul 13 15:05:45 2010 -0400
    64.2 +++ b/src/video/x11/SDL_x11video.c	Sun Jul 18 13:48:23 2010 -0400
    64.3 @@ -21,6 +21,8 @@
    64.4  */
    64.5  #include "SDL_config.h"
    64.6  
    64.7 +#include <unistd.h> /* For getpid() and readlink() */
    64.8 +
    64.9  #include "SDL_video.h"
   64.10  #include "SDL_mouse.h"
   64.11  #include "../SDL_sysvideo.h"
   64.12 @@ -225,6 +227,10 @@
   64.13      device->GL_DeleteContext = X11_GLES_DeleteContext;
   64.14  #endif
   64.15  
   64.16 +    device->SetClipboardText = X11_SetClipboardText;
   64.17 +    device->GetClipboardText = X11_GetClipboardText;
   64.18 +    device->HasClipboardText = X11_HasClipboardText;
   64.19 +
   64.20      device->free = X11_DeleteDevice;
   64.21  
   64.22      return device;
   64.23 @@ -236,6 +242,43 @@
   64.24  };
   64.25  
   64.26  
   64.27 +static void
   64.28 +X11_CheckWindowManager(_THIS)
   64.29 +{
   64.30 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   64.31 +    Display *display = data->display;
   64.32 +    Atom _NET_SUPPORTING_WM_CHECK;
   64.33 +    int status, real_format;
   64.34 +    Atom real_type;
   64.35 +    unsigned long items_read, items_left;
   64.36 +    unsigned char *propdata;
   64.37 +    Window wm_window = 0;
   64.38 +#ifdef DEBUG_WINDOW_MANAGER
   64.39 +    char *wm_name;
   64.40 +#endif
   64.41 +
   64.42 +    _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
   64.43 +    status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   64.44 +    if (status == Success && items_read) {
   64.45 +        wm_window = ((Window*)propdata)[0];
   64.46 +    }
   64.47 +    XFree(propdata);
   64.48 +
   64.49 +    if (!wm_window) {
   64.50 +#ifdef DEBUG_WINDOW_MANAGER
   64.51 +        printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
   64.52 +#endif
   64.53 +        return;
   64.54 +    }
   64.55 +    data->net_wm = SDL_TRUE;
   64.56 +
   64.57 +#ifdef DEBUG_WINDOW_MANAGER
   64.58 +    wm_name = X11_GetWindowTitle(_this, wm_window);
   64.59 +    printf("Window manager: %s\n", wm_name);
   64.60 +    SDL_free(wm_name);
   64.61 +#endif
   64.62 +}
   64.63 +
   64.64  int
   64.65  X11_VideoInit(_THIS)
   64.66  {
   64.67 @@ -253,8 +296,20 @@
   64.68  #endif
   64.69  
   64.70      /* Look up some useful Atoms */
   64.71 -    data->WM_DELETE_WINDOW =
   64.72 -        XInternAtom(data->display, "WM_DELETE_WINDOW", False);
   64.73 +#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
   64.74 +    GET_ATOM(WM_DELETE_WINDOW);
   64.75 +    GET_ATOM(_NET_WM_STATE);
   64.76 +    GET_ATOM(_NET_WM_STATE_HIDDEN);
   64.77 +    GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
   64.78 +    GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
   64.79 +    GET_ATOM(_NET_WM_STATE_FULLSCREEN);
   64.80 +    GET_ATOM(_NET_WM_NAME);
   64.81 +    GET_ATOM(_NET_WM_ICON_NAME);
   64.82 +    GET_ATOM(_NET_WM_ICON);
   64.83 +    GET_ATOM(UTF8_STRING);
   64.84 +
   64.85 +    /* Detect the window manager */
   64.86 +    X11_CheckWindowManager(_this);
   64.87  
   64.88      if (X11_InitModes(_this) < 0) {
   64.89          return -1;
    65.1 --- a/src/video/x11/SDL_x11video.h	Tue Jul 13 15:05:45 2010 -0400
    65.2 +++ b/src/video/x11/SDL_x11video.h	Sun Jul 18 13:48:23 2010 -0400
    65.3 @@ -48,6 +48,7 @@
    65.4  
    65.5  #include "SDL_x11dyn.h"
    65.6  
    65.7 +#include "SDL_x11clipboard.h"
    65.8  #include "SDL_x11events.h"
    65.9  #include "SDL_x11gamma.h"
   65.10  #include "SDL_x11keyboard.h"
   65.11 @@ -67,8 +68,24 @@
   65.12      int numwindows;
   65.13      SDL_WindowData **windowlist;
   65.14      int windowlistlength;
   65.15 +
   65.16 +    /* This is true for ICCCM2.0-compliant window managers */
   65.17 +    SDL_bool net_wm;
   65.18 +
   65.19 +    /* Useful atoms */
   65.20      Atom WM_DELETE_WINDOW;
   65.21 +    Atom _NET_WM_STATE;
   65.22 +    Atom _NET_WM_STATE_HIDDEN;
   65.23 +    Atom _NET_WM_STATE_MAXIMIZED_VERT;
   65.24 +    Atom _NET_WM_STATE_MAXIMIZED_HORZ;
   65.25 +    Atom _NET_WM_STATE_FULLSCREEN;
   65.26 +    Atom _NET_WM_NAME;
   65.27 +    Atom _NET_WM_ICON_NAME;
   65.28 +    Atom _NET_WM_ICON;
   65.29 +    Atom UTF8_STRING;
   65.30 +
   65.31      SDL_scancode key_layout[256];
   65.32 +    SDL_bool selection_waiting;
   65.33  } SDL_VideoData;
   65.34  
   65.35  extern SDL_bool X11_UseDirectColorVisuals(void);
    66.1 --- a/src/video/x11/SDL_x11window.c	Tue Jul 13 15:05:45 2010 -0400
    66.2 +++ b/src/video/x11/SDL_x11window.c	Sun Jul 18 13:48:23 2010 -0400
    66.3 @@ -42,6 +42,50 @@
    66.4  #define _NET_WM_STATE_ADD       1l
    66.5  #define _NET_WM_STATE_TOGGLE    2l
    66.6  
    66.7 +static SDL_bool
    66.8 +X11_IsWindowOldFullscreen(_THIS, SDL_Window * window)
    66.9 +{
   66.10 +    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   66.11 +
   66.12 +    /* ICCCM2.0-compliant window managers can handle fullscreen windows */
   66.13 +    if ((window->flags & SDL_WINDOW_FULLSCREEN) && !videodata->net_wm) {
   66.14 +        return SDL_TRUE;
   66.15 +    } else {
   66.16 +        return SDL_FALSE;
   66.17 +    }
   66.18 +}
   66.19 +
   66.20 +static SDL_bool
   66.21 +X11_IsWindowMapped(_THIS, SDL_Window * window)
   66.22 +{
   66.23 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   66.24 +    SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   66.25 +    XWindowAttributes attr;
   66.26 +
   66.27 +    XGetWindowAttributes(videodata->display, data->xwindow, &attr);
   66.28 +    if (attr.map_state != IsUnmapped) {
   66.29 +        return SDL_TRUE;
   66.30 +    } else {
   66.31 +        return SDL_FALSE;
   66.32 +    }
   66.33 +}
   66.34 +
   66.35 +static int
   66.36 +X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3])
   66.37 +{
   66.38 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   66.39 +    int count = 0;
   66.40 +
   66.41 +    if (window->flags & SDL_WINDOW_FULLSCREEN) {
   66.42 +        atoms[count++] = data->_NET_WM_STATE_FULLSCREEN;
   66.43 +    }
   66.44 +    if (window->flags & SDL_WINDOW_MAXIMIZED) {
   66.45 +        atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_VERT;
   66.46 +        atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_HORZ;
   66.47 +    }
   66.48 +    return count;
   66.49 +}
   66.50 +
   66.51  static void
   66.52  X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
   66.53  {
   66.54 @@ -128,14 +172,10 @@
   66.55      }
   66.56  
   66.57      {
   66.58 -        Atom _NET_WM_STATE =
   66.59 -            XInternAtom(data->videodata->display, "_NET_WM_STATE", False);
   66.60 -        Atom _NET_WM_STATE_MAXIMIZED_VERT =
   66.61 -            XInternAtom(data->videodata->display,
   66.62 -                        "_NET_WM_STATE_MAXIMIZED_VERT", False);
   66.63 -        Atom _NET_WM_STATE_MAXIMIZED_HORZ =
   66.64 -            XInternAtom(data->videodata->display,
   66.65 -                        "_NET_WM_STATE_MAXIMIZED_HORZ", False);
   66.66 +        Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
   66.67 +        Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
   66.68 +        Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
   66.69 +        Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
   66.70          Atom actualType;
   66.71          int actualFormat;
   66.72          unsigned long i, numItems, bytesAfter;
   66.73 @@ -148,19 +188,21 @@
   66.74                                 &propertyValue) == Success) {
   66.75              Atom *atoms = (Atom *) propertyValue;
   66.76              int maximized = 0;
   66.77 +            int fullscreen = 0;
   66.78  
   66.79              for (i = 0; i < numItems; ++i) {
   66.80                  if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
   66.81                      maximized |= 1;
   66.82                  } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
   66.83                      maximized |= 2;
   66.84 +                } else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) {
   66.85 +                    fullscreen = 1;
   66.86                  }
   66.87 -                /* Might also want to check the following properties:
   66.88 -                   _NET_WM_STATE_ABOVE, _NET_WM_STATE_FULLSCREEN
   66.89 -                 */
   66.90              }
   66.91              if (maximized == 3) {
   66.92                  window->flags |= SDL_WINDOW_MAXIMIZED;
   66.93 +            }  else if (fullscreen == 1) {
   66.94 +                window->flags |= SDL_WINDOW_FULLSCREEN;
   66.95              }
   66.96              XFree(propertyValue);
   66.97          }
   66.98 @@ -180,11 +222,6 @@
   66.99         } else {
  66.100         window->flags &= ~SDL_WINDOW_RESIZABLE;
  66.101         }
  66.102 -       if (style & WS_MAXIMIZE) {
  66.103 -       window->flags |= SDL_WINDOW_MAXIMIZED;
  66.104 -       } else {
  66.105 -       window->flags &= ~SDL_WINDOW_MAXIMIZED;
  66.106 -       }
  66.107         if (style & WS_MINIMIZE) {
  66.108         window->flags |= SDL_WINDOW_MINIMIZED;
  66.109         } else {
  66.110 @@ -217,6 +254,8 @@
  66.111      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
  66.112      SDL_DisplayData *displaydata =
  66.113          (SDL_DisplayData *) window->display->driverdata;
  66.114 +    Display *display = data->display;
  66.115 +    int screen = displaydata->screen;
  66.116      Visual *visual;
  66.117      int depth;
  66.118      XSetWindowAttributes xattr;
  66.119 @@ -225,6 +264,14 @@
  66.120      XSizeHints *sizehints;
  66.121      XWMHints *wmhints;
  66.122      XClassHint *classhints;
  66.123 +    SDL_bool oldstyle_fullscreen;
  66.124 +    Atom _NET_WM_WINDOW_TYPE;
  66.125 +    Atom _NET_WM_WINDOW_TYPE_NORMAL;
  66.126 +    int wmstate_count;
  66.127 +    Atom wmstate_atoms[3];
  66.128 +
  66.129 +    /* ICCCM2.0-compliant window managers can handle fullscreen windows */
  66.130 +    oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
  66.131  
  66.132  #if SDL_VIDEO_DRIVER_X11_XINERAMA
  66.133  /* FIXME
  66.134 @@ -238,7 +285,7 @@
  66.135      if (window->flags & SDL_WINDOW_OPENGL) {
  66.136          XVisualInfo *vinfo;
  66.137  
  66.138 -        vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen);
  66.139 +        vinfo = X11_GL_GetVisual(_this, display, screen);
  66.140          if (!vinfo) {
  66.141              return -1;
  66.142          }
  66.143 @@ -251,7 +298,7 @@
  66.144      if (window->flags & SDL_WINDOW_OPENGL) {
  66.145          XVisualInfo *vinfo;
  66.146  
  66.147 -        vinfo = X11_GLES_GetVisual(_this, data->display, displaydata->screen);
  66.148 +        vinfo = X11_GLES_GetVisual(_this, display, screen);
  66.149          if (!vinfo) {
  66.150              return -1;
  66.151          }
  66.152 @@ -265,7 +312,7 @@
  66.153          depth = displaydata->depth;
  66.154      }
  66.155  
  66.156 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
  66.157 +    if (oldstyle_fullscreen) {
  66.158          xattr.override_redirect = True;
  66.159      } else {
  66.160          xattr.override_redirect = False;
  66.161 @@ -289,16 +336,13 @@
  66.162          Sint32 r, g, b;
  66.163  
  66.164          /* Is the colormap we need already registered in SDL? */
  66.165 -        if (colormap =
  66.166 -            X11_LookupColormap(data->display,
  66.167 -                               displaydata->screen, visual->visualid)) {
  66.168 +        if ((colormap =
  66.169 +            X11_LookupColormap(display, screen, visual->visualid))) {
  66.170              xattr.colormap = colormap;
  66.171  /*             printf("found existing colormap\n"); */
  66.172          } else {
  66.173              /* The colormap is not known to SDL so we will create it */
  66.174 -            colormap = XCreateColormap(data->display,
  66.175 -                                       RootWindow(data->display,
  66.176 -                                                  displaydata->screen),
  66.177 +            colormap = XCreateColormap(display, RootWindow(display, screen),
  66.178                                         visual, AllocAll);
  66.179  /*             printf("colormap = %x\n", colormap); */
  66.180  
  66.181 @@ -377,11 +421,10 @@
  66.182              }
  66.183  
  66.184  /*             status = */
  66.185 -/*                 XStoreColors(data->display, colormap, colorcells, ncolors); */
  66.186 +/*                 XStoreColors(display, colormap, colorcells, ncolors); */
  66.187  
  66.188              xattr.colormap = colormap;
  66.189 -            X11_TrackColormap(data->display, displaydata->screen,
  66.190 -                              colormap, visual, NULL);
  66.191 +            X11_TrackColormap(display, screen, colormap, visual, NULL);
  66.192  
  66.193              SDL_free(colorcells);
  66.194          }
  66.195 @@ -397,15 +440,12 @@
  66.196  
  66.197          /* Is the colormap we need already registered in SDL? */
  66.198          if ((colormap =
  66.199 -             X11_LookupColormap(data->display,
  66.200 -                                displaydata->screen, visual->visualid))) {
  66.201 +             X11_LookupColormap(display, screen, visual->visualid))) {
  66.202              xattr.colormap = colormap;
  66.203  /*             printf("found existing colormap\n"); */
  66.204          } else {
  66.205              /* The colormap is not known to SDL so we will create it */
  66.206 -            colormap = XCreateColormap(data->display,
  66.207 -                                       RootWindow(data->display,
  66.208 -                                                  displaydata->screen),
  66.209 +            colormap = XCreateColormap(display, RootWindow(display, screen),
  66.210                                         visual, AllocAll);
  66.211  /*             printf("colormap = %x\n", colormap); */
  66.212  
  66.213 @@ -417,7 +457,6 @@
  66.214              }
  66.215  
  66.216              /* OK, we got a colormap, now fill it in as best as we can */
  66.217 -
  66.218              colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
  66.219              if (NULL == colorcells) {
  66.220                  SDL_SetError("out of memory in X11_CreateWindow");
  66.221 @@ -479,22 +518,20 @@
  66.222              }
  66.223  
  66.224              status =
  66.225 -                XStoreColors(data->display, colormap, colorcells, ncolors);
  66.226 +                XStoreColors(display, colormap, colorcells, ncolors);
  66.227  
  66.228              xattr.colormap = colormap;
  66.229 -            X11_TrackColormap(data->display, displaydata->screen,
  66.230 -                              colormap, visual, colorcells);
  66.231 +            X11_TrackColormap(display, screen, colormap, visual, colorcells);
  66.232  
  66.233              SDL_free(colorcells);
  66.234          }
  66.235      } else {
  66.236          xattr.colormap =
  66.237 -            XCreateColormap(data->display,
  66.238 -                            RootWindow(data->display, displaydata->screen),
  66.239 +            XCreateColormap(display, RootWindow(display, screen),
  66.240                              visual, AllocNone);
  66.241      }
  66.242  
  66.243 -    if ((window->flags & SDL_WINDOW_FULLSCREEN)
  66.244 +    if (oldstyle_fullscreen
  66.245          || window->x == SDL_WINDOWPOS_CENTERED) {
  66.246          X11_GetDisplaySize(_this, window, &x, NULL);
  66.247          x = (x - window->w) / 2;
  66.248 @@ -503,7 +540,7 @@
  66.249      } else {
  66.250          x = window->x;
  66.251      }
  66.252 -    if ((window->flags & SDL_WINDOW_FULLSCREEN)
  66.253 +    if (oldstyle_fullscreen
  66.254          || window->y == SDL_WINDOWPOS_CENTERED) {
  66.255          X11_GetDisplaySize(_this, window, NULL, &y);
  66.256          y = (y - window->h) / 2;
  66.257 @@ -513,8 +550,7 @@
  66.258          y = window->y;
  66.259      }
  66.260  
  66.261 -    w = XCreateWindow(data->display,
  66.262 -                      RootWindow(data->display, displaydata->screen), x, y,
  66.263 +    w = XCreateWindow(display, RootWindow(display, screen), x, y,
  66.264                        window->w, window->h, 0, depth, InputOutput, visual,
  66.265                        (CWOverrideRedirect | CWBackPixel | CWBorderPixel |
  66.266                         CWColormap), &xattr);
  66.267 @@ -539,23 +575,23 @@
  66.268      sizehints = XAllocSizeHints();
  66.269      if (sizehints) {
  66.270          if (!(window->flags & SDL_WINDOW_RESIZABLE)
  66.271 -            || (window->flags & SDL_WINDOW_FULLSCREEN)) {
  66.272 +            || oldstyle_fullscreen) {
  66.273              sizehints->min_width = sizehints->max_width = window->w;
  66.274              sizehints->min_height = sizehints->max_height = window->h;
  66.275              sizehints->flags = PMaxSize | PMinSize;
  66.276          }
  66.277 -        if (!(window->flags & SDL_WINDOW_FULLSCREEN)
  66.278 +        if (!oldstyle_fullscreen
  66.279              && window->x != SDL_WINDOWPOS_UNDEFINED
  66.280              && window->y != SDL_WINDOWPOS_UNDEFINED) {
  66.281              sizehints->x = x;
  66.282              sizehints->y = y;
  66.283              sizehints->flags |= USPosition;
  66.284          }
  66.285 -        XSetWMNormalHints(data->display, w, sizehints);
  66.286 +        XSetWMNormalHints(display, w, sizehints);
  66.287          XFree(sizehints);
  66.288      }
  66.289  
  66.290 -    if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) {
  66.291 +    if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) {
  66.292          SDL_bool set;
  66.293          Atom WM_HINTS;
  66.294  
  66.295 @@ -563,7 +599,7 @@
  66.296          set = SDL_FALSE;
  66.297  
  66.298          /* First try to set MWM hints */
  66.299 -        WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
  66.300 +        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
  66.301          if (WM_HINTS != None) {
  66.302              /* Hints used by Motif compliant window managers */
  66.303              struct
  66.304 @@ -576,40 +612,36 @@
  66.305              } MWMHints = {
  66.306              (1L << 1), 0, 0, 0, 0};
  66.307  
  66.308 -            XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32,
  66.309 +            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
  66.310                              PropModeReplace, (unsigned char *) &MWMHints,
  66.311 -                            sizeof(MWMHints) / sizeof(long));
  66.312 +                            sizeof(MWMHints) / 4);
  66.313              set = SDL_TRUE;
  66.314          }
  66.315          /* Now try to set KWM hints */
  66.316 -        WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
  66.317 +        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
  66.318          if (WM_HINTS != None) {
  66.319              long KWMHints = 0;
  66.320  
  66.321 -            XChangeProperty(data->display, w,
  66.322 -                            WM_HINTS, WM_HINTS, 32,
  66.323 +            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
  66.324                              PropModeReplace,
  66.325                              (unsigned char *) &KWMHints,
  66.326 -                            sizeof(KWMHints) / sizeof(long));
  66.327 +                            sizeof(KWMHints) / 4);
  66.328              set = SDL_TRUE;
  66.329          }
  66.330          /* Now try to set GNOME hints */
  66.331 -        WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
  66.332 +        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
  66.333          if (WM_HINTS != None) {
  66.334              long GNOMEHints = 0;
  66.335  
  66.336 -            XChangeProperty(data->display, w,
  66.337 -                            WM_HINTS, WM_HINTS, 32,
  66.338 +            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
  66.339                              PropModeReplace,
  66.340                              (unsigned char *) &GNOMEHints,
  66.341 -                            sizeof(GNOMEHints) / sizeof(long));
  66.342 +                            sizeof(GNOMEHints) / 4);
  66.343              set = SDL_TRUE;
  66.344          }
  66.345          /* Finally set the transient hints if necessary */
  66.346          if (!set) {
  66.347 -            XSetTransientForHint(data->display, w,
  66.348 -                                 RootWindow(data->display,
  66.349 -                                            displaydata->screen));
  66.350 +            XSetTransientForHint(display, w, RootWindow(display, screen));
  66.351          }
  66.352      } else {
  66.353          SDL_bool set;
  66.354 @@ -619,53 +651,36 @@
  66.355          set = SDL_FALSE;
  66.356  
  66.357          /* First try to unset MWM hints */
  66.358 -        WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
  66.359 +        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
  66.360          if (WM_HINTS != None) {
  66.361 -            XDeleteProperty(data->display, w, WM_HINTS);
  66.362 +            XDeleteProperty(display, w, WM_HINTS);
  66.363              set = SDL_TRUE;
  66.364          }
  66.365          /* Now try to unset KWM hints */
  66.366 -        WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
  66.367 +        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
  66.368          if (WM_HINTS != None) {
  66.369 -            XDeleteProperty(data->display, w, WM_HINTS);
  66.370 +            XDeleteProperty(display, w, WM_HINTS);
  66.371              set = SDL_TRUE;
  66.372          }
  66.373          /* Now try to unset GNOME hints */
  66.374 -        WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
  66.375 +        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
  66.376          if (WM_HINTS != None) {
  66.377 -            XDeleteProperty(data->display, w, WM_HINTS);
  66.378 +            XDeleteProperty(display, w, WM_HINTS);
  66.379              set = SDL_TRUE;
  66.380          }
  66.381          /* Finally unset the transient hints if necessary */
  66.382          if (!set) {
  66.383              /* NOTE: Does this work? */
  66.384 -            XSetTransientForHint(data->display, w, None);
  66.385 +            XSetTransientForHint(display, w, None);
  66.386          }
  66.387      }
  66.388  
  66.389 -    /* Tell KDE to keep fullscreen windows on top */
  66.390 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
  66.391 -        XEvent ev;
  66.392 -
  66.393 -        SDL_zero(ev);
  66.394 -        ev.xclient.type = ClientMessage;
  66.395 -        ev.xclient.window = RootWindow(data->display, displaydata->screen);
  66.396 -        ev.xclient.message_type =
  66.397 -            XInternAtom(data->display, "KWM_KEEP_ON_TOP", False);
  66.398 -        ev.xclient.format = 32;
  66.399 -        ev.xclient.data.l[0] = w;
  66.400 -        ev.xclient.data.l[1] = CurrentTime;
  66.401 -        XSendEvent(data->display,
  66.402 -                   RootWindow(data->display, displaydata->screen), False,
  66.403 -                   SubstructureRedirectMask, &ev);
  66.404 -    }
  66.405 -
  66.406      /* Set the input hints so we get keyboard input */
  66.407      wmhints = XAllocWMHints();
  66.408      if (wmhints) {
  66.409          wmhints->input = True;
  66.410          wmhints->flags = InputHint;
  66.411 -        XSetWMHints(data->display, w, wmhints);
  66.412 +        XSetWMHints(display, w, wmhints);
  66.413          XFree(wmhints);
  66.414      }
  66.415  
  66.416 @@ -674,15 +689,32 @@
  66.417      if (classhints != NULL) {
  66.418          classhints->res_name = data->classname;
  66.419          classhints->res_class = data->classname;
  66.420 -        XSetClassHint(data->display, w, classhints);
  66.421 +        XSetClassHint(display, w, classhints);
  66.422          XFree(classhints);
  66.423      }
  66.424  
  66.425 +    /* Set the window manager state */
  66.426 +    wmstate_count = X11_GetWMStateProperty(_this, window, wmstate_atoms);
  66.427 +    if (wmstate_count > 0) {
  66.428 +        XChangeProperty(display, w, data->_NET_WM_STATE, XA_ATOM, 32,
  66.429 +                        PropModeReplace,
  66.430 +                        (unsigned char *)wmstate_atoms, wmstate_count);
  66.431 +    } else {
  66.432 +        XDeleteProperty(display, w, data->_NET_WM_STATE);
  66.433 +    }
  66.434 +
  66.435 +    /* Let the window manager know we're a "normal" window */
  66.436 +    _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
  66.437 +    _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
  66.438 +    XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
  66.439 +                    PropModeReplace,
  66.440 +                    (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
  66.441 +
  66.442      /* Allow the window to be deleted by the window manager */
  66.443 -    XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
  66.444 +    XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1);
  66.445  
  66.446      if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
  66.447 -        XDestroyWindow(data->display, w);
  66.448 +        XDestroyWindow(display, w);
  66.449          return -1;
  66.450      }
  66.451  #ifdef X_HAVE_UTF8_STRING
  66.452 @@ -690,7 +722,7 @@
  66.453          Uint32 fevent = 0;
  66.454          pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
  66.455                        XNFilterEvents, &fevent, NULL);
  66.456 -        XSelectInput(data->display, w,
  66.457 +        XSelectInput(display, w,
  66.458                       (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
  66.459                        ExposureMask | ButtonPressMask | ButtonReleaseMask |
  66.460                        PointerMotionMask | KeyPressMask | KeyReleaseMask |
  66.461 @@ -699,7 +731,7 @@
  66.462      }
  66.463  #else
  66.464      {
  66.465 -        XSelectInput(data->display, w,
  66.466 +        XSelectInput(display, w,
  66.467                       (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
  66.468                        ExposureMask | ButtonPressMask | ButtonReleaseMask |
  66.469                        PointerMotionMask | KeyPressMask | KeyReleaseMask |
  66.470 @@ -716,7 +748,7 @@
  66.471  {
  66.472      Window w = (Window) data;
  66.473  
  66.474 -    /* FIXME: Query the title from the existing window */
  66.475 +    window->title = X11_GetWindowTitle(_this, w);
  66.476  
  66.477      if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
  66.478          return -1;
  66.479 @@ -724,6 +756,36 @@
  66.480      return 0;
  66.481  }
  66.482  
  66.483 +char *
  66.484 +X11_GetWindowTitle(_THIS, Window xwindow)
  66.485 +{
  66.486 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
  66.487 +    Display *display = data->display;
  66.488 +    int status, real_format;
  66.489 +    Atom real_type;
  66.490 +    unsigned long items_read, items_left;
  66.491 +    unsigned char *propdata;
  66.492 +    char *title = NULL;
  66.493 +
  66.494 +    status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
  66.495 +                0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
  66.496 +                &items_read, &items_left, &propdata);
  66.497 +    if (status == Success) {
  66.498 +        title = SDL_strdup(SDL_static_cast(char*, propdata));
  66.499 +        XFree(propdata);
  66.500 +    } else {
  66.501 +        status = XGetWindowProperty(display, xwindow, XA_WM_NAME,
  66.502 +                    0L, 8192L, False, XA_STRING, &real_type, &real_format,
  66.503 +                    &items_read, &items_left, &propdata);
  66.504 +        if (status == Success) {
  66.505 +            title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1);
  66.506 +        } else {
  66.507 +            title = SDL_strdup("");
  66.508 +        }
  66.509 +    }
  66.510 +    return title;
  66.511 +}
  66.512 +
  66.513  void
  66.514  X11_SetWindowTitle(_THIS, SDL_Window * window)
  66.515  {
  66.516 @@ -735,14 +797,8 @@
  66.517      const char *icon = NULL;
  66.518  
  66.519  #ifdef X_HAVE_UTF8_STRING
  66.520 -    Atom _NET_WM_NAME = 0;
  66.521 -    Atom _NET_WM_ICON_NAME = 0;
  66.522 -
  66.523 -    /* Look up some useful Atoms */
  66.524 -    if (SDL_X11_HAVE_UTF8) {
  66.525 -        _NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False);
  66.526 -        _NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False);
  66.527 -    }
  66.528 +    Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
  66.529 +    Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
  66.530  #endif
  66.531  
  66.532      if (title != NULL) {
  66.533 @@ -803,13 +859,13 @@
  66.534  {
  66.535      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  66.536      Display *display = data->videodata->display;
  66.537 -    Atom _NET_WM_ICON = XInternAtom(display, "_NET_WM_ICON", False);
  66.538 +    Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON;
  66.539  
  66.540      if (icon) {
  66.541          SDL_PixelFormat format;
  66.542          SDL_Surface *surface;
  66.543          int propsize;
  66.544 -        Uint32 *propdata;
  66.545 +        long *propdata;
  66.546  
  66.547          /* Convert the icon to ARGB for modern window managers */
  66.548          SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
  66.549 @@ -823,10 +879,19 @@
  66.550          propsize = 2 + (icon->w * icon->h);
  66.551          propdata = SDL_malloc(propsize * sizeof(Uint32));
  66.552          if (propdata) {
  66.553 +            int x, y;
  66.554 +            Uint32 *src;
  66.555 +            long *dst;
  66.556 +
  66.557              propdata[0] = icon->w;
  66.558              propdata[1] = icon->h;
  66.559 -            SDL_memcpy(&propdata[2], surface->pixels,
  66.560 -                       surface->h * surface->pitch);
  66.561 +            dst = &propdata[2];
  66.562 +            for (y = 0; y < icon->h; ++y) {
  66.563 +                src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch);
  66.564 +                for (x = 0; x < icon->w; ++x) {
  66.565 +                    *dst++ = *src++;
  66.566 +                }
  66.567 +            }
  66.568              XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
  66.569                              32, PropModeReplace, (unsigned char *) propdata,
  66.570                              propsize);
  66.571 @@ -842,16 +907,20 @@
  66.572  {
  66.573      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  66.574      Display *display = data->videodata->display;
  66.575 +    SDL_bool oldstyle_fullscreen;
  66.576      int x, y;
  66.577  
  66.578 -    if ((window->flags & SDL_WINDOW_FULLSCREEN)
  66.579 +    /* ICCCM2.0-compliant window managers can handle fullscreen windows */
  66.580 +    oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
  66.581 +
  66.582 +    if (oldstyle_fullscreen
  66.583          || window->x == SDL_WINDOWPOS_CENTERED) {
  66.584          X11_GetDisplaySize(_this, window, &x, NULL);
  66.585          x = (x - window->w) / 2;
  66.586      } else {
  66.587          x = window->x;
  66.588      }
  66.589 -    if ((window->flags & SDL_WINDOW_FULLSCREEN)
  66.590 +    if (oldstyle_fullscreen
  66.591          || window->y == SDL_WINDOWPOS_CENTERED) {
  66.592          X11_GetDisplaySize(_this, window, NULL, &y);
  66.593          y = (y - window->h) / 2;
  66.594 @@ -904,26 +973,45 @@
  66.595      SDL_DisplayData *displaydata =
  66.596          (SDL_DisplayData *) window->display->driverdata;
  66.597      Display *display = data->videodata->display;
  66.598 -    Atom _NET_WM_STATE = XInternAtom(display, "_NET_WM_STATE", False);
  66.599 -    Atom _NET_WM_STATE_MAXIMIZED_VERT =
  66.600 -        XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
  66.601 -    Atom _NET_WM_STATE_MAXIMIZED_HORZ =
  66.602 -        XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
  66.603 -    XEvent e;
  66.604 +    Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
  66.605 +    Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
  66.606 +    Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
  66.607 +    Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
  66.608  
  66.609 -    e.xany.type = ClientMessage;
  66.610 -    e.xany.window = data->xwindow;
  66.611 -    e.xclient.message_type = _NET_WM_STATE;
  66.612 -    e.xclient.format = 32;
  66.613 -    e.xclient.data.l[0] =
  66.614 -        maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
  66.615 -    e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
  66.616 -    e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
  66.617 -    e.xclient.data.l[3] = 0l;
  66.618 -    e.xclient.data.l[4] = 0l;
  66.619 +    if (X11_IsWindowMapped(_this, window)) {
  66.620 +        XEvent e;
  66.621  
  66.622 -    XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  66.623 -               SubstructureNotifyMask | SubstructureRedirectMask, &e);
  66.624 +        SDL_zero(e);
  66.625 +        e.xany.type = ClientMessage;
  66.626 +        e.xclient.message_type = _NET_WM_STATE;
  66.627 +        e.xclient.format = 32;
  66.628 +        e.xclient.window = data->xwindow;
  66.629 +        e.xclient.data.l[0] =
  66.630 +            maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
  66.631 +        e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
  66.632 +        e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
  66.633 +        e.xclient.data.l[3] = 0l;
  66.634 +
  66.635 +        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  66.636 +                   SubstructureNotifyMask | SubstructureRedirectMask, &e);
  66.637 +    } else {
  66.638 +        int count = 0;
  66.639 +        Atom atoms[3];
  66.640 +
  66.641 +        if (window->flags & SDL_WINDOW_FULLSCREEN) {
  66.642 +            atoms[count++] = _NET_WM_STATE_FULLSCREEN;
  66.643 +        }
  66.644 +        if (maximized) {
  66.645 +            atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT;
  66.646 +            atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
  66.647 +        }
  66.648 +        if (count > 0) {
  66.649 +            XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32,
  66.650 +                            PropModeReplace, (unsigned char *)atoms, count);
  66.651 +        } else {
  66.652 +            XDeleteProperty(display, data->xwindow, _NET_WM_STATE);
  66.653 +        }
  66.654 +    }
  66.655  }
  66.656  
  66.657  void
  66.658 @@ -935,7 +1023,12 @@
  66.659  void
  66.660  X11_MinimizeWindow(_THIS, SDL_Window * window)
  66.661  {
  66.662 -    X11_HideWindow(_this, window);
  66.663 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  66.664 +    SDL_DisplayData *displaydata =
  66.665 +        (SDL_DisplayData *) window->display->driverdata;
  66.666 +    Display *display = data->videodata->display;
  66.667 + 
  66.668 +    XIconifyWindow(display, data->xwindow, displaydata->screen);
  66.669  }
  66.670  
  66.671  void
  66.672 @@ -950,8 +1043,12 @@
  66.673  {
  66.674      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  66.675      Display *display = data->videodata->display;
  66.676 +    SDL_bool oldstyle_fullscreen;
  66.677  
  66.678 -    if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
  66.679 +    /* ICCCM2.0-compliant window managers can handle fullscreen windows */
  66.680 +    oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
  66.681 +
  66.682 +    if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen)
  66.683          && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
  66.684          /* Try to grab the mouse */
  66.685          for (;;) {
  66.686 @@ -1014,8 +1111,14 @@
  66.687  SDL_bool
  66.688  X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
  66.689  {
  66.690 -    if (info->version.major <= SDL_MAJOR_VERSION) {
  66.691 -        /* FIXME! */
  66.692 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  66.693 +    Display *display = data->videodata->display;
  66.694 +
  66.695 +    if (info->version.major == SDL_MAJOR_VERSION &&
  66.696 +        info->version.minor == SDL_MINOR_VERSION) {
  66.697 +        info->subsystem = SDL_SYSWM_X11;
  66.698 +        info->info.x11.display = display;
  66.699 +        info->info.x11.window = data->xwindow;
  66.700          return SDL_TRUE;
  66.701      } else {
  66.702          SDL_SetError("Application not compiled with SDL %d.%d\n",
    67.1 --- a/src/video/x11/SDL_x11window.h	Tue Jul 13 15:05:45 2010 -0400
    67.2 +++ b/src/video/x11/SDL_x11window.h	Sun Jul 18 13:48:23 2010 -0400
    67.3 @@ -35,6 +35,7 @@
    67.4  
    67.5  extern int X11_CreateWindow(_THIS, SDL_Window * window);
    67.6  extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
    67.7 +extern char *X11_GetWindowTitle(_THIS, Window xwindow);
    67.8  extern void X11_SetWindowTitle(_THIS, SDL_Window * window);
    67.9  extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
   67.10  extern void X11_SetWindowPosition(_THIS, SDL_Window * window);
    68.1 --- a/test/common.c	Tue Jul 13 15:05:45 2010 -0400
    68.2 +++ b/test/common.c	Sun Jul 18 13:48:23 2010 -0400
    68.3 @@ -6,7 +6,7 @@
    68.4  #include "common.h"
    68.5  
    68.6  #define VIDEO_USAGE \
    68.7 -"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
    68.8 +"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab] [--double] [--triple]"
    68.9  
   68.10  #define AUDIO_USAGE \
   68.11  "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
   68.12 @@ -192,6 +192,14 @@
   68.13          state->window_title = argv[index];
   68.14          return 2;
   68.15      }
   68.16 +    if (SDL_strcasecmp(argv[index], "--icon") == 0) {
   68.17 +        ++index;
   68.18 +        if (!argv[index]) {
   68.19 +            return -1;
   68.20 +        }
   68.21 +        state->window_icon = argv[index];
   68.22 +        return 2;
   68.23 +    }
   68.24      if (SDL_strcasecmp(argv[index], "--center") == 0) {
   68.25          state->window_x = SDL_WINDOWPOS_CENTERED;
   68.26          state->window_y = SDL_WINDOWPOS_CENTERED;
   68.27 @@ -611,6 +619,30 @@
   68.28      }
   68.29  }
   68.30  
   68.31 +static SDL_Surface *
   68.32 +LoadIcon(const char *file)
   68.33 +{
   68.34 +    SDL_Surface *icon;
   68.35 +
   68.36 +    /* Load the icon surface */
   68.37 +    icon = SDL_LoadBMP(file);
   68.38 +    if (icon == NULL) {
   68.39 +        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
   68.40 +        return (NULL);
   68.41 +    }
   68.42 +
   68.43 +    if (icon->format->palette == NULL) {
   68.44 +        fprintf(stderr, "Icon must have a palette!\n");
   68.45 +        SDL_FreeSurface(icon);
   68.46 +        return (NULL);
   68.47 +    }
   68.48 +
   68.49 +    /* Set the colorkey */
   68.50 +    SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
   68.51 +
   68.52 +    return (icon);
   68.53 +}
   68.54 +
   68.55  SDL_bool
   68.56  CommonInit(CommonState * state)
   68.57  {
   68.58 @@ -791,6 +823,15 @@
   68.59                          SDL_GetError());
   68.60                  return SDL_FALSE;
   68.61              }
   68.62 +
   68.63 +            if (state->window_icon) {
   68.64 +                SDL_Surface *icon = LoadIcon(state->window_icon);
   68.65 +                if (icon) {
   68.66 +                    SDL_SetWindowIcon(state->windows[i], icon);
   68.67 +                    SDL_FreeSurface(icon);
   68.68 +                }
   68.69 +            }
   68.70 +
   68.71              SDL_ShowWindow(state->windows[i]);
   68.72  
   68.73              if (!state->skip_renderer
   68.74 @@ -1017,6 +1058,9 @@
   68.75          fprintf(stderr, "Joystick %d: button %d released",
   68.76                  event->jbutton.which, event->jbutton.button);
   68.77          break;
   68.78 +    case SDL_CLIPBOARDUPDATE:
   68.79 +        fprintf(stderr, "Clipboard updated");
   68.80 +        break;
   68.81      case SDL_QUIT:
   68.82          fprintf(stderr, "Quit requested");
   68.83          break;
   68.84 @@ -1050,11 +1094,43 @@
   68.85      case SDL_KEYDOWN:
   68.86          switch (event->key.keysym.sym) {
   68.87              /* Add hotkeys here */
   68.88 +        case SDLK_c:
   68.89 +            if (event->key.keysym.mod & KMOD_CTRL) {
   68.90 +                /* Ctrl-C copy awesome text! */
   68.91 +                SDL_SetClipboardText("SDL rocks!\nYou know it!");
   68.92 +                printf("Copied text to clipboard\n");
   68.93 +            }
   68.94 +            break;
   68.95 +        case SDLK_v:
   68.96 +            if (event->key.keysym.mod & KMOD_CTRL) {
   68.97 +                /* Ctrl-V paste awesome text! */
   68.98 +                char *text = SDL_GetClipboardText();
   68.99 +                if (*text) {
  68.100 +                    printf("Clipboard: %s\n", text);
  68.101 +                } else {
  68.102 +                    printf("Clipboard is empty\n");
  68.103 +                }
  68.104 +                SDL_free(text);
  68.105 +            }
  68.106 +            break;
  68.107          case SDLK_g:
  68.108              if (event->key.keysym.mod & KMOD_CTRL) {
  68.109                  /* Ctrl-G toggle grab */
  68.110              }
  68.111              break;
  68.112 +        case SDLK_m:
  68.113 +            if (event->key.keysym.mod & KMOD_CTRL) {
  68.114 +                /* Ctrl-M maximize */
  68.115 +                /* FIXME: Which window has focus for this keyboard? */
  68.116 +                for (i = 0; i < state->num_windows; ++i) {
  68.117 +                    if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) {
  68.118 +                        SDL_RestoreWindow(state->windows[i]);
  68.119 +                    } else {
  68.120 +                        SDL_MaximizeWindow(state->windows[i]);
  68.121 +                    }
  68.122 +                }
  68.123 +            }
  68.124 +            break;
  68.125          case SDLK_z:
  68.126              if (event->key.keysym.mod & KMOD_CTRL) {
  68.127                  /* Ctrl-Z minimize */
    69.1 --- a/test/common.h	Tue Jul 13 15:05:45 2010 -0400
    69.2 +++ b/test/common.h	Sun Jul 18 13:48:23 2010 -0400
    69.3 @@ -24,6 +24,7 @@
    69.4      const char *videodriver;
    69.5      int display;
    69.6      const char *window_title;
    69.7 +    const char *window_icon;
    69.8      Uint32 window_flags;
    69.9      int window_x;
   69.10      int window_y;