Mercurial > sdl-ios-xcode
changeset 4755:436183eb30c8
Merge with main repo (mainly for non-printable character fix)
author | dewyatt |
---|---|
date | Sun, 18 Jul 2010 13:48:23 -0400 |
parents | 2072fed2f583 (current diff) af1d018ebbe6 (diff) |
children | b99b1024607a |
files | 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 |
diffstat | 69 files changed, 2917 insertions(+), 1427 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.in Tue Jul 13 15:05:45 2010 -0400 +++ b/Makefile.in Sun Jul 18 13:48:23 2010 -0400 @@ -44,7 +44,7 @@ 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 -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 +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 LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@
--- a/VisualC/SDL/SDL_VS2005.vcproj Tue Jul 13 15:05:45 2010 -0400 +++ b/VisualC/SDL/SDL_VS2005.vcproj Sun Jul 18 13:48:23 2010 -0400 @@ -236,6 +236,10 @@ > </File> <File + RelativePath="..\..\include\SDL_clipboard.h" + > + </File> + <File RelativePath="..\..\include\SDL_compat.h" > </File> @@ -561,6 +565,18 @@ > </File> <File + RelativePath="..\..\src\video\SDL_clipboard.c" + > + </File> + <File + RelativePath="..\..\src\events\SDL_clipboardevents.c" + > + </File> + <File + RelativePath="..\..\src\events\SDL_clipboardevents_c.h" + > + </File> + <File RelativePath="..\..\src\SDL_compat.c" > </File> @@ -841,10 +857,6 @@ > </File> <File - RelativePath="..\..\src\video\SDL_stretch_c.h" - > - </File> - <File RelativePath="..\..\src\stdlib\SDL_string.c" > </File> @@ -945,6 +957,14 @@ > </File> <File + RelativePath="..\..\src\video\win32\SDL_win32clipboard.c" + > + </File> + <File + RelativePath="..\..\src\video\win32\SDL_win32clipboard.h" + > + </File> + <File RelativePath="..\..\src\video\win32\SDL_win32events.c" > </File>
--- a/VisualC/SDL/SDL_VS2008.vcproj Tue Jul 13 15:05:45 2010 -0400 +++ b/VisualC/SDL/SDL_VS2008.vcproj Sun Jul 18 13:48:23 2010 -0400 @@ -383,6 +383,10 @@ > </File> <File + RelativePath="..\..\include\SDL_clipboard.h" + > + </File> + <File RelativePath="..\..\include\SDL_compat.h" > </File> @@ -716,6 +720,18 @@ > </File> <File + RelativePath="..\..\src\video\SDL_clipboard.c" + > + </File> + <File + RelativePath="..\..\src\events\SDL_clipboardevents.c" + > + </File> + <File + RelativePath="..\..\src\events\SDL_clipboardevents_c.h" + > + </File> + <File RelativePath="..\..\src\SDL_compat.c" > </File> @@ -996,10 +1012,6 @@ > </File> <File - RelativePath="..\..\src\video\SDL_stretch_c.h" - > - </File> - <File RelativePath="..\..\src\stdlib\SDL_string.c" > </File> @@ -1100,6 +1112,14 @@ > </File> <File + RelativePath="..\..\src\video\win32\SDL_win32clipboard.c" + > + </File> + <File + RelativePath="..\..\src\video\win32\SDL_win32clipboard.h" + > + </File> + <File RelativePath="..\..\src\video\win32\SDL_win32events.c" > </File>
--- a/VisualC/SDLmain/SDLmain_VS2008.vcproj Tue Jul 13 15:05:45 2010 -0400 +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj Sun Jul 18 13:48:23 2010 -0400 @@ -29,7 +29,7 @@ <Tool Name="VCPreBuildEventTool" Description="Making sure basic SDL headers are in place..." - CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY" + CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY
" /> <Tool Name="VCCustomBuildTool" @@ -166,7 +166,7 @@ <Tool Name="VCPreBuildEventTool" Description="Making sure basic SDL headers are in place..." - CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY" + CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY
" /> <Tool Name="VCCustomBuildTool" @@ -303,7 +303,7 @@ <Tool Name="VCPreBuildEventTool" Description="Making sure basic SDL headers are in place..." - CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY" + CommandLine="if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
echo Copying SDL_config_win32.h to SDL_config.h...
copy "$(ProjectDir)\..\..\include\SDL_config_win32.h" "$(ProjectDir)\..\..\include\SDL_config.h"
:SDLCONFIGOKAY

if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
echo Creating stub SDL_revision.h file...
echo #define SDL_REVISION 0 >"$(ProjectDir)\..\..\include\SDL_revision.h"
:SDLREVISIONOKAY
" /> <Tool Name="VCCustomBuildTool"
--- a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj Sun Jul 18 13:48:23 2010 -0400 @@ -105,6 +105,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 04AB757011E563D200BE9753 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */; + remoteInfo = testsdl; + }; FD1B489D0E313154007AB34E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */; @@ -318,6 +325,7 @@ isa = PBXGroup; children = ( FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */, + 04AB757111E563D200BE9753 /* testsdl.app */, ); name = Products; sourceTree = "<group>"; @@ -523,6 +531,13 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ + 04AB757111E563D200BE9753 /* testsdl.app */ = { + isa = PBXReferenceProxy; + fileType = wrapper.application; + path = testsdl.app; + remoteRef = 04AB757011E563D200BE9753 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -731,7 +746,7 @@ OTHER_CFLAGS = ""; PREBINDING = NO; PRELINK_LIBS = ""; - SDKROOT = iphoneos2.0; + SDKROOT = iphoneos3.2; }; name = Debug; }; @@ -749,7 +764,7 @@ OTHER_CFLAGS = ""; PREBINDING = NO; PRELINK_LIBS = ""; - SDKROOT = iphoneos2.0; + SDKROOT = iphoneos3.2; }; name = Release; };
--- a/Xcode-iPhoneOS/Demos/src/fireworks.c Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/Demos/src/fireworks.c Sun Jul 18 13:48:23 2010 -0400 @@ -430,9 +430,7 @@ done = 1; } if (event.type == SDL_MOUSEBUTTONDOWN) { - int which = event.button.which; int x, y; - SDL_SelectMouse(which); SDL_GetMouseState(&x, &y); spawnEmitterParticle(x, y); }
--- a/Xcode-iPhoneOS/Demos/src/mixer.c Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/Demos/src/mixer.c Sun Jul 18 13:48:23 2010 -0400 @@ -124,10 +124,9 @@ int x, y, mouseIndex, i, drumIndex; - mouseIndex = event->button.which; + mouseIndex = 0; drumIndex = -1; - SDL_SelectMouse(mouseIndex); SDL_GetMouseState(&x, &y); /* check if we hit any of the drum buttons */ for (i = 0; i < NUM_DRUMS; i++) { @@ -153,7 +152,7 @@ handleMouseButtonUp(SDL_Event * event) { int i; - int mouseIndex = event->button.which; + int mouseIndex = 0; /* check if this should cause any of the buttons to become unpressed */ for (i = 0; i < NUM_DRUMS; i++) { if (buttons[i].touchIndex == mouseIndex) {
--- a/Xcode-iPhoneOS/Demos/src/touch.c Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/Demos/src/touch.c Sun Jul 18 13:48:23 2010 -0400 @@ -106,7 +106,6 @@ done = 1; break; case SDL_MOUSEMOTION: - SDL_SelectMouse(event.motion.which); /* select 'mouse' (touch) that moved */ state = SDL_GetMouseState(&x, &y); /* get its location */ SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */ if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Sun Jul 18 13:48:23 2010 -0400 @@ -62,11 +62,16 @@ 0098A5631195B4D900343137 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5621195B4D900343137 /* OpenGLES.framework */; }; 0098A5651195B4D900343137 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5641195B4D900343137 /* UIKit.framework */; }; 0098A5851195B5E200343137 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5841195B5E200343137 /* QuartzCore.framework */; }; + 0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; }; + 0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; }; 043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */; }; 043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */; }; 043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */; }; 043DD77210FD8A0000DED673 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */; }; 04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04461DED0EA76BA3006C462D /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; }; + 044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; }; + 044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 044E5FB711E606EB0076F181 /* SDL_clipboard.c */; }; 0463873F0F0B5B7D0041FD65 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387370F0B5B7D0041FD65 /* SDL_blendline.c */; }; 046387400F0B5B7D0041FD65 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */; }; 046387410F0B5B7D0041FD65 /* SDL_blendrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387390F0B5B7D0041FD65 /* SDL_blendrect.c */; }; @@ -308,11 +313,16 @@ 0098A5621195B4D900343137 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 0098A5641195B4D900343137 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 0098A5841195B5E200343137 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; }; + 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; }; 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; }; 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = "<group>"; }; 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; }; 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; }; 04461DED0EA76BA3006C462D /* SDL_haptic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_haptic.h; path = ../../include/SDL_haptic.h; sourceTree = SOURCE_ROOT; }; + 044E5FB311E6069F0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; }; + 044E5FB411E6069F0076F181 /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; }; + 044E5FB711E606EB0076F181 /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; }; 046387370F0B5B7D0041FD65 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = "<group>"; }; 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = "<group>"; }; 046387390F0B5B7D0041FD65 /* SDL_blendrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendrect.c; sourceTree = "<group>"; }; @@ -826,19 +836,23 @@ FD99B8BC0DD52E5C00FB1D6B /* Public Headers */ = { isa = PBXGroup; children = ( - 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */, - 04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */, FD99B8CC0DD52EB400FB1D6B /* begin_code.h */, FD99B8CD0DD52EB400FB1D6B /* close_code.h */, + FD99B8F50DD52EB400FB1D6B /* SDL.h */, + 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */, + 04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */, FD99B8CF0DD52EB400FB1D6B /* SDL_audio.h */, + 044E5FB311E6069F0076F181 /* SDL_clipboard.h */, FD99B8D10DD52EB400FB1D6B /* SDL_compat.h */, + 04B2ED061025CF9E00F9BC5F /* SDL_config.h */, 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */, - 04B2ED061025CF9E00F9BC5F /* SDL_config.h */, FD99B8DA0DD52EB400FB1D6B /* SDL_copying.h */, FD99B8DB0DD52EB400FB1D6B /* SDL_cpuinfo.h */, + FD99B8F60DD52EB400FB1D6B /* SDL_endian.h */, FD99B8DC0DD52EB400FB1D6B /* SDL_error.h */, FD99B8DD0DD52EB400FB1D6B /* SDL_events.h */, 04461DED0EA76BA3006C462D /* SDL_haptic.h */, + 044E5FB411E6069F0076F181 /* SDL_input.h */, FD99B8DE0DD52EB400FB1D6B /* SDL_joystick.h */, FD99B8DF0DD52EB400FB1D6B /* SDL_keyboard.h */, FD99B8E00DD52EB400FB1D6B /* SDL_keysym.h */, @@ -865,8 +879,6 @@ FD99B8F20DD52EB400FB1D6B /* SDL_types.h */, FD99B8F30DD52EB400FB1D6B /* SDL_version.h */, FD99B8F40DD52EB400FB1D6B /* SDL_video.h */, - FD99B8F50DD52EB400FB1D6B /* SDL.h */, - FD99B8F60DD52EB400FB1D6B /* SDL_endian.h */, ); name = "Public Headers"; sourceTree = "<group>"; @@ -950,6 +962,8 @@ FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */, FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */, FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */, + 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */, + 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */, FD99B9930DD52EDC00FB1D6B /* SDL_events.c */, FD99B9940DD52EDC00FB1D6B /* SDL_events_c.h */, FD99B9950DD52EDC00FB1D6B /* SDL_keyboard.c */, @@ -1023,6 +1037,7 @@ FDA682420DF2374D00F98A1A /* video */ = { isa = PBXGroup; children = ( + 044E5FB711E606EB0076F181 /* SDL_clipboard.c */, FD689F090E26E5D900F90B21 /* uikit */, FDA685F40DF244C800F98A1A /* dummy */, 0495E6850E97408800152DFE /* SDL_glfuncs.h */, @@ -1173,6 +1188,9 @@ 043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */, 04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */, 006E9888119552DD001DE610 /* SDL_rwopsbundlesupport.h in Headers */, + 044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */, + 044E5FB611E6069F0076F181 /* SDL_input.h in Headers */, + 0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1411,6 +1429,8 @@ 56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */, 56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */, 006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */, + 044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */, + 0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };
--- a/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj Sun Jul 18 13:48:23 2010 -0400 @@ -287,6 +287,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */; + remoteInfo = testsdl; + }; FD1B48B70E3131CA007AB34E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */; @@ -298,9 +305,7 @@ /* Begin PBXFileReference section */ 1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "testpower-Info.plist"; sourceTree = "<group>"; }; 56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 56ED050F118A8FE400A56AA6 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; }; 56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; }; FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDLiPhoneOS.xcodeproj; path = ../SDL/SDLiPhoneOS.xcodeproj; sourceTree = SOURCE_ROOT; }; FDA8A7400E2D0F1600EA573E /* testalpha.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testalpha.c; path = ../../test/testalpha.c; sourceTree = SOURCE_ROOT; }; @@ -861,14 +866,11 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( - 56ED0510118A904200A56AA6 /* testpower.c */, FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */, FDA8AAD60E2D339A00EA573E /* Resources */, FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */, FDA8A73B0E2D0F0400EA573E /* src */, 19C28FACFE9D520D11CA2CBB /* Products */, - 56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */, - 56ED050F118A8FE400A56AA6 /* Info copy.plist */, ); name = CustomTemplate; sourceTree = "<group>"; @@ -877,6 +879,7 @@ isa = PBXGroup; children = ( FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */, + 0466EE7011E565E4000198A4 /* testsdl.app */, ); name = Products; sourceTree = "<group>"; @@ -910,6 +913,7 @@ FDA8A7540E2D0F1600EA573E /* testoverlay2.c */, FDA8A7550E2D0F1600EA573E /* testpalette.c */, FDA8A7560E2D0F1600EA573E /* testplatform.c */, + 56ED0510118A904200A56AA6 /* testpower.c */, FDA8A7570E2D0F1600EA573E /* testsem.c */, FDA8A7580E2D0F1600EA573E /* testsprite.c */, FDA8A7590E2D0F1600EA573E /* testsprite2.c */, @@ -1502,6 +1506,13 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ + 0466EE7011E565E4000198A4 /* testsdl.app */ = { + isa = PBXReferenceProxy; + fileType = wrapper.application; + path = testsdl.app; + remoteRef = 0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -2034,7 +2045,7 @@ ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; - SDKROOT = iphoneos2.2.1; + SDKROOT = iphoneos3.2; }; name = Debug; }; @@ -2049,7 +2060,7 @@ HEADER_SEARCH_PATHS = ../../include; PREBINDING = NO; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; - SDKROOT = iphoneos2.2.1; + SDKROOT = iphoneos3.2; }; name = Release; };
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj Tue Jul 13 15:05:45 2010 -0400 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj Sun Jul 18 13:48:23 2010 -0400 @@ -438,6 +438,24 @@ 00D8DA281195093100638393 /* SDL_at.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA151195093100638393 /* SDL_at.c */; }; 00D8DA291195093100638393 /* surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA181195093100638393 /* surface.c */; }; 00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; }; + 0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; }; + 0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; }; + 0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; }; + 0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; }; + 0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; }; + 0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; }; + 0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; }; + 0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; }; + 0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; }; + 0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; }; + 0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; }; + 0420498111E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; }; + 0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; }; + 0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; }; + 0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; }; + 0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; }; + 044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; }; 046B91EC0A11B53500FB151C /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B91E90A11B53500FB151C /* SDL_sysloadso.c */; }; 046B91ED0A11B53500FB151C /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B91E90A11B53500FB151C /* SDL_sysloadso.c */; }; 046B92130A11B8AD00FB151C /* SDL_dlcompat.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B92100A11B8AD00FB151C /* SDL_dlcompat.c */; }; @@ -446,9 +464,17 @@ 04DB838D10FD8C81000519B5 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */; }; 04DB838E10FD8C81000519B5 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838A10FD8C81000519B5 /* SDL_blendfillrect.c */; }; 04DB838F10FD8C81000519B5 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */; }; + 04DEA57111E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 04DEA57311E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; }; + 04DEA57511E6009000386CAC /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57411E6009000386CAC /* SDL_clipboard.c */; }; + 04DEA57611E6009000386CAC /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57411E6009000386CAC /* SDL_clipboard.c */; }; + 04DEA57911E600A600386CAC /* SDL_cocoaclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */; }; + 04DEA57A11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */; }; + 04DEA57B11E600A600386CAC /* SDL_cocoaclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */; }; + 04DEA57C11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */; }; 04F2AF661104AC0800D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF651104AC0800D6DDF7 /* SDL_assert.c */; }; 04F2AF671104AC0800D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF651104AC0800D6DDF7 /* SDL_assert.c */; }; - 04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; }; + 04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; }; 04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; }; BECDF62E0761BA81005FE872 /* SDL_audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 01538330006D78D67F000001 /* SDL_audio.c */; }; BECDF62F0761BA81005FE872 /* SDL_audiocvt.c in Sources */ = {isa = PBXBuildFile; fileRef = 01538331006D78D67F000001 /* SDL_audiocvt.c */; }; @@ -795,10 +821,23 @@ 01538439006D7D947F000001 /* SDL_fatal.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL_fatal.c; path = ../../src/SDL_fatal.c; sourceTree = SOURCE_ROOT; }; 0153843C006D7D947F000001 /* SDL.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL.c; path = ../../src/SDL.c; sourceTree = SOURCE_ROOT; }; 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; }; + 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; }; + 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; }; + 0420497411E6F052007E7EC9 /* blank_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blank_cursor.h; sourceTree = "<group>"; }; + 0420497511E6F052007E7EC9 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; }; + 0420497611E6F052007E7EC9 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; }; + 0420497711E6F052007E7EC9 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; }; + 0420497811E6F052007E7EC9 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; }; + 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; }; + 044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; }; 046B91E90A11B53500FB151C /* SDL_sysloadso.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_sysloadso.c; sourceTree = "<group>"; }; 046B92100A11B8AD00FB151C /* SDL_dlcompat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_dlcompat.c; sourceTree = "<group>"; }; 04DB838A10FD8C81000519B5 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; }; 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = "<group>"; }; + 04DEA56F11E6006A00386CAC /* SDL_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_input.h; path = ../../include/SDL_input.h; sourceTree = SOURCE_ROOT; }; + 04DEA57411E6009000386CAC /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = "<group>"; }; + 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaclipboard.h; sourceTree = "<group>"; }; + 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaclipboard.m; sourceTree = "<group>"; }; 04F2AF651104AC0800D6DDF7 /* SDL_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_assert.c; path = ../../src/SDL_assert.c; sourceTree = SOURCE_ROOT; }; 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert.h; path = ../../include/SDL_assert.h; sourceTree = SOURCE_ROOT; }; 083E489D006D88D97F000001 /* SDL_joystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_joystick.c; sourceTree = "<group>"; }; @@ -1033,6 +1072,8 @@ 00CFA703106B498A00758660 /* cocoa */ = { isa = PBXGroup; children = ( + 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */, + 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */, 00CFA704106B498A00758660 /* SDL_cocoaevents.h */, 00CFA705106B498A00758660 /* SDL_cocoaevents.m */, 00CFA706106B498A00758660 /* SDL_cocoakeyboard.h */, @@ -1312,6 +1353,14 @@ 01538367006D79147F000001 /* events */ = { isa = PBXGroup; children = ( + 0420497411E6F052007E7EC9 /* blank_cursor.h */, + 0420497511E6F052007E7EC9 /* default_cursor.h */, + 0420497611E6F052007E7EC9 /* scancodes_darwin.h */, + 0420497711E6F052007E7EC9 /* scancodes_linux.h */, + 0420497811E6F052007E7EC9 /* scancodes_win32.h */, + 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */, + 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */, + 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */, 00CFA6C2106B480800758660 /* SDL_events_c.h */, 01538369006D79147F000001 /* SDL_events.c */, 00CFA6C3106B480800758660 /* SDL_keyboard_c.h */, @@ -1380,6 +1429,7 @@ 00CFA7FA106B49B600758660 /* SDL_blit.c */, 00CFA7FB106B49B600758660 /* SDL_blit.h */, 00CFA7FC106B49B600758660 /* SDL_bmp.c */, + 04DEA57411E6009000386CAC /* SDL_clipboard.c */, 00CFA7FD106B49B600758660 /* SDL_draw.h */, 00CFA7FE106B49B600758660 /* SDL_drawline.c */, 00CFA7FF106B49B600758660 /* SDL_drawpoint.c */, @@ -1420,12 +1470,13 @@ 0153844A006D81B07F000001 /* Public Headers */ = { isa = PBXGroup; children = ( - 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */, 0C5AF5E501191D2B7F000001 /* begin_code.h */, 0C5AF5E601191D2B7F000001 /* close_code.h */, 0C5AF5FF01191D2B7F000001 /* SDL.h */, + 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */, 00CFA67A106B44CE00758660 /* SDL_atomic.h */, 0C5AF5E801191D2B7F000001 /* SDL_audio.h */, + 044E5F8411E6051C0076F181 /* SDL_clipboard.h */, 00CFA67B106B44CE00758660 /* SDL_compat.h */, 00162D3709BD1FA90037C8D0 /* SDL_config.h */, 00162D3409BD1FA90037C8D0 /* SDL_config_macosx.h */, @@ -1435,6 +1486,7 @@ 0C5AF5ED01191D2B7F000001 /* SDL_error.h */, 0C5AF5EE01191D2B7F000001 /* SDL_events.h */, 00CFA67C106B44CE00758660 /* SDL_haptic.h */, + 04DEA56F11E6006A00386CAC /* SDL_input.h */, 0C5AF5F001191D2B7F000001 /* SDL_joystick.h */, 0C5AF5F101191D2B7F000001 /* SDL_keyboard.h */, 0C5AF5F201191D2B7F000001 /* SDL_keysym.h */, @@ -1743,6 +1795,16 @@ 00A6EBDA1078D569001EEA06 /* SDL_revision.h in Headers */, 04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */, 006E95B011952992001DE610 /* SDL_rwopsbundlesupport.h in Headers */, + 04DEA57111E6006A00386CAC /* SDL_input.h in Headers */, + 04DEA57911E600A600386CAC /* SDL_cocoaclipboard.h in Headers */, + 044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */, + 0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */, + 0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */, + 0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */, + 0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */, + 0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */, + 0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */, + 0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1843,6 +1905,16 @@ 00A6EBDB1078D569001EEA06 /* SDL_revision.h in Headers */, 04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */, 006E95B211952992001DE610 /* SDL_rwopsbundlesupport.h in Headers */, + 04DEA57311E6006A00386CAC /* SDL_input.h in Headers */, + 04DEA57B11E600A600386CAC /* SDL_cocoaclipboard.h in Headers */, + 044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */, + 0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */, + 0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */, + 0420498111E6F052007E7EC9 /* default_cursor.h in Headers */, + 0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */, + 0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */, + 0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */, + 0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2035,7 +2107,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - 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"; + 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"; }; 0083103E1072EA5700A531F1 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -2202,6 +2274,9 @@ 04DB838D10FD8C81000519B5 /* SDL_drawrect.c in Sources */, 04F2AF661104AC0800D6DDF7 /* SDL_assert.c in Sources */, 006E95B111952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */, + 04DEA57511E6009000386CAC /* SDL_clipboard.c in Sources */, + 04DEA57A11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */, + 0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2318,6 +2393,9 @@ 04DB838F10FD8C81000519B5 /* SDL_drawrect.c in Sources */, 04F2AF671104AC0800D6DDF7 /* SDL_assert.c in Sources */, 006E95B311952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */, + 04DEA57611E6009000386CAC /* SDL_clipboard.c in Sources */, + 04DEA57C11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */, + 0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };
--- a/include/SDL.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL.h Sun Jul 18 13:48:23 2010 -0400 @@ -78,6 +78,7 @@ #include "SDL_stdinc.h" #include "SDL_atomic.h" #include "SDL_audio.h" +#include "SDL_clipboard.h" #include "SDL_cpuinfo.h" #include "SDL_endian.h" #include "SDL_error.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/SDL_clipboard.h Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,76 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * \file SDL_clipboard.h + * + * Include file for SDL clipboard handling + */ + +#ifndef _SDL_clipboard_h +#define _SDL_clipboard_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/* Function prototypes */ + +/** + * \brief Put UTF-8 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * \brief Returns whether the clipboard has text + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/include/SDL_config_iphoneos.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL_config_iphoneos.h Sun Jul 18 13:48:23 2010 -0400 @@ -145,12 +145,9 @@ #define SDL_POWER_UIKIT 1 /* enable iPhone keyboard support */ -#define SDL_IPHONE_KEYBOARD 0 +#define SDL_IPHONE_KEYBOARD 1 -/* Enable emulation of multiple mice through multi-touch */ -#define SDL_IPHONE_MULTIPLE_MICE 1 - -/* Set max recognized G-force from acceleromter +/* Set max recognized G-force from accelerometer See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed */ #define SDL_IPHONE_MAX_GFORCE 5.0
--- a/include/SDL_events.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL_events.h Sun Jul 18 13:48:23 2010 -0400 @@ -90,6 +90,9 @@ SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ SDL_JOYBUTTONUP, /**< Joystick button released */ + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */ + /* Obsolete events */ SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */ SDL_EVENT_COMPAT2,
--- a/include/SDL_pixels.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL_pixels.h Sun Jul 18 13:48:23 2010 -0400 @@ -112,8 +112,7 @@ SDL_PACKEDLAYOUT_1010102 }; -#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \ - ((A) | ((B) << 8) | ((C) << 16) | ((D) << 24)) +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
--- a/include/SDL_stdinc.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL_stdinc.h Sun Jul 18 13:48:23 2010 -0400 @@ -1,788 +1,795 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * \file SDL_stdinc.h - * - * This is a general header that includes C language support. - */ - -#ifndef _SDL_stdinc_h -#define _SDL_stdinc_h - -#include "SDL_config.h" - - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_STDIO_H -#include <stdio.h> -#endif -#if defined(STDC_HEADERS) -# include <stdlib.h> -# include <stddef.h> -# include <stdarg.h> -#else -# if defined(HAVE_STDLIB_H) -# include <stdlib.h> -# elif defined(HAVE_MALLOC_H) -# include <malloc.h> -# endif -# if defined(HAVE_STDDEF_H) -# include <stddef.h> -# endif -# if defined(HAVE_STDARG_H) -# include <stdarg.h> -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -# include <memory.h> -# endif -# include <string.h> -#endif -#ifdef HAVE_STRINGS_H -# include <strings.h> -#endif -#if defined(HAVE_INTTYPES_H) -# include <inttypes.h> -#elif defined(HAVE_STDINT_H) -# include <stdint.h> -#endif -#ifdef HAVE_CTYPE_H -# include <ctype.h> -#endif -#ifdef HAVE_MATH_H -# include <math.h> -#endif -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -# include <iconv.h> -#endif - -/** - * The number of elements in an array. - */ -#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) -#define SDL_TABLESIZE(table) SDL_arraysize(table) - -/** - * \name Cast operators - * - * Use proper C++ casts when compiled as C++ to be compatible with the option - * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). - */ -/*@{*/ -#ifdef __cplusplus -#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression) -#define SDL_static_cast(type, expression) static_cast<type>(expression) -#else -#define SDL_reinterpret_cast(type, expression) ((type)(expression)) -#define SDL_static_cast(type, expression) ((type)(expression)) -#endif -/*@}*//*Cast operators*/ - -/** - * \name Basic data types - */ -/*@{*/ - -typedef enum -{ - SDL_FALSE = 0, - SDL_TRUE = 1 -} SDL_bool; - -/** - * \brief A signed 8-bit integer type. - */ -typedef int8_t Sint8; -/** - * \brief An unsigned 8-bit integer type. - */ -typedef uint8_t Uint8; -/** - * \brief A signed 16-bit integer type. - */ -typedef int16_t Sint16; -/** - * \brief An unsigned 16-bit integer type. - */ -typedef uint16_t Uint16; -/** - * \brief A signed 32-bit integer type. - */ -typedef int32_t Sint32; -/** - * \brief An unsigned 32-bit integer type. - */ -typedef uint32_t Uint32; - -#ifdef SDL_HAS_64BIT_TYPE -/** - * \brief A signed 64-bit integer type. - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32! - */ -typedef int64_t Sint64; -/** - * \brief An unsigned 64-bit integer type. - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32! - */ -typedef uint64_t Uint64; -#else -/* This is really just a hack to prevent the compiler from complaining */ -typedef Sint32 Sint64; -typedef Uint32 Uint64; -#endif - -/*@}*//*Basic data types*/ - - -#define SDL_COMPILE_TIME_ASSERT(name, x) \ - typedef int SDL_dummy_ ## name[(x) * 2 - 1] -/** \cond */ -#ifndef DOXYGEN_SHOULD_IGNORE_THIS -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); -#ifndef __NINTENDODS__ /* TODO: figure out why the following happens: - include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative - include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */ -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); -#endif -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ -/** \endcond */ - -/* Check to make sure enums are the size of ints, for structure packing. - For both Watcom C/C++ and Borland C/C++ the compiler option that makes - enums having the size of an int must be enabled. - This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). -*/ -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ -#ifdef __MWERKS__ -#pragma enumsalwaysint on -#endif - -/** \cond */ -#ifndef DOXYGEN_SHOULD_IGNORE_THIS -#ifndef __NINTENDODS__ /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ -typedef enum -{ - DUMMY_ENUM_VALUE -} SDL_DUMMY_ENUM; - -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); -#endif -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ -/** \endcond */ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -/* *INDENT-OFF* */ -extern "C" { -/* *INDENT-ON* */ -#endif - -#ifdef HAVE_MALLOC -#define SDL_malloc malloc -#else -extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); -#endif - -#ifdef HAVE_CALLOC -#define SDL_calloc calloc -#else -extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); -#endif - -#ifdef HAVE_REALLOC -#define SDL_realloc realloc -#else -extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); -#endif - -#ifdef HAVE_FREE -#define SDL_free free -#else -extern DECLSPEC void SDLCALL SDL_free(void *mem); -#endif - -#if defined(HAVE_ALLOCA) && !defined(alloca) -# if defined(HAVE_ALLOCA_H) -# include <alloca.h> -# elif defined(__GNUC__) -# define alloca __builtin_alloca -# elif defined(_MSC_VER) -# include <malloc.h> -# define alloca _alloca -# elif defined(__WATCOMC__) -# include <malloc.h> -# elif defined(__BORLANDC__) -# include <malloc.h> -# elif defined(__DMC__) -# include <stdlib.h> -# elif defined(__AIX__) -#pragma alloca -# elif defined(__MRC__) -void *alloca(unsigned); -# else -char *alloca(); -# endif -#endif -#ifdef HAVE_ALLOCA -#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) -#define SDL_stack_free(data) -#else -#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) -#define SDL_stack_free(data) SDL_free(data) -#endif - -#ifdef HAVE_GETENV -#define SDL_getenv getenv -#else -extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); -#endif - -/* SDL_putenv() has moved to SDL_compat. */ -#ifdef HAVE_SETENV -#define SDL_setenv setenv -#else -extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, - int overwrite); -#endif - -#ifdef HAVE_QSORT -#define SDL_qsort qsort -#else -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, - int (*compare) (const void *, - const void *)); -#endif - -#ifdef HAVE_ABS -#define SDL_abs abs -#else -#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) -#endif - -#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) -#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) - -#ifdef HAVE_CTYPE_H -#define SDL_isdigit(X) isdigit(X) -#define SDL_isspace(X) isspace(X) -#define SDL_toupper(X) toupper(X) -#define SDL_tolower(X) tolower(X) -#else -#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) -#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) -#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) -#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) -#endif - -#ifdef HAVE_MEMSET -#define SDL_memset memset -#else -extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); -#endif -#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) -#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) - -#if defined(__GNUC__) && defined(i386) -#define SDL_memset4(dst, val, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; stosl\n\t" \ - : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ - : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memset4 -#define SDL_memset4(dst, val, len) \ -do { \ - unsigned _count = (len); \ - unsigned _n = (_count + 3) / 4; \ - Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ - Uint32 _val = (val); \ - if (len == 0) break; \ - switch (_count % 4) { \ - case 0: do { *_p++ = _val; \ - case 3: *_p++ = _val; \ - case 2: *_p++ = _val; \ - case 1: *_p++ = _val; \ - } while ( --_n ); \ - } \ -} while(0) -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl\n\t" \ - "testb $2,%b4\n\t" \ - "je 1f\n\t" \ - "movsw\n" \ - "1:\ttestb $1,%b4\n\t" \ - "je 2f\n\t" \ - "movsb\n" \ - "2:" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy -#ifdef HAVE_MEMCPY -#define SDL_memcpy memcpy -#elif defined(HAVE_BCOPY) -#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) -#else -extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, - size_t len); -#endif -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy4(dst, src, len) \ -do { \ - int ecx, edi, esi; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl" \ - : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ - : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy4 -#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_revcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - char *dstp = SDL_static_cast(char *, dst); \ - char *srcp = SDL_static_cast(char *, src); \ - int n = (len); \ - if ( n >= 4 ) { \ - __asm__ __volatile__ ( \ - "std\n\t" \ - "rep ; movsl\n\t" \ - "cld\n\t" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (n >> 2), \ - "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ - : "memory" ); \ - } \ - switch (n & 3) { \ - case 3: dstp[2] = srcp[2]; \ - case 2: dstp[1] = srcp[1]; \ - case 1: dstp[0] = srcp[0]; \ - break; \ - default: \ - break; \ - } \ -} while(0) -#endif -#ifndef SDL_revcpy -extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src, - size_t len); -#endif - -#ifdef HAVE_MEMMOVE -#define SDL_memmove memmove -#elif defined(HAVE_BCOPY) -#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) -#else -#define SDL_memmove(dst, src, len) \ -do { \ - if ( dst < src ) { \ - SDL_memcpy(dst, src, len); \ - } else { \ - SDL_revcpy(dst, src, len); \ - } \ -} while(0) -#endif - -#ifdef HAVE_MEMCMP -#define SDL_memcmp memcmp -#else -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, - size_t len); -#endif - -#ifdef HAVE_STRLEN -#define SDL_strlen strlen -#else -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); -#endif - -#ifdef HAVE_WCSLEN -#define SDL_wcslen wcslen -#else -#if !defined(wchar_t) && defined(__NINTENDODS__) -#define wchar_t short /* TODO: figure out why libnds doesn't have this */ -#endif -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string); -#endif - -#ifdef HAVE_STRLCPY -#define SDL_strlcpy strlcpy -#else -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, - size_t maxlen); -#endif - +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * \file SDL_stdinc.h + * + * This is a general header that includes C language support. + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_STDIO_H +#include <stdio.h> +#endif +#if defined(STDC_HEADERS) +# include <stdlib.h> +# include <stddef.h> +# include <stdarg.h> +#else +# if defined(HAVE_STDLIB_H) +# include <stdlib.h> +# elif defined(HAVE_MALLOC_H) +# include <malloc.h> +# endif +# if defined(HAVE_STDDEF_H) +# include <stddef.h> +# endif +# if defined(HAVE_STDARG_H) +# include <stdarg.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#if defined(HAVE_INTTYPES_H) +# include <inttypes.h> +#elif defined(HAVE_STDINT_H) +# include <stdint.h> +#endif +#ifdef HAVE_CTYPE_H +# include <ctype.h> +#endif +#ifdef HAVE_MATH_H +# include <math.h> +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include <iconv.h> +#endif + +/** + * The number of elements in an array. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/*@{*/ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression) +#define SDL_static_cast(type, expression) static_cast<type>(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#endif +/*@}*//*Cast operators*/ + +/* Define a four character code as a Uint32 */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +/** + * \name Basic data types + */ +/*@{*/ + +typedef enum +{ + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +/** + * \brief A signed 8-bit integer type. + */ +typedef int8_t Sint8; +/** + * \brief An unsigned 8-bit integer type. + */ +typedef uint8_t Uint8; +/** + * \brief A signed 16-bit integer type. + */ +typedef int16_t Sint16; +/** + * \brief An unsigned 16-bit integer type. + */ +typedef uint16_t Uint16; +/** + * \brief A signed 32-bit integer type. + */ +typedef int32_t Sint32; +/** + * \brief An unsigned 32-bit integer type. + */ +typedef uint32_t Uint32; + +#ifdef SDL_HAS_64BIT_TYPE +/** + * \brief A signed 64-bit integer type. + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32! + */ +typedef int64_t Sint64; +/** + * \brief An unsigned 64-bit integer type. + * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32! + */ +typedef uint64_t Uint64; +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef Sint32 Sint64; +typedef Uint32 Uint64; +#endif + +/*@}*//*Basic data types*/ + + +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +#ifndef __NINTENDODS__ /* TODO: figure out why the following happens: + include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative + include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */ +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ +#ifdef __MWERKS__ +#pragma enumsalwaysint on +#endif + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#ifndef __NINTENDODS__ /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +#ifdef HAVE_MALLOC +#define SDL_malloc malloc +#else +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); +#endif + +#ifdef HAVE_CALLOC +#define SDL_calloc calloc +#else +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); +#endif + +#ifdef HAVE_REALLOC +#define SDL_realloc realloc +#else +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); +#endif + +#ifdef HAVE_FREE +#define SDL_free free +#else +extern DECLSPEC void SDLCALL SDL_free(void *mem); +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include <alloca.h> +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include <malloc.h> +# define alloca _alloca +# elif defined(__WATCOMC__) +# include <malloc.h> +# elif defined(__BORLANDC__) +# include <malloc.h> +# elif defined(__DMC__) +# include <stdlib.h> +# elif defined(__AIX__) +#pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +char *alloca(); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +#ifdef HAVE_GETENV +#define SDL_getenv getenv +#else +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); +#endif + +/* SDL_putenv() has moved to SDL_compat. */ +#ifdef HAVE_SETENV +#define SDL_setenv setenv +#else +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, + int overwrite); +#endif + +#ifdef HAVE_QSORT +#define SDL_qsort qsort +#else +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, + int (*compare) (const void *, + const void *)); +#endif + +#ifdef HAVE_ABS +#define SDL_abs abs +#else +#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) +#endif + +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +#ifdef HAVE_CTYPE_H +#define SDL_isdigit(X) isdigit(X) +#define SDL_isspace(X) isspace(X) +#define SDL_toupper(X) toupper(X) +#define SDL_tolower(X) tolower(X) +#else +#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) +#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) +#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) +#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) +#endif + +#ifdef HAVE_MEMSET +#define SDL_memset memset +#else +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); +#endif +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) + +#if defined(__GNUC__) && defined(i386) +#define SDL_memset4(dst, val, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; stosl\n\t" \ + : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memset4 +#define SDL_memset4(dst, val, len) \ +do { \ + unsigned _count = (len); \ + unsigned _n = (_count + 3) / 4; \ + Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ + Uint32 _val = (val); \ + if (len == 0) break; \ + switch (_count % 4) { \ + case 0: do { *_p++ = _val; \ + case 3: *_p++ = _val; \ + case 2: *_p++ = _val; \ + case 1: *_p++ = _val; \ + } while ( --_n ); \ + } \ +} while(0) +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl\n\t" \ + "testb $2,%b4\n\t" \ + "je 1f\n\t" \ + "movsw\n" \ + "1:\ttestb $1,%b4\n\t" \ + "je 2f\n\t" \ + "movsb\n" \ + "2:" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy +#ifdef HAVE_MEMCPY +#define SDL_memcpy memcpy +#elif defined(HAVE_BCOPY) +#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) +#else +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, + size_t len); +#endif +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy4(dst, src, len) \ +do { \ + int ecx, edi, esi; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl" \ + : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ + : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy4 +#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_revcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + char *dstp = SDL_static_cast(char *, dst); \ + char *srcp = SDL_static_cast(char *, src); \ + int n = (len); \ + if ( n >= 4 ) { \ + __asm__ __volatile__ ( \ + "std\n\t" \ + "rep ; movsl\n\t" \ + "cld\n\t" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (n >> 2), \ + "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ + : "memory" ); \ + } \ + switch (n & 3) { \ + case 3: dstp[2] = srcp[2]; \ + case 2: dstp[1] = srcp[1]; \ + case 1: dstp[0] = srcp[0]; \ + break; \ + default: \ + break; \ + } \ +} while(0) +#endif +#ifndef SDL_revcpy +extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src, + size_t len); +#endif + +#ifdef HAVE_MEMMOVE +#define SDL_memmove memmove +#elif defined(HAVE_BCOPY) +#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) +#else +#define SDL_memmove(dst, src, len) \ +do { \ + if ( dst < src ) { \ + SDL_memcpy(dst, src, len); \ + } else { \ + SDL_revcpy(dst, src, len); \ + } \ +} while(0) +#endif + +#ifdef HAVE_MEMCMP +#define SDL_memcmp memcmp +#else +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, + size_t len); +#endif + +#ifdef HAVE_STRLEN +#define SDL_strlen strlen +#else +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); +#endif + +#ifdef HAVE_WCSLEN +#define SDL_wcslen wcslen +#else +#if !defined(wchar_t) && defined(__NINTENDODS__) +#define wchar_t short /* TODO: figure out why libnds doesn't have this */ +#endif +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string); +#endif + +#ifdef HAVE_STRLCPY +#define SDL_strlcpy strlcpy +#else +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, + size_t maxlen); +#endif + extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes); - -#ifdef HAVE_STRLCAT -#define SDL_strlcat strlcat -#else -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, - size_t maxlen); -#endif - -#ifdef HAVE_STRDUP -#define SDL_strdup strdup -#else -extern DECLSPEC char *SDLCALL SDL_strdup(const char *string); -#endif - -#ifdef HAVE__STRREV -#define SDL_strrev _strrev -#else -extern DECLSPEC char *SDLCALL SDL_strrev(char *string); -#endif - -#ifdef HAVE__STRUPR -#define SDL_strupr _strupr -#else -extern DECLSPEC char *SDLCALL SDL_strupr(char *string); -#endif - -#ifdef HAVE__STRLWR -#define SDL_strlwr _strlwr -#else -extern DECLSPEC char *SDLCALL SDL_strlwr(char *string); -#endif - -#ifdef HAVE_STRCHR -#define SDL_strchr strchr -#elif defined(HAVE_INDEX) -#define SDL_strchr index -#else -extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c); -#endif - -#ifdef HAVE_STRRCHR -#define SDL_strrchr strrchr -#elif defined(HAVE_RINDEX) -#define SDL_strrchr rindex -#else -extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c); -#endif - -#ifdef HAVE_STRSTR -#define SDL_strstr strstr -#else -extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, - const char *needle); -#endif - -#ifdef HAVE_ITOA -#define SDL_itoa itoa -#else -#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) -#endif - -#ifdef HAVE__LTOA -#define SDL_ltoa _ltoa -#else -extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix); -#endif - -#ifdef HAVE__UITOA -#define SDL_uitoa _uitoa -#else -#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) -#endif - -#ifdef HAVE__ULTOA -#define SDL_ultoa _ultoa -#else -extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string, - int radix); -#endif - -#ifdef HAVE_STRTOL -#define SDL_strtol strtol -#else -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, - int base); -#endif - -#ifdef HAVE_STRTOUL -#define SDL_strtoul strtoul -#else -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, - char **endp, int base); -#endif - -#ifdef SDL_HAS_64BIT_TYPE - -#ifdef HAVE__I64TOA -#define SDL_lltoa _i64toa -#else -extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string, - int radix); -#endif - -#ifdef HAVE__UI64TOA -#define SDL_ulltoa _ui64toa -#else -extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string, - int radix); -#endif - -#ifdef HAVE_STRTOLL -#define SDL_strtoll strtoll -#else -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, - int base); -#endif - -#ifdef HAVE_STRTOULL -#define SDL_strtoull strtoull -#else -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, - int base); -#endif - -#endif /* SDL_HAS_64BIT_TYPE */ - -#ifdef HAVE_STRTOD -#define SDL_strtod strtod -#else -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); -#endif - -#ifdef HAVE_ATOI -#define SDL_atoi atoi -#else -#define SDL_atoi(X) SDL_strtol(X, NULL, 0) -#endif - -#ifdef HAVE_ATOF -#define SDL_atof atof -#else -#define SDL_atof(X) SDL_strtod(X, NULL) -#endif - -#ifdef HAVE_STRCMP -#define SDL_strcmp strcmp -#else -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); -#endif - -#ifdef HAVE_STRNCMP -#define SDL_strncmp strncmp -#else -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, - size_t maxlen); -#endif - -#ifdef HAVE_STRCASECMP -#define SDL_strcasecmp strcasecmp -#elif defined(HAVE__STRICMP) -#define SDL_strcasecmp _stricmp -#else -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, - const char *str2); -#endif - -#ifdef HAVE_STRNCASECMP -#define SDL_strncasecmp strncasecmp -#elif defined(HAVE__STRNICMP) -#define SDL_strncasecmp _strnicmp -#else -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, - const char *str2, size_t maxlen); -#endif - -#ifdef HAVE_SSCANF -#define SDL_sscanf sscanf -#else -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, - ...); -#endif - -#ifdef HAVE_SNPRINTF -#define SDL_snprintf snprintf -#else -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, - const char *fmt, ...); -#endif - -#ifdef HAVE_VSNPRINTF -#define SDL_vsnprintf vsnprintf -#else -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, - const char *fmt, va_list ap); -#endif - -#ifndef HAVE_M_PI -#define M_PI 3.14159265358979323846264338327950288 /* pi */ -#endif - -#ifdef HAVE_CEIL -#define SDL_ceil ceil -#else -#define SDL_ceil(x) ((double)(int)((x)+0.5)) -#endif - -#ifdef HAVE_COPYSIGN -#define SDL_copysign copysign -#else -extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); -#endif - -#ifdef HAVE_COS -#define SDL_cos cos -#else -extern DECLSPEC double SDLCALL SDL_cos(double x); -#endif - -#ifdef HAVE_COSF -#define SDL_cosf cosf -#else -#define SDL_cosf(x) (float)SDL_cos((double)x) -#endif - -#ifdef HAVE_FABS -#define SDL_fabs fabs -#else -extern DECLSPEC double SDLCALL SDL_fabs(double x); -#endif - -#ifdef HAVE_FLOOR -#define SDL_floor floor -#else -extern DECLSPEC double SDLCALL SDL_floor(double x); -#endif - -#ifdef HAVE_LOG -#define SDL_log log -#else -extern DECLSPEC double SDLCALL SDL_log(double x); -#endif - -#ifdef HAVE_POW -#define SDL_pow pow -#else -extern DECLSPEC double SDLCALL SDL_pow(double x, double y); -#endif - -#ifdef HAVE_SCALBN -#define SDL_scalbn scalbn -#else -extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); -#endif - -#ifdef HAVE_SIN -#define SDL_sin sin -#else -extern DECLSPEC double SDLCALL SDL_sin(double x); -#endif - -#ifdef HAVE_SINF -#define SDL_sinf sinf -#else -#define SDL_sinf(x) (float)SDL_sin((double)x) -#endif - -#ifdef HAVE_SQRT -#define SDL_sqrt sqrt -#else -extern DECLSPEC double SDLCALL SDL_sqrt(double x); -#endif - -/* The SDL implementation of iconv() returns these error codes */ -#define SDL_ICONV_ERROR (size_t)-1 -#define SDL_ICONV_E2BIG (size_t)-2 -#define SDL_ICONV_EILSEQ (size_t)-3 -#define SDL_ICONV_EINVAL (size_t)-4 - -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -#define SDL_iconv_t iconv_t -#define SDL_iconv_open iconv_open -#define SDL_iconv_close iconv_close -#else -typedef struct _SDL_iconv_t *SDL_iconv_t; -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, - const char *fromcode); -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); -#endif -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, - size_t * inbytesleft, char **outbuf, - size_t * outbytesleft); -/** - * This function converts a string between encodings in one pass, returning a - * string that must be freed with SDL_free() or NULL on error. - */ -extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, - const char *fromcode, - const char *inbuf, - size_t inbytesleft); -#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -/* *INDENT-OFF* */ -} -/* *INDENT-ON* */ -#endif -#include "close_code.h" - -#endif /* _SDL_stdinc_h */ - -/* vi: set ts=4 sw=4 expandtab: */ + +#ifdef HAVE_STRLCAT +#define SDL_strlcat strlcat +#else +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, + size_t maxlen); +#endif + +#ifdef HAVE_STRDUP +#define SDL_strdup strdup +#else +extern DECLSPEC char *SDLCALL SDL_strdup(const char *string); +#endif + +#ifdef HAVE__STRREV +#define SDL_strrev _strrev +#else +extern DECLSPEC char *SDLCALL SDL_strrev(char *string); +#endif + +#ifdef HAVE__STRUPR +#define SDL_strupr _strupr +#else +extern DECLSPEC char *SDLCALL SDL_strupr(char *string); +#endif + +#ifdef HAVE__STRLWR +#define SDL_strlwr _strlwr +#else +extern DECLSPEC char *SDLCALL SDL_strlwr(char *string); +#endif + +#ifdef HAVE_STRCHR +#define SDL_strchr strchr +#elif defined(HAVE_INDEX) +#define SDL_strchr index +#else +extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c); +#endif + +#ifdef HAVE_STRRCHR +#define SDL_strrchr strrchr +#elif defined(HAVE_RINDEX) +#define SDL_strrchr rindex +#else +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c); +#endif + +#ifdef HAVE_STRSTR +#define SDL_strstr strstr +#else +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, + const char *needle); +#endif + +#ifdef HAVE_ITOA +#define SDL_itoa itoa +#else +#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) +#endif + +#ifdef HAVE__LTOA +#define SDL_ltoa _ltoa +#else +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix); +#endif + +#ifdef HAVE__UITOA +#define SDL_uitoa _uitoa +#else +#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) +#endif + +#ifdef HAVE__ULTOA +#define SDL_ultoa _ultoa +#else +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string, + int radix); +#endif + +#ifdef HAVE_STRTOL +#define SDL_strtol strtol +#else +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, + int base); +#endif + +#ifdef HAVE_STRTOUL +#define SDL_strtoul strtoul +#else +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, + char **endp, int base); +#endif + +#ifdef SDL_HAS_64BIT_TYPE + +#ifdef HAVE__I64TOA +#define SDL_lltoa _i64toa +#else +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string, + int radix); +#endif + +#ifdef HAVE__UI64TOA +#define SDL_ulltoa _ui64toa +#else +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string, + int radix); +#endif + +#ifdef HAVE_STRTOLL +#define SDL_strtoll strtoll +#else +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, + int base); +#endif + +#ifdef HAVE_STRTOULL +#define SDL_strtoull strtoull +#else +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, + int base); +#endif + +#endif /* SDL_HAS_64BIT_TYPE */ + +#ifdef HAVE_STRTOD +#define SDL_strtod strtod +#else +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); +#endif + +#ifdef HAVE_ATOI +#define SDL_atoi atoi +#else +#define SDL_atoi(X) SDL_strtol(X, NULL, 0) +#endif + +#ifdef HAVE_ATOF +#define SDL_atof atof +#else +#define SDL_atof(X) SDL_strtod(X, NULL) +#endif + +#ifdef HAVE_STRCMP +#define SDL_strcmp strcmp +#else +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCMP +#define SDL_strncmp strncmp +#else +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, + size_t maxlen); +#endif + +#ifdef HAVE_STRCASECMP +#define SDL_strcasecmp strcasecmp +#elif defined(HAVE__STRICMP) +#define SDL_strcasecmp _stricmp +#else +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, + const char *str2); +#endif + +#ifdef HAVE_STRNCASECMP +#define SDL_strncasecmp strncasecmp +#elif defined(HAVE__STRNICMP) +#define SDL_strncasecmp _strnicmp +#else +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, + const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_SSCANF +#define SDL_sscanf sscanf +#else +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, + ...); +#endif + +#ifdef HAVE_SNPRINTF +#define SDL_snprintf snprintf +#else +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, + const char *fmt, ...); +#endif + +#ifdef HAVE_VSNPRINTF +#define SDL_vsnprintf vsnprintf +#else +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, + const char *fmt, va_list ap); +#endif + +#ifndef HAVE_M_PI +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#endif + +#ifdef HAVE_CEIL +#define SDL_ceil ceil +#else +#define SDL_ceil(x) ((double)(int)((x)+0.5)) +#endif + +#ifdef HAVE_COPYSIGN +#define SDL_copysign copysign +#else +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); +#endif + +#ifdef HAVE_COS +#define SDL_cos cos +#else +extern DECLSPEC double SDLCALL SDL_cos(double x); +#endif + +#ifdef HAVE_COSF +#define SDL_cosf cosf +#else +#define SDL_cosf(x) (float)SDL_cos((double)x) +#endif + +#ifdef HAVE_FABS +#define SDL_fabs fabs +#else +extern DECLSPEC double SDLCALL SDL_fabs(double x); +#endif + +#ifdef HAVE_FLOOR +#define SDL_floor floor +#else +extern DECLSPEC double SDLCALL SDL_floor(double x); +#endif + +#ifdef HAVE_LOG +#define SDL_log log +#else +extern DECLSPEC double SDLCALL SDL_log(double x); +#endif + +#ifdef HAVE_POW +#define SDL_pow pow +#else +extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +#endif + +#ifdef HAVE_SCALBN +#define SDL_scalbn scalbn +#else +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); +#endif + +#ifdef HAVE_SIN +#define SDL_sin sin +#else +extern DECLSPEC double SDLCALL SDL_sin(double x); +#endif + +#ifdef HAVE_SINF +#define SDL_sinf sinf +#else +#define SDL_sinf(x) (float)SDL_sin((double)x) +#endif + +#ifdef HAVE_SQRT +#define SDL_sqrt sqrt +#else +extern DECLSPEC double SDLCALL SDL_sqrt(double x); +#endif + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +#define SDL_iconv_t iconv_t +#define SDL_iconv_open iconv_open +#define SDL_iconv_close iconv_close +#else +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +#endif +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); +/** + * This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/include/SDL_syswm.h Tue Jul 13 15:05:45 2010 -0400 +++ b/include/SDL_syswm.h Sun Jul 18 13:48:23 2010 -0400 @@ -106,24 +106,6 @@ { Display *display; /**< The X11 display */ Window window; /**< The X11 display window */ - /** - * These locking functions should be called around - * any X11 functions using the display variable. - * They lock the event thread, so should not be - * called around event functions or from event filters. - */ - /*@{*/ - void (*lock_func) (void); - void (*unlock_func) (void); - /*@}*/ - - /** - * Introduced in SDL 1.0.2. - */ - /*@{*/ - Window fswindow; /**< The X11 fullscreen window */ - Window wmwindow; /**< The X11 managed input window */ - /*@}*/ } x11; } info; }; @@ -231,7 +213,7 @@ /** * \brief This function allows access to driver-dependent window information. * - * \param windowID The window about which information is being requested + * \param window The window about which information is being requested * \param info This structure must be initialized with the SDL version, and is * then filled in with information about the given window. *
--- a/src/audio/SDL_audio.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/audio/SDL_audio.c Sun Jul 18 13:48:23 2010 -0400 @@ -287,6 +287,7 @@ } /* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */ +#if 0 static int SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) { @@ -305,6 +306,7 @@ return 0; } +#endif /* Deinitialize the stream simply by freeing the buffer */ static void
--- a/src/audio/SDL_audiodev.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/audio/SDL_audiodev.c Sun Jul 18 13:48:23 2010 -0400 @@ -28,6 +28,7 @@ #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> +#include <unistd.h> /* For close() */ #include "SDL_stdinc.h" #include "SDL_audiodev_c.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/events/SDL_clipboardevents.c Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,47 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Clipboard event handling code for SDL */ + +#include "SDL_events.h" +#include "SDL_events_c.h" +#include "SDL_clipboardevents_c.h" + + +int +SDL_SendClipboardUpdate(void) +{ + int posted; + + /* Post the event, if desired */ + posted = 0; + if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_CLIPBOARDUPDATE; + + posted = (SDL_PushEvent(&event) > 0); + } + return (posted); +} + +/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/events/SDL_clipboardevents_c.h Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,31 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_clipboardevents_c_h +#define _SDL_clipboardevents_c_h + +extern int SDL_SendClipboardUpdate(void); + +#endif /* _SDL_clipboardevents_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_keyboard.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/events/SDL_keyboard.c Sun Jul 18 13:48:23 2010 -0400 @@ -551,6 +551,10 @@ int SDL_KeyboardInit(void) { + SDL_Keyboard *keyboard = &SDL_keyboard; + + /* Set the default keymap */ + SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); return (0); } @@ -760,6 +764,11 @@ SDL_Keyboard *keyboard = &SDL_keyboard; int posted; + /* Don't post text events for unprintable characters */ + if (*text < ' ') { + return 0; + } + /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
--- a/src/events/scancodes_xfree86.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/events/scancodes_xfree86.h Sun Jul 18 13:48:23 2010 -0400 @@ -262,24 +262,24 @@ /* 81 */ SDL_SCANCODE_KP_3, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_PERIOD, - /* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */ - /* 85 */ SDL_SCANCODE_MODE, /* ???? */ + /* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */ + /* 85 */ SDL_SCANCODE_MODE, /* ???? */ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* 87 */ SDL_SCANCODE_F11, /* 88 */ SDL_SCANCODE_F12, /* 89 */ SDL_SCANCODE_UNKNOWN, - /* 90 */ SDL_SCANCODE_UNKNOWN, - /* 91 */ SDL_SCANCODE_UNKNOWN, - /* 92 */ SDL_SCANCODE_UNKNOWN, - /* 93 */ SDL_SCANCODE_UNKNOWN, - /* 94 */ SDL_SCANCODE_UNKNOWN, + /* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */ + /* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */ + /* 92 */ SDL_SCANCODE_UNKNOWN, /* Henkan_Mode */ + /* 93 */ SDL_SCANCODE_UNKNOWN, /* Hiragana_Katakana */ + /* 94 */ SDL_SCANCODE_UNKNOWN, /* Muhenkan */ /* 95 */ SDL_SCANCODE_UNKNOWN, - /* 96 */ SDL_SCANCODE_UNKNOWN, + /* 96 */ SDL_SCANCODE_KP_ENTER, /* 97 */ SDL_SCANCODE_RCTRL, /* 98 */ SDL_SCANCODE_KP_DIVIDE, - /* 99 */ SDL_SCANCODE_UNKNOWN, - /* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */ - /* 101 */ SDL_SCANCODE_UNKNOWN, + /* 99 */ SDL_SCANCODE_PRINTSCREEN, + /* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */ + /* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */ /* 102 */ SDL_SCANCODE_HOME, /* 103 */ SDL_SCANCODE_UP, /* 104 */ SDL_SCANCODE_PAGEUP, @@ -291,40 +291,132 @@ /* 110 */ SDL_SCANCODE_INSERT, /* 111 */ SDL_SCANCODE_DELETE, /* 112 */ SDL_SCANCODE_UNKNOWN, - /* 113 */ SDL_SCANCODE_UNKNOWN, - /* 114 */ SDL_SCANCODE_UNKNOWN, - /* 115 */ SDL_SCANCODE_UNKNOWN, - /* 116 */ SDL_SCANCODE_UNKNOWN, - /* 117 */ SDL_SCANCODE_UNKNOWN, - /* 118 */ SDL_SCANCODE_UNKNOWN, - /* 119 */ SDL_SCANCODE_UNKNOWN, - /* 120 */ SDL_SCANCODE_UNKNOWN, - /* 121 */ SDL_SCANCODE_PAUSE, - /* 122 */ SDL_SCANCODE_UNKNOWN, - /* 123 */ SDL_SCANCODE_UNKNOWN, + /* 113 */ SDL_SCANCODE_MUTE, + /* 114 */ SDL_SCANCODE_VOLUMEDOWN, + /* 115 */ SDL_SCANCODE_VOLUMEUP, + /* 116 */ SDL_SCANCODE_POWER, + /* 117 */ SDL_SCANCODE_KP_EQUALS, + /* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */ + /* 119 */ SDL_SCANCODE_PAUSE, + /* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */ + /* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */ + /* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */ + /* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */ /* 124 */ SDL_SCANCODE_UNKNOWN, - /* 125 */ SDL_SCANCODE_LGUI, - /* 126 */ SDL_SCANCODE_RGUI, - /* 127 */ SDL_SCANCODE_APPLICATION, - /* 128 */ SDL_SCANCODE_UNKNOWN, - /* 129 */ SDL_SCANCODE_UNKNOWN, - /* 130 */ SDL_SCANCODE_UNKNOWN, - /* 131 */ SDL_SCANCODE_UNKNOWN, - /* 132 */ SDL_SCANCODE_UNKNOWN, - /* 133 */ SDL_SCANCODE_UNKNOWN, - /* 134 */ SDL_SCANCODE_UNKNOWN, - /* 135 */ SDL_SCANCODE_UNKNOWN, - /* 136 */ SDL_SCANCODE_UNKNOWN, - /* 137 */ SDL_SCANCODE_UNKNOWN, - /* 138 */ SDL_SCANCODE_UNKNOWN, - /* 139 */ SDL_SCANCODE_UNKNOWN, - /* 140 */ SDL_SCANCODE_UNKNOWN, - /* 141 */ SDL_SCANCODE_UNKNOWN, - /* 142 */ SDL_SCANCODE_UNKNOWN, - /* 143 */ SDL_SCANCODE_UNKNOWN, - /* 144 */ SDL_SCANCODE_UNKNOWN, - /* 145 */ SDL_SCANCODE_UNKNOWN, - /* 146 */ SDL_SCANCODE_UNKNOWN, + /* 125 */ SDL_SCANCODE_LGUI, + /* 126 */ SDL_SCANCODE_RGUI, + /* 127 */ SDL_SCANCODE_APPLICATION, + /* 128 */ SDL_SCANCODE_CANCEL, + /* 129 */ SDL_SCANCODE_AGAIN, + /* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */ + /* 131 */ SDL_SCANCODE_UNDO, + /* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */ + /* 133 */ SDL_SCANCODE_COPY, + /* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */ + /* 135 */ SDL_SCANCODE_PASTE, + /* 136 */ SDL_SCANCODE_FIND, + /* 137 */ SDL_SCANCODE_CUT, + /* 138 */ SDL_SCANCODE_HELP, + /* 139 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */ + /* 140 */ SDL_SCANCODE_CALCULATOR, + /* 141 */ SDL_SCANCODE_UNKNOWN, + /* 142 */ SDL_SCANCODE_SLEEP, + /* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */ + /* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */ + /* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ + /* 146 */ SDL_SCANCODE_UNKNOWN, + /* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */ + /* 148 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch1 */ + /* 149 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch2 */ + /* 150 */ SDL_SCANCODE_WWW, + /* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */ + /* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */ + /* 153 */ SDL_SCANCODE_UNKNOWN, + /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ + /* 155 */ SDL_SCANCODE_MAIL, + /* 156 */ SDL_SCANCODE_UNKNOWN, /* XF86Favorites */ + /* 157 */ SDL_SCANCODE_COMPUTER, + /* 158 */ SDL_SCANCODE_AC_BACK, + /* 159 */ SDL_SCANCODE_AC_FORWARD, + /* 160 */ SDL_SCANCODE_UNKNOWN, + /* 161 */ SDL_SCANCODE_EJECT, + /* 162 */ SDL_SCANCODE_EJECT, + /* 163 */ SDL_SCANCODE_AUDIONEXT, + /* 164 */ SDL_SCANCODE_AUDIOPLAY, + /* 165 */ SDL_SCANCODE_AUDIOPREV, + /* 166 */ SDL_SCANCODE_AUDIOSTOP, + /* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */ + /* 168 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRewind */ + /* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */ + /* 170 */ SDL_SCANCODE_UNKNOWN, + /* 171 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */ + /* 172 */ SDL_SCANCODE_AC_HOME, + /* 173 */ SDL_SCANCODE_AC_REFRESH, + /* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */ + /* 175 */ SDL_SCANCODE_UNKNOWN, + /* 176 */ SDL_SCANCODE_UNKNOWN, + /* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */ + /* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */ + /* 179 */ SDL_SCANCODE_UNKNOWN, /* parenleft */ + /* 180 */ SDL_SCANCODE_UNKNOWN, /* parenright */ + /* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */ + /* 182 */ SDL_SCANCODE_AGAIN, + /* 183 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */ + /* 184 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch5 */ + /* 185 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */ + /* 186 */ SDL_SCANCODE_UNKNOWN, + /* 187 */ SDL_SCANCODE_UNKNOWN, + /* 188 */ SDL_SCANCODE_UNKNOWN, + /* 189 */ SDL_SCANCODE_UNKNOWN, + /* 190 */ SDL_SCANCODE_UNKNOWN, + /* 191 */ SDL_SCANCODE_UNKNOWN, + /* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */ + /* 193 */ SDL_SCANCODE_UNKNOWN, + /* 194 */ SDL_SCANCODE_UNKNOWN, + /* 195 */ SDL_SCANCODE_MODE, + /* 196 */ SDL_SCANCODE_UNKNOWN, + /* 197 */ SDL_SCANCODE_UNKNOWN, + /* 198 */ SDL_SCANCODE_UNKNOWN, + /* 199 */ SDL_SCANCODE_UNKNOWN, + /* 200 */ SDL_SCANCODE_AUDIOPLAY, + /* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */ + /* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */ + /* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */ + /* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */ + /* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */ + /* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */ + /* 207 */ SDL_SCANCODE_AUDIOPLAY, + /* 208 */ SDL_SCANCODE_AUDIONEXT, + /* 209 */ SDL_SCANCODE_UNKNOWN, + /* 210 */ SDL_SCANCODE_PRINTSCREEN, + /* 211 */ SDL_SCANCODE_UNKNOWN, + /* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */ + /* 213 */ SDL_SCANCODE_UNKNOWN, + /* 214 */ SDL_SCANCODE_UNKNOWN, + /* 215 */ SDL_SCANCODE_MAIL, + /* 216 */ SDL_SCANCODE_UNKNOWN, + /* 217 */ SDL_SCANCODE_AC_SEARCH, + /* 218 */ SDL_SCANCODE_UNKNOWN, + /* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */ + /* 220 */ SDL_SCANCODE_UNKNOWN, + /* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */ + /* 222 */ SDL_SCANCODE_UNKNOWN, + /* 223 */ SDL_SCANCODE_STOP, + /* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN, + /* 225 */ SDL_SCANCODE_BRIGHTNESSUP, + /* 226 */ SDL_SCANCODE_MEDIASELECT, + /* 227 */ SDL_SCANCODE_DISPLAYSWITCH, + /* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE, + /* 229 */ SDL_SCANCODE_KBDILLUMDOWN, + /* 230 */ SDL_SCANCODE_KBDILLUMUP, + /* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ + /* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */ + /* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */ + /* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */ + /* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */ + /* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */ + /* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */ + /* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */ }; /* *INDENT-ON* */
--- a/src/haptic/linux/SDL_syshaptic.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/haptic/linux/SDL_syshaptic.c Sun Jul 18 13:48:23 2010 -0400 @@ -254,8 +254,6 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) { - const char *name; - /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata));
--- a/src/joystick/bsd/SDL_sysjoystick.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/joystick/bsd/SDL_sysjoystick.c Sun Jul 18 13:48:23 2010 -0400 @@ -59,7 +59,7 @@ #include <libusbhid.h> #endif -#ifdef __FREEBSD__ +#ifdef defined(__FREEBSD__) || defined(__FreeBSD_kernel__) #ifndef __DragonFly__ #include <osreldate.h> #endif @@ -78,7 +78,7 @@ #define MAX_JOY_JOYS 2 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) && false struct usb_ctl_report { int ucr_report; u_char ucr_data[1024]; /* filled data size will vary */ @@ -149,7 +149,7 @@ static int report_alloc(struct report *, struct report_desc *, int); static void report_free(struct report *); -#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) +#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__) #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) #else #define REP_BUF_DATA(rep) ((rep)->buf->data) @@ -308,7 +308,7 @@ goto usberr; } rep = &hw->inreport; -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) rep->rid = hid_get_report_id(fd); if (rep->rid < 0) { #else @@ -324,7 +324,7 @@ hw->path); goto usberr; } -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) +#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); @@ -409,7 +409,7 @@ int nbutton, naxe = -1; Sint32 v; -#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) struct joystick gameport; static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; @@ -466,7 +466,7 @@ if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { return; } -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) +#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
--- a/src/main/win32/SDL_win32_main.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/main/win32/SDL_win32_main.c Sun Jul 18 13:48:23 2010 -0400 @@ -71,6 +71,7 @@ ++argc; } /* Skip over word */ + lastp = bufp; while (*bufp && (*bufp != '"' || *lastp == '\\')) { lastp = bufp; ++bufp;
--- a/src/timer/SDL_systimer.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/timer/SDL_systimer.h Sun Jul 18 13:48:23 2010 -0400 @@ -38,4 +38,5 @@ /* Stop a previously started timer */ extern void SDL_SYS_StopTimer(void); + /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/unix/SDL_systimer.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/timer/unix/SDL_systimer.c Sun Jul 18 13:48:23 2010 -0400 @@ -31,6 +31,7 @@ #include <errno.h> #include "SDL_timer.h" +#include "../SDL_systimer.h" #include "../SDL_timer_c.h" /* The clock_gettime provides monotonous time, so we should use it if
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/SDL_clipboard.c Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,76 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_clipboard.h" +#include "SDL_sysvideo.h" + + +int +SDL_SetClipboardText(const char *text) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!text) { + text = ""; + } + if (_this->SetClipboardText) { + return _this->SetClipboardText(_this, text); + } else { + _this->clipboard_text = SDL_strdup(text); + return 0; + } +} + +char * +SDL_GetClipboardText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (_this->GetClipboardText) { + return _this->GetClipboardText(_this); + } else { + const char *text = _this->clipboard_text; + if (!text) { + text = ""; + } + return SDL_strdup(text); + } +} + +SDL_bool +SDL_HasClipboardText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (_this->HasClipboardText) { + return _this->HasClipboardText(_this); + } else { + if (_this->clipboard_text) { + return SDL_TRUE; + } else { + return SDL_FALSE; + } + } +} + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gles.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_renderer_gles.c Sun Jul 18 13:48:23 2010 -0400 @@ -822,20 +822,25 @@ maybe it'd be a good idea to keep a temp buffer around for this purpose rather than allocating it each time */ - temp_buffer = SDL_malloc(rect->w * rect->h * bpp); - temp_ptr = temp_buffer; - for (i = 0; i < rect->h; i++) { - SDL_memcpy(temp_ptr, pixels, rect->w * bpp); - temp_ptr += rect->w * bpp; - pixels += pitch; + if( rect->x == 0 && rect->w * bpp == pitch ) { + temp_buffer = pixels; /* Updating whole texture, no need to reformat */ + } else { + temp_buffer = SDL_malloc(rect->w * rect->h * bpp); + temp_ptr = temp_buffer; + for (i = 0; i < rect->h; i++) { + SDL_memcpy(temp_ptr, pixels, rect->w * bpp); + temp_ptr += rect->w * bpp; + pixels += pitch; + } } data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, rect->w, rect->h, texturedata->format, texturedata->formattype, temp_buffer); - SDL_free(temp_buffer); - + if( temp_buffer != pixels ) { + SDL_free(temp_buffer); + } } SDL_ClearDirtyRects(&texturedata->dirty); }
--- a/src/video/SDL_renderer_sw.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_renderer_sw.c Sun Jul 18 13:48:23 2010 -0400 @@ -795,7 +795,6 @@ const SDL_Rect * srcrect, const SDL_Rect * dstrect) { SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; int status; if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
--- a/src/video/SDL_stretch.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_stretch.c Sun Jul 18 13:48:23 2010 -0400 @@ -80,7 +80,7 @@ int i; int pos, inc; - unsigned char *eip; + unsigned char *eip, *fence; unsigned char load, store; /* See if we need to regenerate the copy buffer */ @@ -116,14 +116,21 @@ pos = 0x10000; inc = (src_w << 16) / dst_w; eip = copy_row; + fence = copy_row + sizeof(copy_row)-2; for (i = 0; i < dst_w; ++i) { while (pos >= 0x10000L) { + if (eip == fence) { + return -1; + } if (bpp == 2) { *eip++ = PREFIX16; } *eip++ = load; pos -= 0x10000L; } + if (eip == fence) { + return -1; + } if (bpp == 2) { *eip++ = PREFIX16; } @@ -132,11 +139,6 @@ } *eip++ = RETURN; - /* Verify that we didn't overflow (too late!!!) */ - if (eip > (copy_row + sizeof(copy_row))) { - SDL_SetError("Copy buffer overflow"); - return (-1); - } #ifdef HAVE_MPROTECT /* Make the code executable but not writeable */ if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) {
--- a/src/video/SDL_surface.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_surface.c Sun Jul 18 13:48:23 2010 -0400 @@ -851,7 +851,7 @@ /* Enable alpha blending by default if the new surface has an * alpha channel or alpha modulation */ if ((surface->format->Amask && format->Amask) || - (copy_flags & SDL_COPY_MODULATE_ALPHA)) { + (copy_flags & (SDL_COPY_COLORKEY|SDL_COPY_MODULATE_ALPHA))) { SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND); } if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
--- a/src/video/SDL_sysvideo.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_sysvideo.h Sun Jul 18 13:48:23 2010 -0400 @@ -303,6 +303,11 @@ void (*StopTextInput) (_THIS); void (*SetTextInputRect) (_THIS, SDL_Rect *rect); + /* Clipboard */ + int (*SetClipboardText) (_THIS, const char *text); + char * (*GetClipboardText) (_THIS); + SDL_bool (*HasClipboardText) (_THIS); + /* * * */ /* Data common to all drivers */ SDL_bool suspend_screensaver; @@ -312,6 +317,7 @@ Uint8 window_magic; Uint8 texture_magic; Uint32 next_object_id; + char * clipboard_text; /* * * */ /* Data used by the GL drivers */
--- a/src/video/SDL_video.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/SDL_video.c Sun Jul 18 13:48:23 2010 -0400 @@ -2833,6 +2833,10 @@ SDL_free(_this->displays); _this->displays = NULL; } + if (_this->clipboard_text) { + SDL_free(_this->clipboard_text); + _this->clipboard_text = NULL; + } _this->free(_this); _this = NULL; } @@ -3267,7 +3271,7 @@ void SDL_GL_DeleteContext(SDL_GLContext context) { - if (!_this || !context) { + if (!_this || !_this->gl_data || !context) { return; } _this->GL_MakeCurrent(_this, NULL, NULL);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/cocoa/SDL_cocoaclipboard.h Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,37 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_cocoaclipboard_h +#define _SDL_cocoaclipboard_h + +/* Forward declaration */ +struct SDL_VideoData; + +extern int Cocoa_SetClipboardText(_THIS, const char *text); +extern char *Cocoa_GetClipboardText(_THIS); +extern SDL_bool Cocoa_HasClipboardText(_THIS); +extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data); + +#endif /* _SDL_cocoaclipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/cocoa/SDL_cocoaclipboard.m Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,140 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_cocoavideo.h" +#include "../../events/SDL_clipboardevents_c.h" + +static NSString * +GetTextFormat(_THIS) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + return NSStringPboardType; +#else + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + + if (data->osversion >= 0x1060) { + return NSPasteboardTypeString; + } else { + return NSStringPboardType; + } +#endif +} + +int +Cocoa_SetClipboardText(_THIS, const char *text) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format = GetTextFormat(_this); + + pool = [[NSAutoreleasePool alloc] init]; + + pasteboard = [NSPasteboard generalPasteboard]; + data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; + [pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; + + [pool release]; + + return 0; +} + +char * +Cocoa_GetClipboardText(_THIS) +{ + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format = GetTextFormat(_this); + NSString *available; + char *text; + + pool = [[NSAutoreleasePool alloc] init]; + + pasteboard = [NSPasteboard generalPasteboard]; + available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; + if ([available isEqualToString:format]) { + NSString* string; + const char *utf8; + + string = [pasteboard stringForType:format]; + if (string == nil) { + utf8 = ""; + } else { + utf8 = [string UTF8String]; + } + text = SDL_strdup(utf8); + } else { + text = SDL_strdup(""); + } + + [pool release]; + + return text; +} + +SDL_bool +Cocoa_HasClipboardText(_THIS) +{ + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format = GetTextFormat(_this); + NSString *available; + SDL_bool result; + + pool = [[NSAutoreleasePool alloc] init]; + + pasteboard = [NSPasteboard generalPasteboard]; + available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; + if ([available isEqualToString:format]) { + result = SDL_TRUE; + } else { + result = SDL_FALSE; + } + + [pool release]; + + return result; +} + +void +Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) +{ + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSInteger count; + + pool = [[NSAutoreleasePool alloc] init]; + + pasteboard = [NSPasteboard generalPasteboard]; + count = [pasteboard changeCount]; + if (count != data->clipboard_count) { + if (data->clipboard_count) { + SDL_SendClipboardUpdate(); + } + data->clipboard_count = count; + } + + [pool release]; +} + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/cocoa/SDL_cocoaevents.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoaevents.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
--- a/src/video/cocoa/SDL_cocoakeyboard.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoakeyboard.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
--- a/src/video/cocoa/SDL_cocoamodes.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoamodes.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
--- a/src/video/cocoa/SDL_cocoamouse.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoamouse.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
--- a/src/video/cocoa/SDL_cocoaopengl.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoaopengl.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
--- a/src/video/cocoa/SDL_cocoavideo.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoavideo.h Sun Jul 18 13:48:23 2010 -0400 @@ -32,6 +32,7 @@ #include "SDL_keysym.h" #include "../SDL_sysvideo.h" +#include "SDL_cocoaclipboard.h" #include "SDL_cocoaevents.h" #include "SDL_cocoakeyboard.h" #include "SDL_cocoamodes.h" @@ -59,6 +60,7 @@ unsigned int modifierFlags; void *key_layout; SDLTranslatorResponder *fieldEdit; + NSInteger clipboard_count; Uint32 screensaver_activity; } SDL_VideoData;
--- a/src/video/cocoa/SDL_cocoavideo.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoavideo.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -108,6 +108,10 @@ device->StopTextInput = Cocoa_StopTextInput; device->SetTextInputRect = Cocoa_SetTextInputRect; + device->SetClipboardText = Cocoa_SetClipboardText; + device->GetClipboardText = Cocoa_GetClipboardText; + device->HasClipboardText = Cocoa_HasClipboardText; + device->free = Cocoa_DeleteDevice; return device;
--- a/src/video/cocoa/SDL_cocoawindow.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/cocoa/SDL_cocoawindow.m Sun Jul 18 13:48:23 2010 -0400 @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Copyright (C) 1997-2010 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -128,6 +128,9 @@ { /* We're going to get keyboard events, since we're key. */ SDL_SetKeyboardFocus(_data->window); + + /* Check to see if someone updated the clipboard */ + Cocoa_CheckClipboardUpdate(_data->videodata); } - (void)windowDidResignKey:(NSNotification *)aNotification
--- a/src/video/uikit/SDL_uikitappdelegate.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/uikit/SDL_uikitappdelegate.m Sun Jul 18 13:48:23 2010 -0400 @@ -42,11 +42,12 @@ /* store arguments */ forward_argc = argc; - forward_argv = (char **)malloc(argc * sizeof(char *)); + forward_argv = (char **)malloc((argc+1) * sizeof(char *)); for (i=0; i<argc; i++) { forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char)); strcpy(forward_argv[i], argv[i]); } + forward_argv[i] = NULL; /* Give over control to run loop, SDLUIKitDelegate will handle most things from here */ UIApplicationMain(argc, argv, NULL, @"SDLUIKitDelegate");
--- a/src/video/uikit/SDL_uikitopengles.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/uikit/SDL_uikitopengles.m Sun Jul 18 13:48:23 2010 -0400 @@ -26,6 +26,8 @@ #include "SDL_uikitwindow.h" #include "jumphack.h" #include "SDL_sysvideo.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" #include "SDL_loadso.h" #include <dlfcn.h> @@ -125,7 +127,11 @@ UIKit_GL_DeleteContext(_this, view); return NULL; } - + + /* Make this window the current mouse focus for touch input */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + return view; }
--- a/src/video/uikit/SDL_uikitview.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/uikit/SDL_uikitview.h Sun Jul 18 13:48:23 2010 -0400 @@ -22,8 +22,6 @@ #import <UIKit/UIKit.h> #include "SDL_stdinc.h" -#include "SDL_mouse.h" -#include "SDL_mouse_c.h" #include "SDL_events.h" #if SDL_IPHONE_MULTIPLE_MICE @@ -38,7 +36,7 @@ #else @interface SDL_uikitview : UIView { #endif - + #if FIXME_MULTITOUCH SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; #endif
--- a/src/video/uikit/SDL_uikitview.m Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/uikit/SDL_uikitview.m Sun Jul 18 13:48:23 2010 -0400 @@ -22,8 +22,10 @@ #import "SDL_uikitview.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + #if SDL_IPHONE_KEYBOARD -#import "SDL_keyboard_c.h" #import "keyinfotable.h" #import "SDL_uikitappdelegate.h" #import "SDL_uikitwindow.h" @@ -33,7 +35,6 @@ - (void)dealloc { #if SDL_IPHONE_KEYBOARD - SDL_DelKeyboard(0); [textField release]; #endif [super dealloc]; @@ -64,7 +65,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch =(UITouch*)[enumerator nextObject]; + UITouch *touch = (UITouch*)[enumerator nextObject]; #if FIXME_MULTITOUCH /* associate touches with mice, so long as we have slots */ @@ -101,12 +102,21 @@ /* re-calibrate relative mouse motion */ SDL_GetRelativeMouseState(i, NULL, NULL); - /* grab next touch */ - touch = (UITouch*)[enumerator nextObject]; - /* switch back to our old mouse */ SDL_SelectMouse(oldMouse); + /* grab next touch */ + touch = (UITouch*)[enumerator nextObject]; + } +#else + if (touch) { + CGPoint locationInView = [touch locationInView: self]; + + /* send moved event */ + SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + + /* send mouse down event */ + SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); } #endif } @@ -114,10 +124,10 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch=nil; + UITouch *touch = (UITouch*)[enumerator nextObject]; #if FIXME_MULTITOUCH - while(touch = (UITouch *)[enumerator nextObject]) { + while(touch) { /* search for the mouse slot associated with this touch */ int i, found = NO; for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { @@ -131,6 +141,14 @@ found = YES; } } + + /* grab next touch */ + touch = (UITouch*)[enumerator nextObject]; + } +#else + if (touch) { + /* send mouse up */ + SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); } #endif } @@ -147,10 +165,10 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch=nil; + UITouch *touch = (UITouch*)[enumerator nextObject]; #if FIXME_MULTITOUCH - while(touch = (UITouch *)[enumerator nextObject]) { + while(touch) { /* try to find the mouse associated with this touch */ int i, found = NO; for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { @@ -163,6 +181,16 @@ found = YES; } } + + /* grab next touch */ + touch = (UITouch*)[enumerator nextObject]; + } +#else + if (touch) { + CGPoint locationInView = [touch locationInView: self]; + + /* send moved event */ + SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); } #endif } @@ -198,15 +226,6 @@ keyboardVisible = NO; /* add the UITextField (hidden) to our view */ [self addSubview: textField]; - - /* create our SDL_Keyboard */ - SDL_Keyboard keyboard; - SDL_zero(keyboard); - SDL_AddKeyboard(&keyboard, 0); - SDLKey keymap[SDL_NUM_SCANCODES]; - SDL_GetDefaultKeymap(keymap); - SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); - } /* reveal onscreen virtual keyboard */ @@ -226,8 +245,8 @@ if ([string length] == 0) { /* it wants to replace text with nothing, ie a delete */ - SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE); - SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); } else { /* go through all the characters in the string we've been sent @@ -253,14 +272,14 @@ if (mod & KMOD_SHIFT) { /* If character uses shift, press shift down */ - SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); } /* send a keydown and keyup even for the character */ - SDL_SendKeyboardKey( 0, SDL_PRESSED, code); - SDL_SendKeyboardKey( 0, SDL_RELEASED, code); + SDL_SendKeyboardKey(SDL_PRESSED, code); + SDL_SendKeyboardKey(SDL_RELEASED, code); if (mod & KMOD_SHIFT) { /* If character uses shift, press shift back up */ - SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/win32/SDL_win32clipboard.c Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,161 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_win32video.h" +#include "SDL_win32window.h" +#include "../../events/SDL_clipboardevents_c.h" + + +#ifdef UNICODE +#define TEXT_FORMAT CF_UNICODETEXT +#else +#define TEXT_FORMAT CF_TEXT +#endif + + +/* Get any application owned window handle for clipboard association */ +static HWND +GetWindowHandle(_THIS) +{ + SDL_VideoDisplay *display; + SDL_Window *window; + + display = _this->displays; + if (display) { + window = display->windows; + if (window) { + return ((SDL_WindowData *) window->driverdata)->hwnd; + } + } + return NULL; +} + +int +WIN_SetClipboardText(_THIS, const char *text) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + int result = 0; + + if (OpenClipboard(GetWindowHandle(_this))) { + HANDLE hMem; + LPTSTR tstr; + SIZE_T i, size; + + /* Convert the text from UTF-8 to Windows Unicode */ + tstr = WIN_UTF8ToString(text); + if (!tstr) { + return -1; + } + + /* Find out the size of the data */ + for (size = 0, i = 0; tstr[i]; ++i, ++size) { + if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { + /* We're going to insert a carriage return */ + ++size; + } + } + size = (size+1)*sizeof(*tstr); + + /* Save the data to the clipboard */ + hMem = GlobalAlloc(GMEM_MOVEABLE, size); + if (hMem) { + LPTSTR dst = (LPTSTR)GlobalLock(hMem); + /* Copy the text over, adding carriage returns as necessary */ + for (i = 0; tstr[i]; ++i) { + if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) { + *dst++ = '\r'; + } + *dst++ = tstr[i]; + } + *dst = 0; + GlobalUnlock(hMem); + + EmptyClipboard(); + if (!SetClipboardData(TEXT_FORMAT, hMem)) { + WIN_SetError("Couldn't set clipboard data"); + result = -1; + } + data->clipboard_count = GetClipboardSequenceNumber(); + } + SDL_free(tstr); + + CloseClipboard(); + } else { + WIN_SetError("Couldn't open clipboard"); + result = -1; + } + return result; +} + +char * +WIN_GetClipboardText(_THIS) +{ + char *text; + + text = NULL; + if (IsClipboardFormatAvailable(TEXT_FORMAT) && + OpenClipboard(GetWindowHandle(_this))) { + HANDLE hMem; + LPTSTR tstr; + + hMem = GetClipboardData(TEXT_FORMAT); + if (hMem) { + tstr = (LPTSTR)GlobalLock(hMem); + text = WIN_StringToUTF8(tstr); + GlobalUnlock(hMem); + } else { + WIN_SetError("Couldn't get clipboard data"); + } + CloseClipboard(); + } + if (!text) { + text = SDL_strdup(""); + } + return text; +} + +SDL_bool +WIN_HasClipboardText(_THIS) +{ + if (IsClipboardFormatAvailable(TEXT_FORMAT)) { + return SDL_TRUE; + } else { + return SDL_FALSE; + } +} + +void +WIN_CheckClipboardUpdate(struct SDL_VideoData * data) +{ + DWORD count; + + count = GetClipboardSequenceNumber(); + if (count != data->clipboard_count) { + if (data->clipboard_count) { + SDL_SendClipboardUpdate(); + } + data->clipboard_count = count; + } +} + +/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/win32/SDL_win32clipboard.h Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,37 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_win32clipboard_h +#define _SDL_win32clipboard_h + +/* Forward declaration */ +struct SDL_VideoData; + +extern int WIN_SetClipboardText(_THIS, const char *text); +extern char *WIN_GetClipboardText(_THIS); +extern SDL_bool WIN_HasClipboardText(_THIS); +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data); + +#endif /* _SDL_win32clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32events.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/win32/SDL_win32events.c Sun Jul 18 13:48:23 2010 -0400 @@ -164,7 +164,10 @@ if (SDL_GetKeyboardFocus() != data->window) { SDL_SetKeyboardFocus(data->window); } - /* FIXME: Update keyboard state */ + /* + * FIXME: Update keyboard state + */ + WIN_CheckClipboardUpdate(data->videodata); } else { if (SDL_GetKeyboardFocus() == data->window) { SDL_SetKeyboardFocus(NULL); @@ -587,17 +590,4 @@ } } -/* Sets an error message based on GetLastError() */ -void -WIN_SetError(const char *prefix) -{ - TCHAR buffer[1024]; - char *message; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, - buffer, SDL_arraysize(buffer), NULL); - message = WIN_StringToUTF8(buffer); - SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); - SDL_free(message); -} - /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32events.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/win32/SDL_win32events.h Sun Jul 18 13:48:23 2010 -0400 @@ -31,7 +31,6 @@ extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); extern void WIN_PumpEvents(_THIS); -extern void WIN_SetError(const char *prefix); #endif /* _SDL_win32events_h */
--- a/src/video/win32/SDL_win32video.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/win32/SDL_win32video.c Sun Jul 18 13:48:23 2010 -0400 @@ -1,213 +1,230 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_main.h" -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" - -#include "SDL_win32video.h" -#include "SDL_d3drender.h" -#include "SDL_gdirender.h" - -/* Initialization/Query functions */ -static int WIN_VideoInit(_THIS); -static void WIN_VideoQuit(_THIS); - -/* WIN32 driver bootstrap functions */ - -static int -WIN_Available(void) -{ - return (1); -} - -static void -WIN_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_VideoData *data = (SDL_VideoData *) device->driverdata; - - SDL_UnregisterApp(); -#if SDL_VIDEO_RENDER_D3D - if (data->d3d) { - IDirect3D9_Release(data->d3d); - FreeLibrary(data->d3dDLL); - } -#endif -#if SDL_VIDEO_RENDER_DDRAW - if (data->ddraw) { - data->ddraw->lpVtbl->Release(data->ddraw); - FreeLibrary(data->ddrawDLL); - } -#endif - SDL_free(device->driverdata); - SDL_free(device); -} - -static SDL_VideoDevice * -WIN_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - SDL_VideoData *data; - - SDL_RegisterApp(NULL, 0, NULL); - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device) { - data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - } else { - data = NULL; - } - if (!data) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return NULL; - } - device->driverdata = data; - -#if SDL_VIDEO_RENDER_D3D - data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL")); - if (data->d3dDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL, - "Direct3DCreate9"); - if (D3DCreate) { - data->d3d = D3DCreate(D3D_SDK_VERSION); - } - if (!data->d3d) { - FreeLibrary(data->d3dDLL); - data->d3dDLL = NULL; - } - } -#endif /* SDL_VIDEO_RENDER_D3D */ -#if SDL_VIDEO_RENDER_DDRAW - data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll")); - if (data->ddrawDLL) { - IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID, - LPDIRECTDRAW FAR * lplpDD, - IUnknown FAR * pUnkOuter); - - DDCreate = - (IDirectDraw * - (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *)) - GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate")); - if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) { - FreeLibrary(data->ddrawDLL); - data->ddrawDLL = NULL; - data->ddraw = NULL; - } - } -#endif /* SDL_VIDEO_RENDER_DDRAW */ - - /* Set the function pointers */ - device->VideoInit = WIN_VideoInit; - device->VideoQuit = WIN_VideoQuit; - device->GetDisplayBounds = WIN_GetDisplayBounds; - device->GetDisplayModes = WIN_GetDisplayModes; - device->SetDisplayMode = WIN_SetDisplayMode; - device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp; - device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp; - device->PumpEvents = WIN_PumpEvents; - -#undef CreateWindow - device->CreateWindow = WIN_CreateWindow; - device->CreateWindowFrom = WIN_CreateWindowFrom; - device->SetWindowTitle = WIN_SetWindowTitle; - device->SetWindowIcon = WIN_SetWindowIcon; - device->SetWindowPosition = WIN_SetWindowPosition; - device->SetWindowSize = WIN_SetWindowSize; - device->ShowWindow = WIN_ShowWindow; - device->HideWindow = WIN_HideWindow; - device->RaiseWindow = WIN_RaiseWindow; - device->MaximizeWindow = WIN_MaximizeWindow; - device->MinimizeWindow = WIN_MinimizeWindow; - device->RestoreWindow = WIN_RestoreWindow; - device->SetWindowGrab = WIN_SetWindowGrab; - device->DestroyWindow = WIN_DestroyWindow; - device->GetWindowWMInfo = WIN_GetWindowWMInfo; -#ifdef SDL_VIDEO_OPENGL_WGL - device->GL_LoadLibrary = WIN_GL_LoadLibrary; - device->GL_GetProcAddress = WIN_GL_GetProcAddress; - device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; - device->GL_CreateContext = WIN_GL_CreateContext; - device->GL_MakeCurrent = WIN_GL_MakeCurrent; - device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; - device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; - device->GL_SwapWindow = WIN_GL_SwapWindow; - device->GL_DeleteContext = WIN_GL_DeleteContext; -#endif - device->StartTextInput = WIN_StartTextInput; - device->StopTextInput = WIN_StopTextInput; - device->SetTextInputRect = WIN_SetTextInputRect; - - device->free = WIN_DeleteDevice; - - return device; -} - -VideoBootStrap WIN32_bootstrap = { - "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice -}; - - -int -WIN_VideoInit(_THIS) -{ - if (WIN_InitModes(_this) < 0) { - return -1; - } - -#if SDL_VIDEO_RENDER_D3D - D3D_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_DDRAW - DDRAW_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_GDI - GDI_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_GAPI - GAPI_AddRenderDriver(_this); -#endif - - WIN_InitKeyboard(_this); - WIN_InitMouse(_this); - - return 0; -} - -void -WIN_VideoQuit(_THIS) -{ - WIN_QuitModes(_this); - WIN_QuitKeyboard(_this); - WIN_QuitMouse(_this); -} - -/* vim: set ts=4 sw=4 expandtab: */ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_main.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" + +#include "SDL_win32video.h" +#include "SDL_d3drender.h" +#include "SDL_gdirender.h" + +/* Initialization/Query functions */ +static int WIN_VideoInit(_THIS); +static void WIN_VideoQuit(_THIS); + +/* Sets an error message based on GetLastError() */ +void +WIN_SetError(const char *prefix) +{ + TCHAR buffer[1024]; + char *message; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, + buffer, SDL_arraysize(buffer), NULL); + message = WIN_StringToUTF8(buffer); + SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); + SDL_free(message); +} + +/* WIN32 driver bootstrap functions */ + +static int +WIN_Available(void) +{ + return (1); +} + +static void +WIN_DeleteDevice(SDL_VideoDevice * device) +{ + SDL_VideoData *data = (SDL_VideoData *) device->driverdata; + + SDL_UnregisterApp(); +#if SDL_VIDEO_RENDER_D3D + if (data->d3d) { + IDirect3D9_Release(data->d3d); + FreeLibrary(data->d3dDLL); + } +#endif +#if SDL_VIDEO_RENDER_DDRAW + if (data->ddraw) { + data->ddraw->lpVtbl->Release(data->ddraw); + FreeLibrary(data->ddrawDLL); + } +#endif + SDL_free(device->driverdata); + SDL_free(device); +} + +static SDL_VideoDevice * +WIN_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + SDL_RegisterApp(NULL, 0, NULL); + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + } else { + data = NULL; + } + if (!data) { + SDL_OutOfMemory(); + if (device) { + SDL_free(device); + } + return NULL; + } + device->driverdata = data; + +#if SDL_VIDEO_RENDER_D3D + data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL")); + if (data->d3dDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); + + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL, + "Direct3DCreate9"); + if (D3DCreate) { + data->d3d = D3DCreate(D3D_SDK_VERSION); + } + if (!data->d3d) { + FreeLibrary(data->d3dDLL); + data->d3dDLL = NULL; + } + } +#endif /* SDL_VIDEO_RENDER_D3D */ +#if SDL_VIDEO_RENDER_DDRAW + data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll")); + if (data->ddrawDLL) { + IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID, + LPDIRECTDRAW FAR * lplpDD, + IUnknown FAR * pUnkOuter); + + DDCreate = + (IDirectDraw * + (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *)) + GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate")); + if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) { + FreeLibrary(data->ddrawDLL); + data->ddrawDLL = NULL; + data->ddraw = NULL; + } + } +#endif /* SDL_VIDEO_RENDER_DDRAW */ + + /* Set the function pointers */ + device->VideoInit = WIN_VideoInit; + device->VideoQuit = WIN_VideoQuit; + device->GetDisplayBounds = WIN_GetDisplayBounds; + device->GetDisplayModes = WIN_GetDisplayModes; + device->SetDisplayMode = WIN_SetDisplayMode; + device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp; + device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp; + device->PumpEvents = WIN_PumpEvents; + +#undef CreateWindow + device->CreateWindow = WIN_CreateWindow; + device->CreateWindowFrom = WIN_CreateWindowFrom; + device->SetWindowTitle = WIN_SetWindowTitle; + device->SetWindowIcon = WIN_SetWindowIcon; + device->SetWindowPosition = WIN_SetWindowPosition; + device->SetWindowSize = WIN_SetWindowSize; + device->ShowWindow = WIN_ShowWindow; + device->HideWindow = WIN_HideWindow; + device->RaiseWindow = WIN_RaiseWindow; + device->MaximizeWindow = WIN_MaximizeWindow; + device->MinimizeWindow = WIN_MinimizeWindow; + device->RestoreWindow = WIN_RestoreWindow; + device->SetWindowGrab = WIN_SetWindowGrab; + device->DestroyWindow = WIN_DestroyWindow; + device->GetWindowWMInfo = WIN_GetWindowWMInfo; +#ifdef SDL_VIDEO_OPENGL_WGL + device->GL_LoadLibrary = WIN_GL_LoadLibrary; + device->GL_GetProcAddress = WIN_GL_GetProcAddress; + device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; + device->GL_CreateContext = WIN_GL_CreateContext; + device->GL_MakeCurrent = WIN_GL_MakeCurrent; + device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; + device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; + device->GL_SwapWindow = WIN_GL_SwapWindow; + device->GL_DeleteContext = WIN_GL_DeleteContext; +#endif + device->StartTextInput = WIN_StartTextInput; + device->StopTextInput = WIN_StopTextInput; + device->SetTextInputRect = WIN_SetTextInputRect; + + device->SetClipboardText = WIN_SetClipboardText; + device->GetClipboardText = WIN_GetClipboardText; + device->HasClipboardText = WIN_HasClipboardText; + + device->free = WIN_DeleteDevice; + + return device; +} + +VideoBootStrap WIN32_bootstrap = { + "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice +}; + + +int +WIN_VideoInit(_THIS) +{ + if (WIN_InitModes(_this) < 0) { + return -1; + } + +#if SDL_VIDEO_RENDER_D3D + D3D_AddRenderDriver(_this); +#endif +#if SDL_VIDEO_RENDER_DDRAW + DDRAW_AddRenderDriver(_this); +#endif +#if SDL_VIDEO_RENDER_GDI + GDI_AddRenderDriver(_this); +#endif +#if SDL_VIDEO_RENDER_GAPI + GAPI_AddRenderDriver(_this); +#endif + + WIN_InitKeyboard(_this); + WIN_InitMouse(_this); + + return 0; +} + +void +WIN_VideoQuit(_THIS) +{ + WIN_QuitModes(_this); + WIN_QuitKeyboard(_this); + WIN_QuitMouse(_this); +} + +/* vim: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32video.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/win32/SDL_win32video.h Sun Jul 18 13:48:23 2010 -0400 @@ -1,92 +1,95 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32video_h -#define _SDL_win32video_h - -#include "../SDL_sysvideo.h" - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#define UNICODE -#undef WINVER -#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ -#include <windows.h> - -#if SDL_VIDEO_RENDER_D3D -//#include <d3d9.h> -#define D3D_DEBUG_INFO -#include "d3d9.h" -#endif - -#if SDL_VIDEO_RENDER_DDRAW -/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */ -#include <objbase.h> -#include "ddraw.h" -#endif - -#include "SDL_win32events.h" -#include "SDL_win32gamma.h" -#include "SDL_win32keyboard.h" -#include "SDL_win32modes.h" -#include "SDL_win32mouse.h" -#include "SDL_win32opengl.h" -#include "SDL_win32window.h" - -#ifdef UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1) -#else -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1)) -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1) -#endif - -/* Private display data */ - -typedef struct SDL_VideoData -{ -#if SDL_VIDEO_RENDER_D3D - HANDLE d3dDLL; - IDirect3D9 *d3d; -#endif -#if SDL_VIDEO_RENDER_DDRAW - HANDLE ddrawDLL; - IDirectDraw *ddraw; -#endif - - const SDL_scancode *key_layout; - - SDL_bool ime_com_initialized; - struct ITfThreadMgr *ime_thread_mgr; - SDL_bool ime_initialized; - SDL_bool ime_enabled; - SDL_bool ime_available; - HWND ime_hwnd_main; - HWND ime_hwnd_current; - HIMC ime_himc; - -} SDL_VideoData; - -#endif /* _SDL_win32video_h */ - -/* vi: set ts=4 sw=4 expandtab: */ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_win32video_h +#define _SDL_win32video_h + +#include "../SDL_sysvideo.h" + +#define WIN32_LEAN_AND_MEAN +#define STRICT +#define UNICODE +#undef WINVER +#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ +#include <windows.h> + +#if SDL_VIDEO_RENDER_D3D +//#include <d3d9.h> +#define D3D_DEBUG_INFO +#include "d3d9.h" +#endif + +#if SDL_VIDEO_RENDER_DDRAW +/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */ +#include <objbase.h> +#include "ddraw.h" +#endif + +#include "SDL_win32clipboard.h" +#include "SDL_win32events.h" +#include "SDL_win32gamma.h" +#include "SDL_win32keyboard.h" +#include "SDL_win32modes.h" +#include "SDL_win32mouse.h" +#include "SDL_win32opengl.h" +#include "SDL_win32window.h" + +#ifdef UNICODE +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR)) +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1) +#else +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1)) +#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1) +#endif +extern void WIN_SetError(const char *prefix); + +/* Private display data */ + +typedef struct SDL_VideoData +{ +#if SDL_VIDEO_RENDER_D3D + HANDLE d3dDLL; + IDirect3D9 *d3d; +#endif +#if SDL_VIDEO_RENDER_DDRAW + HANDLE ddrawDLL; + IDirectDraw *ddraw; +#endif + + const SDL_scancode *key_layout; + DWORD clipboard_count; + + SDL_bool ime_com_initialized; + struct ITfThreadMgr *ime_thread_mgr; + SDL_bool ime_initialized; + SDL_bool ime_enabled; + SDL_bool ime_available; + HWND ime_hwnd_main; + HWND ime_hwnd_current; + HIMC ime_himc; + +} SDL_VideoData; + +#endif /* _SDL_win32video_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32window.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/win32/SDL_win32window.c Sun Jul 18 13:48:23 2010 -0400 @@ -635,8 +635,7 @@ /* Register the class. */ SDL_HelperWindowClass = RegisterClass(&wce); if (SDL_HelperWindowClass == 0) { - SDL_SetError("Unable to create Helper Window Class: error %d.", - GetLastError()); + WIN_SetError("Unable to create Helper Window Class"); return -1; } @@ -654,8 +653,7 @@ hInstance, NULL); if (SDL_HelperWindow == NULL) { UnregisterClass(SDL_HelperWindowClassName, hInstance); - SDL_SetError("Unable to create Helper Window: error %d.", - GetLastError()); + WIN_SetError("Unable to create Helper Window"); return -1; } @@ -674,8 +672,7 @@ /* Destroy the window. */ if (SDL_HelperWindow != NULL) { if (DestroyWindow(SDL_HelperWindow) == 0) { - SDL_SetError("Unable to destroy Helper Window: error %d.", - GetLastError()); + WIN_SetError("Unable to destroy Helper Window"); return; } SDL_HelperWindow = NULL; @@ -684,8 +681,7 @@ /* Unregister the class. */ if (SDL_HelperWindowClass != 0) { if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) { - SDL_SetError("Unable to destroy Helper Window Class: error %d.", - GetLastError()); + WIN_SetError("Unable to destroy Helper Window Class"); return; } SDL_HelperWindowClass = 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/x11/SDL_x11clipboard.c Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,156 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include <limits.h> /* For INT_MAX */ + +#include "SDL_events.h" +#include "SDL_x11video.h" + + +/* If you don't support UTF-8, you might use XA_STRING here */ +#ifdef X_HAVE_UTF8_STRING +#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) +#else +#define TEXT_FORMAT XA_STRING +#endif + +/* Get any application owned window handle for clipboard association */ +static Window +GetWindow(_THIS) +{ + SDL_VideoDisplay *display; + SDL_Window *window; + + display = _this->displays; + if (display) { + window = display->windows; + if (window) { + return ((SDL_WindowData *) window->driverdata)->xwindow; + } + } + return None; +} + +int +X11_SetClipboardText(_THIS, const char *text) +{ + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Atom format; + Window window; + + /* Get the SDL window that will own the selection */ + window = GetWindow(_this); + if (window == None) { + SDL_SetError("Couldn't find a window to own the selection"); + return -1; + } + + /* Save the selection on the root window */ + format = TEXT_FORMAT; + XChangeProperty(display, DefaultRootWindow(display), + XA_CUT_BUFFER0, format, 8, PropModeReplace, + (const unsigned char *)text, SDL_strlen(text)); + + if (XGetSelectionOwner(display, XA_PRIMARY) != window) { + XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime); + } + return 0; +} + +char * +X11_GetClipboardText(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + Display *display = videodata->display; + Atom format; + Window window; + Window owner; + Atom selection; + Atom seln_type; + int seln_format; + unsigned long nbytes; + unsigned long overflow; + unsigned char *src; + char *text; + + text = NULL; + + /* Get the window that holds the selection */ + window = GetWindow(_this); + format = TEXT_FORMAT; + owner = XGetSelectionOwner(display, XA_PRIMARY); + if ((owner == None) || (owner == window)) { + owner = DefaultRootWindow(display); + selection = XA_CUT_BUFFER0; + } else { + /* Request that the selection owner copy the data to our window */ + owner = window; + selection = XInternAtom(display, "SDL_SELECTION", False); + XConvertSelection(display, XA_PRIMARY, format, selection, owner, + CurrentTime); + + /* FIXME: Should we have a timeout here? */ + videodata->selection_waiting = SDL_TRUE; + while (videodata->selection_waiting) { + SDL_PumpEvents(); + } + } + + if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False, + format, &seln_type, &seln_format, &nbytes, &overflow, &src) + == Success) { + if (seln_type == format) { + text = (char *)SDL_malloc(nbytes+1); + if (text) { + SDL_memcpy(text, src, nbytes); + text[nbytes] = '\0'; + } + } + XFree(src); + } + + if (!text) { + text = SDL_strdup(""); + } + return text; +} + +SDL_bool +X11_HasClipboardText(_THIS) +{ + /* Not an easy way to tell with X11, as far as I know... */ + char *text; + SDL_bool retval; + + text = X11_GetClipboardText(_this); + if (*text) { + retval = SDL_TRUE; + } else { + retval = SDL_FALSE; + } + SDL_free(text); + + return retval; +} + +/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/x11/SDL_x11clipboard.h Sun Jul 18 13:48:23 2010 -0400 @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_x11clipboard_h +#define _SDL_x11clipboard_h + +extern int X11_SetClipboardText(_THIS, const char *text); +extern char *X11_GetClipboardText(_THIS); +extern SDL_bool X11_HasClipboardText(_THIS); + +#endif /* _SDL_x11clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11events.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11events.c Sun Jul 18 13:48:23 2010 -0400 @@ -25,6 +25,7 @@ #include <sys/time.h> #include <signal.h> #include <unistd.h> +#include <limits.h> /* For INT_MAX */ #include "SDL_x11video.h" #include "../../events/SDL_events_c.h" @@ -33,16 +34,19 @@ #include "SDL_timer.h" #include "SDL_syswm.h" +#define DEBUG_XEVENTS + static void X11_DispatchEvent(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + Display *display = videodata->display; SDL_WindowData *data; XEvent xevent; int i; SDL_zero(xevent); /* valgrind fix. --ryan. */ - XNextEvent(videodata->display, &xevent); + XNextEvent(display, &xevent); /* filter events catchs XIM events and sends them to the correct handler */ @@ -77,6 +81,7 @@ if (!data) { return; } + #if 0 printf("type = %d display = %d window = %d\n", xevent.type, xevent.xany.display, xevent.xany.window); @@ -176,12 +181,11 @@ printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); -#if 0 +#if 1 if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { int min_keycode, max_keycode; - XDisplayKeycodes(videodata->display, &min_keycode, - &max_keycode); - keysym = XKeycodeToKeysym(videodata->display, keycode, 0); + XDisplayKeycodes(display, &min_keycode, &max_keycode); + keysym = XKeycodeToKeysym(display, keycode, 0); fprintf(stderr, "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", keycode, keycode - min_keycode, keysym, @@ -286,6 +290,130 @@ } break; + case PropertyNotify:{ +#ifdef DEBUG_XEVENTS + unsigned char *propdata; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left, i; + + char *name = XGetAtomName(display, xevent.xproperty.atom); + if (name) { + printf("PropertyNotify: %s\n", name); + XFree(name); + } + + status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success) { + if (real_type == XA_INTEGER) { + int *values = (int *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } else if (real_type == XA_CARDINAL) { + if (real_format == 32) { + Uint32 *values = (Uint32 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } else if (real_format == 16) { + Uint16 *values = (Uint16 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } else if (real_format == 8) { + Uint8 *values = (Uint8 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); + } + printf(" }\n"); + } + } else if (real_type == XA_STRING || + real_type == videodata->UTF8_STRING) { + printf("{ \"%s\" }\n", propdata); + } else if (real_type == XA_ATOM) { + Atom *atoms = (Atom *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + char *name = XGetAtomName(display, atoms[i]); + if (name) { + printf(" %s", name); + XFree(name); + } + } + printf(" }\n"); + } else { + char *name = XGetAtomName(display, real_type); + printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN"); + if (name) { + XFree(name); + } + } + } +#endif + } + break; + + /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ + case SelectionRequest: { + XSelectionRequestEvent *req; + XEvent sevent; + int seln_format; + unsigned long nbytes; + unsigned long overflow; + unsigned char *seln_data; + + req = &xevent.xselectionrequest; +#ifdef DEBUG_XEVENTS + printf("SelectionRequest (requestor = %ld, target = %ld)\n", + req->requestor, req->target); +#endif + + SDL_zero(sevent); + sevent.xany.type = SelectionNotify; + sevent.xselection.selection = req->selection; + sevent.xselection.target = None; + sevent.xselection.property = None; + sevent.xselection.requestor = req->requestor; + sevent.xselection.time = req->time; + if (XGetWindowProperty(display, DefaultRootWindow(display), + XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, + &sevent.xselection.target, &seln_format, &nbytes, + &overflow, &seln_data) == Success) { + if (sevent.xselection.target == req->target) { + XChangeProperty(display, req->requestor, req->property, + sevent.xselection.target, seln_format, PropModeReplace, + seln_data, nbytes); + sevent.xselection.property = req->property; + } + XFree(seln_data); + } + XSendEvent(display, req->requestor, False, 0, &sevent); + XSync(display, False); + } + break; + + case SelectionNotify: { +#ifdef DEBUG_XEVENTS + printf("SelectionNotify (requestor = %ld, target = %ld)\n", + xevent.xselection.requestor, xevent.xselection.target); +#endif + videodata->selection_waiting = SDL_FALSE; + } + break; + default:{ #ifdef DEBUG_XEVENTS printf("Unhandled event %d\n", xevent.type);
--- a/src/video/x11/SDL_x11keyboard.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11keyboard.c Sun Jul 18 13:48:23 2010 -0400 @@ -211,7 +211,9 @@ } } if (j == SDL_arraysize(fingerprint)) { - /* printf("Using scancode set %d\n", i); */ +#ifdef DEBUG_KEYBOARD + 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); +#endif SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table, sizeof(SDL_scancode) * scancode_set[i].table_size); fingerprint_detected = SDL_TRUE;
--- a/src/video/x11/SDL_x11modes.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11modes.c Sun Jul 18 13:48:23 2010 -0400 @@ -23,10 +23,7 @@ #include "SDL_x11video.h" -//#define X11MODES_DEBUG -#undef SDL_VIDEO_DRIVER_X11_XINERAMA -#undef SDL_VIDEO_DRIVER_X11_XRANDR -#undef SDL_VIDEO_DRIVER_X11_VIDMODE +/*#define X11MODES_DEBUG*/ static int get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) @@ -253,6 +250,7 @@ return SDL_TRUE; } +static Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr, SDL_NAME(XF86VidModeModeInfo) * info) { @@ -296,6 +294,7 @@ &data->saved_view.y); } +/* static void restore_mode(Display * display, SDL_DisplayData * data) { @@ -313,6 +312,7 @@ data->saved_view.y); } } +*/ #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ void
--- a/src/video/x11/SDL_x11sym.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11sym.h Sun Jul 18 13:48:23 2010 -0400 @@ -37,6 +37,7 @@ SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return) SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return) +SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return) 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) SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) 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) @@ -66,15 +67,18 @@ SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return) SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return) SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) +SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return) 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) 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) SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return) SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return) SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return) +SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return) +SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return) SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return) -SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return) 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) +SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return) 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) SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return) @@ -114,14 +118,15 @@ SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return) SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return) SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return) SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return) -SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return) SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),) -SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),) -SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return) SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return) SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return) SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return) +SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return) +SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),) +SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return) SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return) SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return)
--- a/src/video/x11/SDL_x11video.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11video.c Sun Jul 18 13:48:23 2010 -0400 @@ -21,6 +21,8 @@ */ #include "SDL_config.h" +#include <unistd.h> /* For getpid() and readlink() */ + #include "SDL_video.h" #include "SDL_mouse.h" #include "../SDL_sysvideo.h" @@ -225,6 +227,10 @@ device->GL_DeleteContext = X11_GLES_DeleteContext; #endif + device->SetClipboardText = X11_SetClipboardText; + device->GetClipboardText = X11_GetClipboardText; + device->HasClipboardText = X11_HasClipboardText; + device->free = X11_DeleteDevice; return device; @@ -236,6 +242,43 @@ }; +static void +X11_CheckWindowManager(_THIS) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + Display *display = data->display; + Atom _NET_SUPPORTING_WM_CHECK; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left; + unsigned char *propdata; + Window wm_window = 0; +#ifdef DEBUG_WINDOW_MANAGER + char *wm_name; +#endif + + _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); + status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success && items_read) { + wm_window = ((Window*)propdata)[0]; + } + XFree(propdata); + + if (!wm_window) { +#ifdef DEBUG_WINDOW_MANAGER + printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n"); +#endif + return; + } + data->net_wm = SDL_TRUE; + +#ifdef DEBUG_WINDOW_MANAGER + wm_name = X11_GetWindowTitle(_this, wm_window); + printf("Window manager: %s\n", wm_name); + SDL_free(wm_name); +#endif +} + int X11_VideoInit(_THIS) { @@ -253,8 +296,20 @@ #endif /* Look up some useful Atoms */ - data->WM_DELETE_WINDOW = - XInternAtom(data->display, "WM_DELETE_WINDOW", False); +#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False) + GET_ATOM(WM_DELETE_WINDOW); + GET_ATOM(_NET_WM_STATE); + GET_ATOM(_NET_WM_STATE_HIDDEN); + GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); + GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); + GET_ATOM(_NET_WM_STATE_FULLSCREEN); + GET_ATOM(_NET_WM_NAME); + GET_ATOM(_NET_WM_ICON_NAME); + GET_ATOM(_NET_WM_ICON); + GET_ATOM(UTF8_STRING); + + /* Detect the window manager */ + X11_CheckWindowManager(_this); if (X11_InitModes(_this) < 0) { return -1;
--- a/src/video/x11/SDL_x11video.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11video.h Sun Jul 18 13:48:23 2010 -0400 @@ -48,6 +48,7 @@ #include "SDL_x11dyn.h" +#include "SDL_x11clipboard.h" #include "SDL_x11events.h" #include "SDL_x11gamma.h" #include "SDL_x11keyboard.h" @@ -67,8 +68,24 @@ int numwindows; SDL_WindowData **windowlist; int windowlistlength; + + /* This is true for ICCCM2.0-compliant window managers */ + SDL_bool net_wm; + + /* Useful atoms */ Atom WM_DELETE_WINDOW; + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_HIDDEN; + Atom _NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN; + Atom _NET_WM_NAME; + Atom _NET_WM_ICON_NAME; + Atom _NET_WM_ICON; + Atom UTF8_STRING; + SDL_scancode key_layout[256]; + SDL_bool selection_waiting; } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void);
--- a/src/video/x11/SDL_x11window.c Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11window.c Sun Jul 18 13:48:23 2010 -0400 @@ -42,6 +42,50 @@ #define _NET_WM_STATE_ADD 1l #define _NET_WM_STATE_TOGGLE 2l +static SDL_bool +X11_IsWindowOldFullscreen(_THIS, SDL_Window * window) +{ + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + + /* ICCCM2.0-compliant window managers can handle fullscreen windows */ + if ((window->flags & SDL_WINDOW_FULLSCREEN) && !videodata->net_wm) { + return SDL_TRUE; + } else { + return SDL_FALSE; + } +} + +static SDL_bool +X11_IsWindowMapped(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + XWindowAttributes attr; + + XGetWindowAttributes(videodata->display, data->xwindow, &attr); + if (attr.map_state != IsUnmapped) { + return SDL_TRUE; + } else { + return SDL_FALSE; + } +} + +static int +X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3]) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + int count = 0; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + atoms[count++] = data->_NET_WM_STATE_FULLSCREEN; + } + if (window->flags & SDL_WINDOW_MAXIMIZED) { + atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_VERT; + atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_HORZ; + } + return count; +} + static void X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) { @@ -128,14 +172,10 @@ } { - Atom _NET_WM_STATE = - XInternAtom(data->videodata->display, "_NET_WM_STATE", False); - Atom _NET_WM_STATE_MAXIMIZED_VERT = - XInternAtom(data->videodata->display, - "_NET_WM_STATE_MAXIMIZED_VERT", False); - Atom _NET_WM_STATE_MAXIMIZED_HORZ = - XInternAtom(data->videodata->display, - "_NET_WM_STATE_MAXIMIZED_HORZ", False); + Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; Atom actualType; int actualFormat; unsigned long i, numItems, bytesAfter; @@ -148,19 +188,21 @@ &propertyValue) == Success) { Atom *atoms = (Atom *) propertyValue; int maximized = 0; + int fullscreen = 0; for (i = 0; i < numItems; ++i) { if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) { maximized |= 1; } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { maximized |= 2; + } else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) { + fullscreen = 1; } - /* Might also want to check the following properties: - _NET_WM_STATE_ABOVE, _NET_WM_STATE_FULLSCREEN - */ } if (maximized == 3) { window->flags |= SDL_WINDOW_MAXIMIZED; + } else if (fullscreen == 1) { + window->flags |= SDL_WINDOW_FULLSCREEN; } XFree(propertyValue); } @@ -180,11 +222,6 @@ } else { window->flags &= ~SDL_WINDOW_RESIZABLE; } - if (style & WS_MAXIMIZE) { - window->flags |= SDL_WINDOW_MAXIMIZED; - } else { - window->flags &= ~SDL_WINDOW_MAXIMIZED; - } if (style & WS_MINIMIZE) { window->flags |= SDL_WINDOW_MINIMIZED; } else { @@ -217,6 +254,8 @@ SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = (SDL_DisplayData *) window->display->driverdata; + Display *display = data->display; + int screen = displaydata->screen; Visual *visual; int depth; XSetWindowAttributes xattr; @@ -225,6 +264,14 @@ XSizeHints *sizehints; XWMHints *wmhints; XClassHint *classhints; + SDL_bool oldstyle_fullscreen; + Atom _NET_WM_WINDOW_TYPE; + Atom _NET_WM_WINDOW_TYPE_NORMAL; + int wmstate_count; + Atom wmstate_atoms[3]; + + /* ICCCM2.0-compliant window managers can handle fullscreen windows */ + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -238,7 +285,7 @@ if (window->flags & SDL_WINDOW_OPENGL) { XVisualInfo *vinfo; - vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); + vinfo = X11_GL_GetVisual(_this, display, screen); if (!vinfo) { return -1; } @@ -251,7 +298,7 @@ if (window->flags & SDL_WINDOW_OPENGL) { XVisualInfo *vinfo; - vinfo = X11_GLES_GetVisual(_this, data->display, displaydata->screen); + vinfo = X11_GLES_GetVisual(_this, display, screen); if (!vinfo) { return -1; } @@ -265,7 +312,7 @@ depth = displaydata->depth; } - if (window->flags & SDL_WINDOW_FULLSCREEN) { + if (oldstyle_fullscreen) { xattr.override_redirect = True; } else { xattr.override_redirect = False; @@ -289,16 +336,13 @@ Sint32 r, g, b; /* Is the colormap we need already registered in SDL? */ - if (colormap = - X11_LookupColormap(data->display, - displaydata->screen, visual->visualid)) { + if ((colormap = + X11_LookupColormap(display, screen, visual->visualid))) { xattr.colormap = colormap; /* printf("found existing colormap\n"); */ } else { /* The colormap is not known to SDL so we will create it */ - colormap = XCreateColormap(data->display, - RootWindow(data->display, - displaydata->screen), + colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); /* printf("colormap = %x\n", colormap); */ @@ -377,11 +421,10 @@ } /* status = */ -/* XStoreColors(data->display, colormap, colorcells, ncolors); */ +/* XStoreColors(display, colormap, colorcells, ncolors); */ xattr.colormap = colormap; - X11_TrackColormap(data->display, displaydata->screen, - colormap, visual, NULL); + X11_TrackColormap(display, screen, colormap, visual, NULL); SDL_free(colorcells); } @@ -397,15 +440,12 @@ /* Is the colormap we need already registered in SDL? */ if ((colormap = - X11_LookupColormap(data->display, - displaydata->screen, visual->visualid))) { + X11_LookupColormap(display, screen, visual->visualid))) { xattr.colormap = colormap; /* printf("found existing colormap\n"); */ } else { /* The colormap is not known to SDL so we will create it */ - colormap = XCreateColormap(data->display, - RootWindow(data->display, - displaydata->screen), + colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); /* printf("colormap = %x\n", colormap); */ @@ -417,7 +457,6 @@ } /* OK, we got a colormap, now fill it in as best as we can */ - colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); if (NULL == colorcells) { SDL_SetError("out of memory in X11_CreateWindow"); @@ -479,22 +518,20 @@ } status = - XStoreColors(data->display, colormap, colorcells, ncolors); + XStoreColors(display, colormap, colorcells, ncolors); xattr.colormap = colormap; - X11_TrackColormap(data->display, displaydata->screen, - colormap, visual, colorcells); + X11_TrackColormap(display, screen, colormap, visual, colorcells); SDL_free(colorcells); } } else { xattr.colormap = - XCreateColormap(data->display, - RootWindow(data->display, displaydata->screen), + XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); } - if ((window->flags & SDL_WINDOW_FULLSCREEN) + if (oldstyle_fullscreen || window->x == SDL_WINDOWPOS_CENTERED) { X11_GetDisplaySize(_this, window, &x, NULL); x = (x - window->w) / 2; @@ -503,7 +540,7 @@ } else { x = window->x; } - if ((window->flags & SDL_WINDOW_FULLSCREEN) + if (oldstyle_fullscreen || window->y == SDL_WINDOWPOS_CENTERED) { X11_GetDisplaySize(_this, window, NULL, &y); y = (y - window->h) / 2; @@ -513,8 +550,7 @@ y = window->y; } - w = XCreateWindow(data->display, - RootWindow(data->display, displaydata->screen), x, y, + w = XCreateWindow(display, RootWindow(display, screen), x, y, window->w, window->h, 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap), &xattr); @@ -539,23 +575,23 @@ sizehints = XAllocSizeHints(); if (sizehints) { if (!(window->flags & SDL_WINDOW_RESIZABLE) - || (window->flags & SDL_WINDOW_FULLSCREEN)) { + || oldstyle_fullscreen) { sizehints->min_width = sizehints->max_width = window->w; sizehints->min_height = sizehints->max_height = window->h; sizehints->flags = PMaxSize | PMinSize; } - if (!(window->flags & SDL_WINDOW_FULLSCREEN) + if (!oldstyle_fullscreen && window->x != SDL_WINDOWPOS_UNDEFINED && window->y != SDL_WINDOWPOS_UNDEFINED) { sizehints->x = x; sizehints->y = y; sizehints->flags |= USPosition; } - XSetWMNormalHints(data->display, w, sizehints); + XSetWMNormalHints(display, w, sizehints); XFree(sizehints); } - if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) { + if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) { SDL_bool set; Atom WM_HINTS; @@ -563,7 +599,7 @@ set = SDL_FALSE; /* First try to set MWM hints */ - WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); + WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { /* Hints used by Motif compliant window managers */ struct @@ -576,40 +612,36 @@ } MWMHints = { (1L << 1), 0, 0, 0, 0}; - XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32, + XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, PropModeReplace, (unsigned char *) &MWMHints, - sizeof(MWMHints) / sizeof(long)); + sizeof(MWMHints) / 4); set = SDL_TRUE; } /* Now try to set KWM hints */ - WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); + WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True); if (WM_HINTS != None) { long KWMHints = 0; - XChangeProperty(data->display, w, - WM_HINTS, WM_HINTS, 32, + XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, PropModeReplace, (unsigned char *) &KWMHints, - sizeof(KWMHints) / sizeof(long)); + sizeof(KWMHints) / 4); set = SDL_TRUE; } /* Now try to set GNOME hints */ - WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); + WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); if (WM_HINTS != None) { long GNOMEHints = 0; - XChangeProperty(data->display, w, - WM_HINTS, WM_HINTS, 32, + XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32, PropModeReplace, (unsigned char *) &GNOMEHints, - sizeof(GNOMEHints) / sizeof(long)); + sizeof(GNOMEHints) / 4); set = SDL_TRUE; } /* Finally set the transient hints if necessary */ if (!set) { - XSetTransientForHint(data->display, w, - RootWindow(data->display, - displaydata->screen)); + XSetTransientForHint(display, w, RootWindow(display, screen)); } } else { SDL_bool set; @@ -619,53 +651,36 @@ set = SDL_FALSE; /* First try to unset MWM hints */ - WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True); + WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { - XDeleteProperty(data->display, w, WM_HINTS); + XDeleteProperty(display, w, WM_HINTS); set = SDL_TRUE; } /* Now try to unset KWM hints */ - WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True); + WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True); if (WM_HINTS != None) { - XDeleteProperty(data->display, w, WM_HINTS); + XDeleteProperty(display, w, WM_HINTS); set = SDL_TRUE; } /* Now try to unset GNOME hints */ - WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True); + WM_HINTS = XInternAtom(display, "_WIN_HINTS", True); if (WM_HINTS != None) { - XDeleteProperty(data->display, w, WM_HINTS); + XDeleteProperty(display, w, WM_HINTS); set = SDL_TRUE; } /* Finally unset the transient hints if necessary */ if (!set) { /* NOTE: Does this work? */ - XSetTransientForHint(data->display, w, None); + XSetTransientForHint(display, w, None); } } - /* Tell KDE to keep fullscreen windows on top */ - if (window->flags & SDL_WINDOW_FULLSCREEN) { - XEvent ev; - - SDL_zero(ev); - ev.xclient.type = ClientMessage; - ev.xclient.window = RootWindow(data->display, displaydata->screen); - ev.xclient.message_type = - XInternAtom(data->display, "KWM_KEEP_ON_TOP", False); - ev.xclient.format = 32; - ev.xclient.data.l[0] = w; - ev.xclient.data.l[1] = CurrentTime; - XSendEvent(data->display, - RootWindow(data->display, displaydata->screen), False, - SubstructureRedirectMask, &ev); - } - /* Set the input hints so we get keyboard input */ wmhints = XAllocWMHints(); if (wmhints) { wmhints->input = True; wmhints->flags = InputHint; - XSetWMHints(data->display, w, wmhints); + XSetWMHints(display, w, wmhints); XFree(wmhints); } @@ -674,15 +689,32 @@ if (classhints != NULL) { classhints->res_name = data->classname; classhints->res_class = data->classname; - XSetClassHint(data->display, w, classhints); + XSetClassHint(display, w, classhints); XFree(classhints); } + /* Set the window manager state */ + wmstate_count = X11_GetWMStateProperty(_this, window, wmstate_atoms); + if (wmstate_count > 0) { + XChangeProperty(display, w, data->_NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, + (unsigned char *)wmstate_atoms, wmstate_count); + } else { + XDeleteProperty(display, w, data->_NET_WM_STATE); + } + + /* Let the window manager know we're a "normal" window */ + _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, + PropModeReplace, + (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1); + /* Allow the window to be deleted by the window manager */ - XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); + XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1); if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { - XDestroyWindow(data->display, w); + XDestroyWindow(display, w); return -1; } #ifdef X_HAVE_UTF8_STRING @@ -690,7 +722,7 @@ Uint32 fevent = 0; pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, XNFilterEvents, &fevent, NULL); - XSelectInput(data->display, w, + XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | @@ -699,7 +731,7 @@ } #else { - XSelectInput(data->display, w, + XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | @@ -716,7 +748,7 @@ { Window w = (Window) data; - /* FIXME: Query the title from the existing window */ + window->title = X11_GetWindowTitle(_this, w); if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { return -1; @@ -724,6 +756,36 @@ return 0; } +char * +X11_GetWindowTitle(_THIS, Window xwindow) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + Display *display = data->display; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left; + unsigned char *propdata; + char *title = NULL; + + status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, + 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); + if (status == Success) { + title = SDL_strdup(SDL_static_cast(char*, propdata)); + XFree(propdata); + } else { + status = XGetWindowProperty(display, xwindow, XA_WM_NAME, + 0L, 8192L, False, XA_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); + if (status == Success) { + title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1); + } else { + title = SDL_strdup(""); + } + } + return title; +} + void X11_SetWindowTitle(_THIS, SDL_Window * window) { @@ -735,14 +797,8 @@ const char *icon = NULL; #ifdef X_HAVE_UTF8_STRING - Atom _NET_WM_NAME = 0; - Atom _NET_WM_ICON_NAME = 0; - - /* Look up some useful Atoms */ - if (SDL_X11_HAVE_UTF8) { - _NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False); - _NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False); - } + Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME; + Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME; #endif if (title != NULL) { @@ -803,13 +859,13 @@ { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - Atom _NET_WM_ICON = XInternAtom(display, "_NET_WM_ICON", False); + Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON; if (icon) { SDL_PixelFormat format; SDL_Surface *surface; int propsize; - Uint32 *propdata; + long *propdata; /* Convert the icon to ARGB for modern window managers */ SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, @@ -823,10 +879,19 @@ propsize = 2 + (icon->w * icon->h); propdata = SDL_malloc(propsize * sizeof(Uint32)); if (propdata) { + int x, y; + Uint32 *src; + long *dst; + propdata[0] = icon->w; propdata[1] = icon->h; - SDL_memcpy(&propdata[2], surface->pixels, - surface->h * surface->pitch); + dst = &propdata[2]; + for (y = 0; y < icon->h; ++y) { + src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch); + for (x = 0; x < icon->w; ++x) { + *dst++ = *src++; + } + } XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) propdata, propsize); @@ -842,16 +907,20 @@ { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; + SDL_bool oldstyle_fullscreen; int x, y; - if ((window->flags & SDL_WINDOW_FULLSCREEN) + /* ICCCM2.0-compliant window managers can handle fullscreen windows */ + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); + + if (oldstyle_fullscreen || window->x == SDL_WINDOWPOS_CENTERED) { X11_GetDisplaySize(_this, window, &x, NULL); x = (x - window->w) / 2; } else { x = window->x; } - if ((window->flags & SDL_WINDOW_FULLSCREEN) + if (oldstyle_fullscreen || window->y == SDL_WINDOWPOS_CENTERED) { X11_GetDisplaySize(_this, window, NULL, &y); y = (y - window->h) / 2; @@ -904,26 +973,45 @@ SDL_DisplayData *displaydata = (SDL_DisplayData *) window->display->driverdata; Display *display = data->videodata->display; - Atom _NET_WM_STATE = XInternAtom(display, "_NET_WM_STATE", False); - Atom _NET_WM_STATE_MAXIMIZED_VERT = - XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False); - Atom _NET_WM_STATE_MAXIMIZED_HORZ = - XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); - XEvent e; + Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT; + e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; + e.xclient.data.l[3] = 0l; - e.xany.type = ClientMessage; - e.xany.window = data->xwindow; - e.xclient.message_type = _NET_WM_STATE; - e.xclient.format = 32; - e.xclient.data.l[0] = - maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; - e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT; - e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; - e.xclient.data.l[3] = 0l; - e.xclient.data.l[4] = 0l; + XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + int count = 0; + Atom atoms[3]; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + if (window->flags & SDL_WINDOW_FULLSCREEN) { + atoms[count++] = _NET_WM_STATE_FULLSCREEN; + } + if (maximized) { + atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT; + atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ; + } + if (count > 0) { + XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char *)atoms, count); + } else { + XDeleteProperty(display, data->xwindow, _NET_WM_STATE); + } + } } void @@ -935,7 +1023,12 @@ void X11_MinimizeWindow(_THIS, SDL_Window * window) { - X11_HideWindow(_this, window); + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_DisplayData *displaydata = + (SDL_DisplayData *) window->display->driverdata; + Display *display = data->videodata->display; + + XIconifyWindow(display, data->xwindow, displaydata->screen); } void @@ -950,8 +1043,12 @@ { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; + SDL_bool oldstyle_fullscreen; - if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) + /* ICCCM2.0-compliant window managers can handle fullscreen windows */ + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); + + if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { /* Try to grab the mouse */ for (;;) { @@ -1014,8 +1111,14 @@ SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) { - if (info->version.major <= SDL_MAJOR_VERSION) { - /* FIXME! */ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + + if (info->version.major == SDL_MAJOR_VERSION && + info->version.minor == SDL_MINOR_VERSION) { + info->subsystem = SDL_SYSWM_X11; + info->info.x11.display = display; + info->info.x11.window = data->xwindow; return SDL_TRUE; } else { SDL_SetError("Application not compiled with SDL %d.%d\n",
--- a/src/video/x11/SDL_x11window.h Tue Jul 13 15:05:45 2010 -0400 +++ b/src/video/x11/SDL_x11window.h Sun Jul 18 13:48:23 2010 -0400 @@ -35,6 +35,7 @@ extern int X11_CreateWindow(_THIS, SDL_Window * window); extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +extern char *X11_GetWindowTitle(_THIS, Window xwindow); extern void X11_SetWindowTitle(_THIS, SDL_Window * window); extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); extern void X11_SetWindowPosition(_THIS, SDL_Window * window);
--- a/test/common.c Tue Jul 13 15:05:45 2010 -0400 +++ b/test/common.c Sun Jul 18 13:48:23 2010 -0400 @@ -6,7 +6,7 @@ #include "common.h" #define VIDEO_USAGE \ -"[--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]" +"[--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]" #define AUDIO_USAGE \ "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]" @@ -192,6 +192,14 @@ state->window_title = argv[index]; return 2; } + if (SDL_strcasecmp(argv[index], "--icon") == 0) { + ++index; + if (!argv[index]) { + return -1; + } + state->window_icon = argv[index]; + return 2; + } if (SDL_strcasecmp(argv[index], "--center") == 0) { state->window_x = SDL_WINDOWPOS_CENTERED; state->window_y = SDL_WINDOWPOS_CENTERED; @@ -611,6 +619,30 @@ } } +static SDL_Surface * +LoadIcon(const char *file) +{ + SDL_Surface *icon; + + /* Load the icon surface */ + icon = SDL_LoadBMP(file); + if (icon == NULL) { + fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); + return (NULL); + } + + if (icon->format->palette == NULL) { + fprintf(stderr, "Icon must have a palette!\n"); + SDL_FreeSurface(icon); + return (NULL); + } + + /* Set the colorkey */ + SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels)); + + return (icon); +} + SDL_bool CommonInit(CommonState * state) { @@ -791,6 +823,15 @@ SDL_GetError()); return SDL_FALSE; } + + if (state->window_icon) { + SDL_Surface *icon = LoadIcon(state->window_icon); + if (icon) { + SDL_SetWindowIcon(state->windows[i], icon); + SDL_FreeSurface(icon); + } + } + SDL_ShowWindow(state->windows[i]); if (!state->skip_renderer @@ -1017,6 +1058,9 @@ fprintf(stderr, "Joystick %d: button %d released", event->jbutton.which, event->jbutton.button); break; + case SDL_CLIPBOARDUPDATE: + fprintf(stderr, "Clipboard updated"); + break; case SDL_QUIT: fprintf(stderr, "Quit requested"); break; @@ -1050,11 +1094,43 @@ case SDL_KEYDOWN: switch (event->key.keysym.sym) { /* Add hotkeys here */ + case SDLK_c: + if (event->key.keysym.mod & KMOD_CTRL) { + /* Ctrl-C copy awesome text! */ + SDL_SetClipboardText("SDL rocks!\nYou know it!"); + printf("Copied text to clipboard\n"); + } + break; + case SDLK_v: + if (event->key.keysym.mod & KMOD_CTRL) { + /* Ctrl-V paste awesome text! */ + char *text = SDL_GetClipboardText(); + if (*text) { + printf("Clipboard: %s\n", text); + } else { + printf("Clipboard is empty\n"); + } + SDL_free(text); + } + break; case SDLK_g: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-G toggle grab */ } break; + case SDLK_m: + if (event->key.keysym.mod & KMOD_CTRL) { + /* Ctrl-M maximize */ + /* FIXME: Which window has focus for this keyboard? */ + for (i = 0; i < state->num_windows; ++i) { + if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) { + SDL_RestoreWindow(state->windows[i]); + } else { + SDL_MaximizeWindow(state->windows[i]); + } + } + } + break; case SDLK_z: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Z minimize */