From 221b03a7cda31c7716a5fcd7691ae52f8aa0bdc5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 6 Jul 2010 08:22:36 -0700 Subject: [PATCH 01/53] Fixed fullscreen window position Fixed position calculation for centered windows --- src/video/win32/SDL_win32window.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c index fc1cd154f..c84d91568 100644 --- a/src/video/win32/SDL_win32window.c +++ b/src/video/win32/SDL_win32window.c @@ -184,7 +184,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) { SDL_VideoDisplay *display = window->display; HWND hwnd; - HWND top; RECT rect; SDL_Rect bounds; DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN); @@ -202,11 +201,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) } /* Figure out what the window area will be */ - if (window->flags & SDL_WINDOW_FULLSCREEN) { - top = HWND_TOPMOST; - } else { - top = HWND_NOTOPMOST; - } rect.left = 0; rect.top = 0; rect.right = window->w; @@ -216,9 +210,17 @@ WIN_CreateWindow(_THIS, SDL_Window * window) h = (rect.bottom - rect.top); WIN_GetDisplayBounds(_this, display, &bounds); + if (window->flags & SDL_WINDOW_FULLSCREEN) { + /* The bounds when this window is visible is the fullscreen mode */ + SDL_DisplayMode fullscreen_mode; + if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { + bounds.w = fullscreen_mode.w; + bounds.h = fullscreen_mode.h; + } + } if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) { - x = bounds.x + (bounds.w - window->w) / 2; + x = bounds.x + (bounds.w - w) / 2; } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { if (bounds.x == 0) { x = CW_USEDEFAULT; @@ -230,7 +232,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) } if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) { - y = bounds.y + (bounds.h - window->h) / 2; + y = bounds.y + (bounds.h - h) / 2; } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { if (bounds.x == 0) { y = CW_USEDEFAULT; @@ -387,6 +389,7 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) HWND top; BOOL menu; int x, y; + int w, h; /* Figure out what the window area will be */ if (window->flags & SDL_WINDOW_FULLSCREEN) { @@ -405,17 +408,27 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); #endif AdjustWindowRectEx(&rect, style, menu, 0); + w = (rect.right - rect.left); + h = (rect.bottom - rect.top); WIN_GetDisplayBounds(_this, display, &bounds); + if (window->flags & SDL_WINDOW_FULLSCREEN) { + /* The bounds when this window is visible is the fullscreen mode */ + SDL_DisplayMode fullscreen_mode; + if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { + bounds.w = fullscreen_mode.w; + bounds.h = fullscreen_mode.h; + } + } if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) { - x = bounds.x + (bounds.w - window->w) / 2; + x = bounds.x + (bounds.w - w) / 2; } else { x = bounds.x + window->x + rect.left; } if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) { - y = bounds.y + (bounds.h - window->h) / 2; + y = bounds.y + (bounds.h - h) / 2; } else { y = bounds.y + window->y + rect.top; } From 2be04296761479aac3de9396508169f453f20725 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 6 Jul 2010 10:58:23 -0700 Subject: [PATCH 02/53] Removed obsolete header file --- VisualC/SDL/SDL_VS2005.vcproj | 4 ---- VisualC/SDL/SDL_VS2008.vcproj | 7 +++---- VisualC/SDLmain/SDLmain_VS2008.vcproj | 9 ++++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/VisualC/SDL/SDL_VS2005.vcproj b/VisualC/SDL/SDL_VS2005.vcproj index 9ae52b1ea..d58446605 100644 --- a/VisualC/SDL/SDL_VS2005.vcproj +++ b/VisualC/SDL/SDL_VS2005.vcproj @@ -840,10 +840,6 @@ RelativePath="..\..\src\video\SDL_stretch.c" > - - diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index bbf91e43a..7cf5d4a1a 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -5,6 +5,9 @@ Name="SDL" ProjectGUID="{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" RootNamespace="SDL" + SccProjectName="Perforce Project" + SccLocalPath="..\.." + SccProvider="MSSCCI:Perforce SCM" TargetFrameworkVersion="131072" > @@ -995,10 +998,6 @@ RelativePath="..\..\src\video\SDL_stretch.c" > - - diff --git a/VisualC/SDLmain/SDLmain_VS2008.vcproj b/VisualC/SDLmain/SDLmain_VS2008.vcproj index 2ef814201..ac482184a 100644 --- a/VisualC/SDLmain/SDLmain_VS2008.vcproj +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj @@ -4,6 +4,9 @@ Version="9.00" Name="SDLmain" ProjectGUID="{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" + SccProjectName="Perforce Project" + SccLocalPath="..\.." + SccProvider="MSSCCI:Perforce SCM" TargetFrameworkVersion="131072" > @@ -29,7 +32,7 @@ Date: Tue, 6 Jul 2010 22:08:19 -0700 Subject: [PATCH 03/53] Re-implemented single mouse touches on the iPhone/iPad --- src/video/uikit/SDL_uikitopengles.m | 5 +++- src/video/uikit/SDL_uikitview.h | 2 +- src/video/uikit/SDL_uikitview.m | 43 +++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index 76c3c02a1..b10984343 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -125,7 +125,10 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) UIKit_GL_DeleteContext(_this, view); return NULL; } - + + /* Make this window the current mouse focus for touch input */ + SDL_SetMouseFocus(window); + return view; } diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index 3e0315704..341e1cbe3 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -38,7 +38,7 @@ #else @interface SDL_uikitview : UIView { #endif - + #if FIXME_MULTITOUCH SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; #endif diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index da03d0c2e..f985f50a1 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -64,7 +64,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 +101,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 +123,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 Date: Tue, 6 Jul 2010 22:26:03 -0700 Subject: [PATCH 04/53] The arguments to main() should be NULL terminated (SuS v3 compliant) --- src/video/uikit/SDL_uikitappdelegate.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index ac2992d32..5b18e27f2 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -42,11 +42,12 @@ int main(int argc, char **argv) { /* store arguments */ forward_argc = argc; - forward_argv = (char **)malloc(argc * sizeof(char *)); + forward_argv = (char **)malloc((argc+1) * sizeof(char *)); for (i=0; i Date: Wed, 7 Jul 2010 18:58:51 -0700 Subject: [PATCH 05/53] Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now) Updated iPhone demos (which build and run again) --- .../DemosiPhoneOS.xcodeproj/project.pbxproj | 19 ++++++++++++-- Xcode-iPhoneOS/Demos/src/fireworks.c | 2 -- Xcode-iPhoneOS/Demos/src/mixer.c | 5 ++-- Xcode-iPhoneOS/Demos/src/touch.c | 1 - .../TestiPhoneOS.xcodeproj/project.pbxproj | 25 +++++++++++++----- include/SDL_config_iphoneos.h | 7 ++--- src/events/SDL_keyboard.c | 4 +++ src/video/uikit/SDL_uikitopengles.m | 3 +++ src/video/uikit/SDL_uikitview.h | 2 -- src/video/uikit/SDL_uikitview.m | 26 +++++++------------ 10 files changed, 55 insertions(+), 39 deletions(-) diff --git a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj index e7c99eae7..aaf5d1279 100755 --- a/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj +++ b/Xcode-iPhoneOS/Demos/DemosiPhoneOS.xcodeproj/project.pbxproj @@ -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 = ""; @@ -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; }; diff --git a/Xcode-iPhoneOS/Demos/src/fireworks.c b/Xcode-iPhoneOS/Demos/src/fireworks.c index 1b9378cb1..ba1949524 100644 --- a/Xcode-iPhoneOS/Demos/src/fireworks.c +++ b/Xcode-iPhoneOS/Demos/src/fireworks.c @@ -430,9 +430,7 @@ main(int argc, char *argv[]) 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); } diff --git a/Xcode-iPhoneOS/Demos/src/mixer.c b/Xcode-iPhoneOS/Demos/src/mixer.c index a8a25203f..f5808d62e 100644 --- a/Xcode-iPhoneOS/Demos/src/mixer.c +++ b/Xcode-iPhoneOS/Demos/src/mixer.c @@ -124,10 +124,9 @@ handleMouseButtonDown(SDL_Event * event) 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 @@ void 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) { diff --git a/Xcode-iPhoneOS/Demos/src/touch.c b/Xcode-iPhoneOS/Demos/src/touch.c index b171415d0..bdaf3b754 100644 --- a/Xcode-iPhoneOS/Demos/src/touch.c +++ b/Xcode-iPhoneOS/Demos/src/touch.c @@ -106,7 +106,6 @@ main(int argc, char *argv[]) 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? */ diff --git a/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj index 6cf2ad995..dce7d25cb 100755 --- a/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj +++ b/Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj @@ -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 = ""; }; 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 = ""; }; 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 = ""; @@ -877,6 +879,7 @@ isa = PBXGroup; children = ( FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */, + 0466EE7011E565E4000198A4 /* testsdl.app */, ); name = Products; sourceTree = ""; @@ -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; }; diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index f9271766c..6e031114b 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -145,12 +145,9 @@ typedef unsigned long uintptr_t; #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 diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index f25bc6af8..a2687bd26 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -551,6 +551,10 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst) 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); } diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index b10984343..8d9839daf 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -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 @@ -128,6 +130,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) /* Make this window the current mouse focus for touch input */ SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); return view; } diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index 341e1cbe3..ca7924b92 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -22,8 +22,6 @@ #import #include "SDL_stdinc.h" -#include "SDL_mouse.h" -#include "SDL_mouse_c.h" #include "SDL_events.h" #if SDL_IPHONE_MULTIPLE_MICE diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index f985f50a1..879ac0464 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -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]; @@ -225,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 */ @@ -253,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 @@ -280,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); } } } From 46bbcfe087ff79bfd93535f8fe99189d11c71997 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 21:35:44 -0700 Subject: [PATCH 06/53] Turn on blending if we're converting from a surface with colorkey enabled --- src/video/SDL_surface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 37740b2d4..16bce3c1b 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -851,7 +851,7 @@ SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format, /* 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)) { From a517ddf4a569a1ba8a691ceb03b08ac48d30f5ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 21:36:09 -0700 Subject: [PATCH 07/53] Added SDL_FOURCC() --- include/SDL_pixels.h | 3 +-- include/SDL_stdinc.h | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 6934105aa..6024dcd0b 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -112,8 +112,7 @@ enum 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) | \ diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index c7e7edd57..ba1e5b5b2 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -101,6 +101,13 @@ #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 */ From 261b8d8865843183e3df715eb1034cc86620e439 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 23:24:04 -0700 Subject: [PATCH 08/53] First pass at clipboard API, still very much in progress --- include/SDL.h | 1 + include/SDL_clipboard.h | 125 ++++++++++++++++++++++++++++++++++++++ src/video/SDL_clipboard.c | 101 ++++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 include/SDL_clipboard.h create mode 100644 src/video/SDL_clipboard.c diff --git a/include/SDL.h b/include/SDL.h index 21c0cbe62..349010d39 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -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" diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h new file mode 100644 index 000000000..8cd51f30d --- /dev/null +++ b/include/SDL_clipboard.h @@ -0,0 +1,125 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 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 "SDL_surface.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 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(); + +/** + * \brief Returns whether the clipboard has text + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(); + +/** + * \brief Put an image into the clipboard + * + * \sa SDL_GetClipboardImage() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardImage(SDL_Surface *image); + +/** + * \brief Get image from the clipboard, which must be freed with SDL_FreeSurface() + * + * \sa SDL_SetClipboard() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetClipboardImage(); + +/** + * \brief Returns whether the clipboard has data in the specified format + * + * \sa SDL_GetClipboardImage() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardImage(); + +/** + * \brief Set the data in the clipboard in the specified format + * + * \sa SDL_GetClipboard() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboard(Uint32 format, void *data, size_t length); + +/** + * \brief Get the data in the clipboard in the specified format, which must be + * freed with SDL_free() + * + * \sa SDL_SetClipboard() + */ +extern DECLSPEC int SDLCALL SDL_GetClipboard(Uint32 format, void **data, size_t *length); + +/** + * \brief Returns whether the clipboard has data in the specified format + * + * \sa SDL_GetClipboard() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardFormat(Uint32 format); + +/** + * \brief Clear any data out of the clipboard, if possible. + */ +extern DECLSPEC void SDLCALL SDL_ClearClipboard(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: */ diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c new file mode 100644 index 000000000..fe33216de --- /dev/null +++ b/src/video/SDL_clipboard.c @@ -0,0 +1,101 @@ +/* + 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" + +/* FOURCC values for text and image clipboard formats */ +#define TEXT_DATA SDL_FOURCC('T', 'E', 'X', 'T') +#define IMAGE_DATA SDL_FOURCC('B', 'M', 'P', ' ') + +int +SDL_SetClipboardText(const char *text) +{ + return SDL_SetClipboard(TEXT_DATA, text, SDL_strlen(text)+1); +} + +char * +SDL_GetClipboardText() +{ + void *data; + size_t length; + + if (SDL_GetClipboard(TEXT_DATA, &data, &length) == 0) { + return SDL_static_cast(char*, data); + } else { + return NULL; + } +} + +SDL_bool +SDL_HasClipboardText() +{ + return SDL_HasClipboardFormat(TEXT_DATA); +} + +int +SDL_SetClipboardImage(SDL_Surface *image) +{ + SDL_Unsupported(); + return -1; +} + +SDL_Surface * +SDL_GetClipboardImage() +{ + SDL_Unsupported(); + return NULL; +} + +SDL_bool +SDL_HasClipboardImage() +{ + return SDL_FALSE; +} + +int +SDL_SetClipboard(Uint32 format, void *data, size_t length) +{ + SDL_Unsupported(); + return -1; +} + +int +SDL_GetClipboard(Uint32 format, void **data, size_t *length) +{ + SDL_Unsupported(); + return -1; +} + +SDL_bool +SDL_HasClipboardFormat(Uint32 format) +{ + return SDL_FALSE; +} + +void +SDL_ClearClipboard(void) +{ +} + +/* vi: set ts=4 sw=4 expandtab: */ From 2612b4c651b01184570aa99ed97a1510b8cd68a0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 23:26:07 -0700 Subject: [PATCH 09/53] Whoops, updated the copyright date --- include/SDL_clipboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h index 8cd51f30d..872c465c3 100644 --- a/include/SDL_clipboard.h +++ b/include/SDL_clipboard.h @@ -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 From e4fe1bb40f39dbec5bbe7712c98a6ee1f41737b0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 23:54:03 -0700 Subject: [PATCH 10/53] Simplified clipboard API for sanity's sake. A complete clipboard implementation would support multiple formats that could be queried at runtime, events for when the clipboard contents changed, support for HTML, images, etc. We're not going that crazy, at least for now. :) --- include/SDL_clipboard.h | 53 +------------------------- src/video/SDL_clipboard.c | 80 +++++++++++++-------------------------- src/video/SDL_sysvideo.h | 6 +++ src/video/SDL_video.c | 4 ++ 4 files changed, 38 insertions(+), 105 deletions(-) diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h index 872c465c3..848c21d12 100644 --- a/include/SDL_clipboard.h +++ b/include/SDL_clipboard.h @@ -30,7 +30,6 @@ #define _SDL_clipboard_h #include "SDL_stdinc.h" -#include "SDL_surface.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -43,14 +42,14 @@ extern "C" { /* Function prototypes */ /** - * \brief Put text into the clipboard + * \brief Put UTF-8 text into the clipboard * * \sa SDL_GetClipboardText() */ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); /** - * \brief Get text from the clipboard, which must be freed with SDL_free() + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() * * \sa SDL_SetClipboardText() */ @@ -63,54 +62,6 @@ extern DECLSPEC char * SDLCALL SDL_GetClipboardText(); */ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(); -/** - * \brief Put an image into the clipboard - * - * \sa SDL_GetClipboardImage() - */ -extern DECLSPEC int SDLCALL SDL_SetClipboardImage(SDL_Surface *image); - -/** - * \brief Get image from the clipboard, which must be freed with SDL_FreeSurface() - * - * \sa SDL_SetClipboard() - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_GetClipboardImage(); - -/** - * \brief Returns whether the clipboard has data in the specified format - * - * \sa SDL_GetClipboardImage() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardImage(); - -/** - * \brief Set the data in the clipboard in the specified format - * - * \sa SDL_GetClipboard() - */ -extern DECLSPEC int SDLCALL SDL_SetClipboard(Uint32 format, void *data, size_t length); - -/** - * \brief Get the data in the clipboard in the specified format, which must be - * freed with SDL_free() - * - * \sa SDL_SetClipboard() - */ -extern DECLSPEC int SDLCALL SDL_GetClipboard(Uint32 format, void **data, size_t *length); - -/** - * \brief Returns whether the clipboard has data in the specified format - * - * \sa SDL_GetClipboard() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardFormat(Uint32 format); - -/** - * \brief Clear any data out of the clipboard, if possible. - */ -extern DECLSPEC void SDLCALL SDL_ClearClipboard(void); - /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index fe33216de..e459f6994 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -24,78 +24,50 @@ #include "SDL_clipboard.h" #include "SDL_sysvideo.h" -/* FOURCC values for text and image clipboard formats */ -#define TEXT_DATA SDL_FOURCC('T', 'E', 'X', 'T') -#define IMAGE_DATA SDL_FOURCC('B', 'M', 'P', ' ') int SDL_SetClipboardText(const char *text) { - return SDL_SetClipboard(TEXT_DATA, text, SDL_strlen(text)+1); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (_this->SetClipboardText) { + return _this->SetClipboardText(_this, text); + } else { + _this->clipboard_text = SDL_strdup(text); + return 0; + } } char * SDL_GetClipboardText() { - void *data; - size_t length; + SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (SDL_GetClipboard(TEXT_DATA, &data, &length) == 0) { - return SDL_static_cast(char*, data); + if (_this->GetClipboardText) { + return _this->GetClipboardText(_this); } else { - return NULL; + const char *text = _this->clipboard_text; + if (!text) { + text = ""; + } + return SDL_strdup(text); } } SDL_bool SDL_HasClipboardText() { - return SDL_HasClipboardFormat(TEXT_DATA); -} + SDL_VideoDevice *_this = SDL_GetVideoDevice(); -int -SDL_SetClipboardImage(SDL_Surface *image) -{ - SDL_Unsupported(); - return -1; -} - -SDL_Surface * -SDL_GetClipboardImage() -{ - SDL_Unsupported(); - return NULL; -} - -SDL_bool -SDL_HasClipboardImage() -{ - return SDL_FALSE; -} - -int -SDL_SetClipboard(Uint32 format, void *data, size_t length) -{ - SDL_Unsupported(); - return -1; -} - -int -SDL_GetClipboard(Uint32 format, void **data, size_t *length) -{ - SDL_Unsupported(); - return -1; -} - -SDL_bool -SDL_HasClipboardFormat(Uint32 format) -{ - return SDL_FALSE; -} - -void -SDL_ClearClipboard(void) -{ + 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: */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 0a82717ec..91b2177cb 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -303,6 +303,11 @@ struct SDL_VideoDevice 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 @@ struct SDL_VideoDevice Uint8 window_magic; Uint8 texture_magic; Uint32 next_object_id; + char * clipboard_text; /* * * */ /* Data used by the GL drivers */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index db8b5d3cb..435f01696 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2833,6 +2833,10 @@ SDL_VideoQuit(void) 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; } From 8697bbff304bdf5cbd2a20e629f25d7526472d59 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 7 Jul 2010 23:59:20 -0700 Subject: [PATCH 11/53] Need to add new headers to Makefile.in --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 87df4de3d..705ec31f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,7 @@ EMBEDSPU = @EMBEDSPU@ 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@ From 4ceea8d275555c3b3fd3b60232d1215e89503df0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 00:00:07 -0700 Subject: [PATCH 12/53] Added simple clipboard test --- test/common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/common.c b/test/common.c index 32d69e2fc..efbccd6f7 100644 --- a/test/common.c +++ b/test/common.c @@ -1050,6 +1050,25 @@ CommonEvent(CommonState * state, SDL_Event * event, int *done) 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 */ From fe0b80fa0508eb6d9e9781564940255e375a5288 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 00:03:39 -0700 Subject: [PATCH 13/53] I missed the Objective C files when updating the copyright date... --- src/video/cocoa/SDL_cocoaevents.m | 2 +- src/video/cocoa/SDL_cocoakeyboard.m | 2 +- src/video/cocoa/SDL_cocoamodes.m | 2 +- src/video/cocoa/SDL_cocoamouse.m | 2 +- src/video/cocoa/SDL_cocoaopengl.m | 2 +- src/video/cocoa/SDL_cocoavideo.m | 2 +- src/video/cocoa/SDL_cocoawindow.m | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index d833400e9..d1164e5c2 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 9fd89d15d..83e743f50 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index b26905bc9..4b120a68e 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index e3d70bfac..c0ac2feaf 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index e80e310b5..41ab75d98 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 86e19fda7..b537e8a83 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -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 diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index be4045c89..af84bff2f 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -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 From 01e31dbb3052d122df6439896de2ce5cd486a729 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 00:35:58 -0700 Subject: [PATCH 14/53] Added Mac OS X implementation of clipboard support --- src/video/cocoa/SDL_cocoaclipboard.h | 33 +++++++ src/video/cocoa/SDL_cocoaclipboard.m | 123 +++++++++++++++++++++++++++ src/video/cocoa/SDL_cocoavideo.h | 1 + src/video/cocoa/SDL_cocoavideo.m | 4 + 4 files changed, 161 insertions(+) create mode 100644 src/video/cocoa/SDL_cocoaclipboard.h create mode 100644 src/video/cocoa/SDL_cocoaclipboard.m diff --git a/src/video/cocoa/SDL_cocoaclipboard.h b/src/video/cocoa/SDL_cocoaclipboard.h new file mode 100644 index 000000000..8e4619b95 --- /dev/null +++ b/src/video/cocoa/SDL_cocoaclipboard.h @@ -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_cocoaclipboard_h +#define _SDL_cocoaclipboard_h + +extern int Cocoa_SetClipboardText(_THIS, const char *text); +extern char *Cocoa_GetClipboardText(_THIS); +extern SDL_bool Cocoa_HasClipboardText(_THIS); + +#endif /* _SDL_cocoaclipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m new file mode 100644 index 000000000..ea86446a0 --- /dev/null +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -0,0 +1,123 @@ +/* + 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" + + +int +Cocoa_SetClipboardText(_THIS, const char *text) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format; + + if (data->osversion >= 0x1060) { + format = NSPasteboardTypeString; + } else { + format = NSStringPboardType; + } + + pool = [[NSAutoreleasePool alloc] init]; + + pasteboard = [NSPasteboard generalPasteboard]; + [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; + [pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; + + [pool release]; + + return 0; +} + +char * +Cocoa_GetClipboardText(_THIS) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format; + NSString *available; + char *text; + + if (data->osversion >= 0x1060) { + format = NSPasteboardTypeString; + } else { + format = NSStringPboardType; + } + + 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) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + NSAutoreleasePool *pool; + NSPasteboard *pasteboard; + NSString *format; + NSString *available; + SDL_bool result; + + if (data->osversion >= 0x1060) { + format = NSPasteboardTypeString; + } else { + format = NSStringPboardType; + } + + 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; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index 8f12dc056..402cdccb5 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -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" diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index b537e8a83..e4b58cb67 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -108,6 +108,10 @@ Cocoa_CreateDevice(int devindex) 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; From ca5e2aca837580bf5e2c35342c9c5815ad96bf4b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 05:43:34 -0700 Subject: [PATCH 15/53] Added Windows clipboard support --- VisualC/SDL/SDL_VS2005.vcproj | 16 +++ VisualC/SDL/SDL_VS2008.vcproj | 19 +++- VisualC/SDLmain/SDLmain_VS2008.vcproj | 3 - src/video/SDL_clipboard.c | 3 + src/video/win32/SDL_win32clipboard.c | 144 ++++++++++++++++++++++++++ src/video/win32/SDL_win32clipboard.h | 33 ++++++ src/video/win32/SDL_win32events.c | 13 --- src/video/win32/SDL_win32events.h | 1 - src/video/win32/SDL_win32video.c | 18 ++++ src/video/win32/SDL_win32video.h | 1 + src/video/win32/SDL_win32window.c | 12 +-- 11 files changed, 235 insertions(+), 28 deletions(-) create mode 100644 src/video/win32/SDL_win32clipboard.c create mode 100644 src/video/win32/SDL_win32clipboard.h diff --git a/VisualC/SDL/SDL_VS2005.vcproj b/VisualC/SDL/SDL_VS2005.vcproj index d58446605..0dfa9b77d 100644 --- a/VisualC/SDL/SDL_VS2005.vcproj +++ b/VisualC/SDL/SDL_VS2005.vcproj @@ -235,6 +235,10 @@ RelativePath="..\..\include\SDL_audio.h" > + + @@ -560,6 +564,10 @@ RelativePath="..\..\src\video\SDL_bmp.c" > + + @@ -940,6 +948,14 @@ RelativePath="..\..\src\audio\SDL_wave.h" > + + + + diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index 7cf5d4a1a..d616591fd 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -5,9 +5,6 @@ Name="SDL" ProjectGUID="{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}" RootNamespace="SDL" - SccProjectName="Perforce Project" - SccLocalPath="..\.." - SccProvider="MSSCCI:Perforce SCM" TargetFrameworkVersion="131072" > @@ -385,6 +382,10 @@ RelativePath="..\..\include\SDL_audio.h" > + + @@ -718,6 +719,10 @@ RelativePath="..\..\src\video\SDL_bmp.c" > + + @@ -1098,6 +1103,14 @@ RelativePath="..\..\src\audio\SDL_wave.h" > + + + + diff --git a/VisualC/SDLmain/SDLmain_VS2008.vcproj b/VisualC/SDLmain/SDLmain_VS2008.vcproj index ac482184a..94f4447fd 100644 --- a/VisualC/SDLmain/SDLmain_VS2008.vcproj +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj @@ -4,9 +4,6 @@ Version="9.00" Name="SDLmain" ProjectGUID="{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}" - SccProjectName="Perforce Project" - SccLocalPath="..\.." - SccProvider="MSSCCI:Perforce SCM" TargetFrameworkVersion="131072" > diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index e459f6994..fc7e5fbb6 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -30,6 +30,9 @@ SDL_SetClipboardText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (!text) { + text = ""; + } if (_this->SetClipboardText) { return _this->SetClipboardText(_this, text); } else { diff --git a/src/video/win32/SDL_win32clipboard.c b/src/video/win32/SDL_win32clipboard.c new file mode 100644 index 000000000..950bd444f --- /dev/null +++ b/src/video/win32/SDL_win32clipboard.c @@ -0,0 +1,144 @@ +/* + 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" + + +#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) +{ + 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; + } + } + 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; + } +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32clipboard.h b/src/video/win32/SDL_win32clipboard.h new file mode 100644 index 000000000..36fb79823 --- /dev/null +++ b/src/video/win32/SDL_win32clipboard.h @@ -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_win32clipboard_h +#define _SDL_win32clipboard_h + +extern int WIN_SetClipboardText(_THIS, const char *text); +extern char *WIN_GetClipboardText(_THIS); +extern SDL_bool WIN_HasClipboardText(_THIS); + +#endif /* _SDL_win32clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c index 1ea7e6c10..98affcc3c 100755 --- a/src/video/win32/SDL_win32events.c +++ b/src/video/win32/SDL_win32events.c @@ -585,17 +585,4 @@ SDL_UnregisterApp() } } -/* 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: */ diff --git a/src/video/win32/SDL_win32events.h b/src/video/win32/SDL_win32events.h index 8ba8e8ab1..18e880bf4 100644 --- a/src/video/win32/SDL_win32events.h +++ b/src/video/win32/SDL_win32events.h @@ -31,7 +31,6 @@ extern HINSTANCE SDL_Instance; 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 */ diff --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c index c93d4f72e..2c93885e2 100644 --- a/src/video/win32/SDL_win32video.c +++ b/src/video/win32/SDL_win32video.c @@ -28,6 +28,7 @@ #include "../SDL_pixels_c.h" #include "SDL_win32video.h" +#include "SDL_win32clipboard.h" #include "SDL_d3drender.h" #include "SDL_gdirender.h" @@ -35,6 +36,19 @@ 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 @@ -163,6 +177,10 @@ WIN_CreateDevice(int devindex) device->GL_DeleteContext = WIN_GL_DeleteContext; #endif + device->SetClipboardText = WIN_SetClipboardText; + device->GetClipboardText = WIN_GetClipboardText; + device->HasClipboardText = WIN_HasClipboardText; + device->free = WIN_DeleteDevice; return device; diff --git a/src/video/win32/SDL_win32video.h b/src/video/win32/SDL_win32video.h index 3cfb63219..117999dc9 100644 --- a/src/video/win32/SDL_win32video.h +++ b/src/video/win32/SDL_win32video.h @@ -60,6 +60,7 @@ #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 */ diff --git a/src/video/win32/SDL_win32window.c b/src/video/win32/SDL_win32window.c index c84d91568..0de0bbeb2 100644 --- a/src/video/win32/SDL_win32window.c +++ b/src/video/win32/SDL_win32window.c @@ -633,8 +633,7 @@ SDL_HelperWindowCreate(void) /* 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; } @@ -652,8 +651,7 @@ SDL_HelperWindowCreate(void) 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; } @@ -672,8 +670,7 @@ SDL_HelperWindowDestroy(void) /* 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; @@ -682,8 +679,7 @@ SDL_HelperWindowDestroy(void) /* 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; From f8e47b74025afb374ba124a5854bfcbcece65fce Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 06:16:27 -0700 Subject: [PATCH 16/53] Updated Xcode project files for clipboard API Fixed generation of SDL_revision.h when hg is in the path set up in .bash_profile --- .../SDL/SDLiPhoneOS.xcodeproj/project.pbxproj | 22 +++++++--- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 34 ++++++++++++++- src/video/cocoa/SDL_cocoaclipboard.m | 42 ++++++++----------- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj index 9390f5939..1bbe2a820 100755 --- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj +++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj @@ -67,6 +67,9 @@ 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 */; }; @@ -313,6 +316,9 @@ 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = ""; }; 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = ""; }; 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 = ""; }; 046387370F0B5B7D0041FD65 /* SDL_blendline.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendline.c; sourceTree = ""; }; 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendpoint.c; sourceTree = ""; }; 046387390F0B5B7D0041FD65 /* SDL_blendrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendrect.c; sourceTree = ""; }; @@ -826,19 +832,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 */, - 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */, 04B2ED061025CF9E00F9BC5F /* SDL_config.h */, + 04EC8B501025D12900431D42 /* SDL_config_iphoneos.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 +875,6 @@ FD99B8F20DD52EB400FB1D6B /* SDL_types.h */, FD99B8F30DD52EB400FB1D6B /* SDL_version.h */, FD99B8F40DD52EB400FB1D6B /* SDL_video.h */, - FD99B8F50DD52EB400FB1D6B /* SDL.h */, - FD99B8F60DD52EB400FB1D6B /* SDL_endian.h */, ); name = "Public Headers"; sourceTree = ""; @@ -1023,6 +1031,7 @@ FDA682420DF2374D00F98A1A /* video */ = { isa = PBXGroup; children = ( + 044E5FB711E606EB0076F181 /* SDL_clipboard.c */, FD689F090E26E5D900F90B21 /* uikit */, FDA685F40DF244C800F98A1A /* dummy */, 0495E6850E97408800152DFE /* SDL_glfuncs.h */, @@ -1173,6 +1182,8 @@ 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1411,6 +1422,7 @@ 56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */, 56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */, 006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */, + 044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 75f066373..d280af118 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -438,6 +438,8 @@ 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 */; }; + 044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; }; + 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,6 +448,14 @@ 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 */; }; + 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 */; }; @@ -795,10 +805,15 @@ 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; }; + 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 = ""; }; 046B92100A11B8AD00FB151C /* SDL_dlcompat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_dlcompat.c; sourceTree = ""; }; 04DB838A10FD8C81000519B5 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = ""; }; 04DB838B10FD8C81000519B5 /* SDL_drawrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawrect.c; sourceTree = ""; }; + 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 = ""; }; + 04DEA57711E600A600386CAC /* SDL_cocoaclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaclipboard.h; sourceTree = ""; }; + 04DEA57811E600A600386CAC /* SDL_cocoaclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaclipboard.m; sourceTree = ""; }; 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 = ""; }; @@ -1033,6 +1048,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 */, @@ -1380,6 +1397,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 +1438,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 +1454,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 +1763,9 @@ 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1843,6 +1866,9 @@ 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2035,7 +2061,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 +2228,8 @@ 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2318,6 +2346,8 @@ 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 */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index ea86446a0..77d30594d 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -23,20 +23,28 @@ #include "SDL_cocoavideo.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; - - if (data->osversion >= 0x1060) { - format = NSPasteboardTypeString; - } else { - format = NSStringPboardType; - } + NSString *format = GetTextFormat(_this); pool = [[NSAutoreleasePool alloc] init]; @@ -52,19 +60,12 @@ Cocoa_SetClipboardText(_THIS, const char *text) char * Cocoa_GetClipboardText(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool; NSPasteboard *pasteboard; - NSString *format; + NSString *format = GetTextFormat(_this); NSString *available; char *text; - if (data->osversion >= 0x1060) { - format = NSPasteboardTypeString; - } else { - format = NSStringPboardType; - } - pool = [[NSAutoreleasePool alloc] init]; pasteboard = [NSPasteboard generalPasteboard]; @@ -92,19 +93,12 @@ Cocoa_GetClipboardText(_THIS) SDL_bool Cocoa_HasClipboardText(_THIS) { - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool; NSPasteboard *pasteboard; - NSString *format; + NSString *format = GetTextFormat(_this); NSString *available; SDL_bool result; - if (data->osversion >= 0x1060) { - format = NSPasteboardTypeString; - } else { - format = NSStringPboardType; - } - pool = [[NSAutoreleasePool alloc] init]; pasteboard = [NSPasteboard generalPasteboard]; From 8a86c556fdbf7b3bd954d431eaad121210c22bcf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 06:21:48 -0700 Subject: [PATCH 17/53] Made the new public headers public --- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index d280af118..f9219d47b 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -438,7 +438,7 @@ 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 */; }; - 044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.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 */; }; @@ -448,7 +448,7 @@ 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 */; }; + 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 */; }; @@ -458,7 +458,7 @@ 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 */; }; From ddf04655498e3fdf3193b8d120101f7bb060ff6f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 22:54:03 -0700 Subject: [PATCH 18/53] Added an event when the clipboard is updated, triggered after the window gains the keyboard focus. --- .../SDL/SDLiPhoneOS.xcodeproj/project.pbxproj | 8 ++++ Xcode/SDL/SDL.xcodeproj/project.pbxproj | 48 +++++++++++++++++++ include/SDL_events.h | 3 ++ src/events/SDL_clipboardevents.c | 47 ++++++++++++++++++ src/events/SDL_clipboardevents_c.h | 31 ++++++++++++ src/video/cocoa/SDL_cocoaclipboard.h | 4 ++ src/video/cocoa/SDL_cocoaclipboard.m | 25 +++++++++- src/video/cocoa/SDL_cocoavideo.h | 1 + src/video/cocoa/SDL_cocoawindow.m | 3 ++ test/common.c | 3 ++ 10 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/events/SDL_clipboardevents.c create mode 100644 src/events/SDL_clipboardevents_c.h diff --git a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj index 1bbe2a820..96ada2e15 100755 --- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj +++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj @@ -62,6 +62,8 @@ 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 */; }; @@ -311,6 +313,8 @@ 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 = ""; }; + 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = ""; }; 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = ""; }; 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = ""; }; 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = ""; }; @@ -958,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 */, @@ -1184,6 +1190,7 @@ 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; }; @@ -1423,6 +1430,7 @@ 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; }; diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index f9219d47b..8202a4c62 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -438,6 +438,22 @@ 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 */; }; @@ -805,6 +821,14 @@ 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 = ""; }; + 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = ""; }; + 0420497411E6F052007E7EC9 /* blank_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blank_cursor.h; sourceTree = ""; }; + 0420497511E6F052007E7EC9 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = ""; }; + 0420497611E6F052007E7EC9 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = ""; }; + 0420497711E6F052007E7EC9 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = ""; }; + 0420497811E6F052007E7EC9 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = ""; }; + 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = ""; }; 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 = ""; }; 046B92100A11B8AD00FB151C /* SDL_dlcompat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_dlcompat.c; sourceTree = ""; }; @@ -1329,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 */, @@ -1766,6 +1798,13 @@ 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; }; @@ -1869,6 +1908,13 @@ 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; }; @@ -2230,6 +2276,7 @@ 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; }; @@ -2348,6 +2395,7 @@ 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; }; diff --git a/include/SDL_events.h b/include/SDL_events.h index 91bdd8624..50a0cb7c3 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -90,6 +90,9 @@ typedef enum 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, diff --git a/src/events/SDL_clipboardevents.c b/src/events/SDL_clipboardevents.c new file mode 100644 index 000000000..7f8820047 --- /dev/null +++ b/src/events/SDL_clipboardevents.c @@ -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() +{ + 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: */ diff --git a/src/events/SDL_clipboardevents_c.h b/src/events/SDL_clipboardevents_c.h new file mode 100644 index 000000000..4d6a1f19a --- /dev/null +++ b/src/events/SDL_clipboardevents_c.h @@ -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(); + +#endif /* _SDL_clipboardevents_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.h b/src/video/cocoa/SDL_cocoaclipboard.h index 8e4619b95..9746e7eb5 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.h +++ b/src/video/cocoa/SDL_cocoaclipboard.h @@ -24,9 +24,13 @@ #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 */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index 77d30594d..01ff40a89 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -22,6 +22,7 @@ #include "SDL_config.h" #include "SDL_cocoavideo.h" +#include "../../events/SDL_clipboardevents_c.h" static NSString * GetTextFormat(_THIS) @@ -42,6 +43,7 @@ GetTextFormat(_THIS) int Cocoa_SetClipboardText(_THIS, const char *text) { + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool; NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); @@ -49,7 +51,7 @@ Cocoa_SetClipboardText(_THIS, const char *text) pool = [[NSAutoreleasePool alloc] init]; pasteboard = [NSPasteboard generalPasteboard]; - [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; + data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; [pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; [pool release]; @@ -114,4 +116,25 @@ Cocoa_HasClipboardText(_THIS) 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: */ diff --git a/src/video/cocoa/SDL_cocoavideo.h b/src/video/cocoa/SDL_cocoavideo.h index 402cdccb5..890624bfb 100644 --- a/src/video/cocoa/SDL_cocoavideo.h +++ b/src/video/cocoa/SDL_cocoavideo.h @@ -60,6 +60,7 @@ typedef struct SDL_VideoData unsigned int modifierFlags; void *key_layout; SDLTranslatorResponder *fieldEdit; + NSInteger clipboard_count; Uint32 screensaver_activity; } SDL_VideoData; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index af84bff2f..be4840b82 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -128,6 +128,9 @@ static __inline__ void ConvertNSRect(NSRect *r) { /* 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 diff --git a/test/common.c b/test/common.c index efbccd6f7..845a7460e 100644 --- a/test/common.c +++ b/test/common.c @@ -1017,6 +1017,9 @@ PrintEvent(SDL_Event * event) 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; From b833ea135110535c98db318517fbe3627151e99e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 8 Jul 2010 23:07:34 -0700 Subject: [PATCH 19/53] Amazingly the Windows code is almost identical to the Mac OS X code. :) --- VisualC/SDL/SDL_VS2005.vcproj | 8 ++++++++ VisualC/SDL/SDL_VS2008.vcproj | 8 ++++++++ src/video/cocoa/SDL_cocoaclipboard.m | 8 ++++---- src/video/win32/SDL_win32clipboard.c | 17 +++++++++++++++++ src/video/win32/SDL_win32clipboard.h | 4 ++++ src/video/win32/SDL_win32events.c | 5 ++++- src/video/win32/SDL_win32video.c | 1 - src/video/win32/SDL_win32video.h | 3 +++ 8 files changed, 48 insertions(+), 6 deletions(-) diff --git a/VisualC/SDL/SDL_VS2005.vcproj b/VisualC/SDL/SDL_VS2005.vcproj index 0dfa9b77d..6be80978f 100644 --- a/VisualC/SDL/SDL_VS2005.vcproj +++ b/VisualC/SDL/SDL_VS2005.vcproj @@ -568,6 +568,14 @@ RelativePath="..\..\src\video\SDL_clipboard.c" > + + + + diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index d616591fd..439cbd1bc 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -723,6 +723,14 @@ RelativePath="..\..\src\video\SDL_clipboard.c" > + + + + diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index 01ff40a89..26f6aeed2 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -45,7 +45,7 @@ Cocoa_SetClipboardText(_THIS, const char *text) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool; - NSPasteboard *pasteboard; + NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); pool = [[NSAutoreleasePool alloc] init]; @@ -63,7 +63,7 @@ char * Cocoa_GetClipboardText(_THIS) { NSAutoreleasePool *pool; - NSPasteboard *pasteboard; + NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); NSString *available; char *text; @@ -96,7 +96,7 @@ SDL_bool Cocoa_HasClipboardText(_THIS) { NSAutoreleasePool *pool; - NSPasteboard *pasteboard; + NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); NSString *available; SDL_bool result; @@ -120,7 +120,7 @@ void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) { NSAutoreleasePool *pool; - NSPasteboard *pasteboard; + NSPasteboard *pasteboard; NSInteger count; pool = [[NSAutoreleasePool alloc] init]; diff --git a/src/video/win32/SDL_win32clipboard.c b/src/video/win32/SDL_win32clipboard.c index 950bd444f..22d54a682 100644 --- a/src/video/win32/SDL_win32clipboard.c +++ b/src/video/win32/SDL_win32clipboard.c @@ -23,6 +23,7 @@ #include "SDL_win32video.h" #include "SDL_win32window.h" +#include "../../events/SDL_clipboardevents_c.h" #ifdef UNICODE @@ -52,6 +53,7 @@ GetWindowHandle(_THIS) int WIN_SetClipboardText(_THIS, const char *text) { + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; int result = 0; if (OpenClipboard(GetWindowHandle(_this))) { @@ -93,6 +95,7 @@ WIN_SetClipboardText(_THIS, const char *text) WIN_SetError("Couldn't set clipboard data"); result = -1; } + data->clipboard_count = GetClipboardSequenceNumber(); } SDL_free(tstr); @@ -141,4 +144,18 @@ WIN_HasClipboardText(_THIS) } } +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: */ diff --git a/src/video/win32/SDL_win32clipboard.h b/src/video/win32/SDL_win32clipboard.h index 36fb79823..ab2fb17a7 100644 --- a/src/video/win32/SDL_win32clipboard.h +++ b/src/video/win32/SDL_win32clipboard.h @@ -24,9 +24,13 @@ #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 */ diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c index 98affcc3c..d03b672c6 100755 --- a/src/video/win32/SDL_win32events.c +++ b/src/video/win32/SDL_win32events.c @@ -162,7 +162,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 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); diff --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c index 2c93885e2..2c5d3146d 100644 --- a/src/video/win32/SDL_win32video.c +++ b/src/video/win32/SDL_win32video.c @@ -28,7 +28,6 @@ #include "../SDL_pixels_c.h" #include "SDL_win32video.h" -#include "SDL_win32clipboard.h" #include "SDL_d3drender.h" #include "SDL_gdirender.h" diff --git a/src/video/win32/SDL_win32video.h b/src/video/win32/SDL_win32video.h index 117999dc9..6911f49b8 100644 --- a/src/video/win32/SDL_win32video.h +++ b/src/video/win32/SDL_win32video.h @@ -45,6 +45,7 @@ #include "ddraw.h" #endif +#include "SDL_win32clipboard.h" #include "SDL_win32events.h" #include "SDL_win32gamma.h" #include "SDL_win32keyboard.h" @@ -75,6 +76,8 @@ typedef struct SDL_VideoData IDirectDraw *ddraw; #endif + DWORD clipboard_count; + const SDL_scancode *key_layout; } SDL_VideoData; From c9dcaef79e07a6cadd2742a5527ef3d308d0c662 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 00:33:24 -0700 Subject: [PATCH 20/53] Fixed compiler warning --- src/video/x11/SDL_x11window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 699740418..9fd1350e6 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -289,9 +289,9 @@ X11_CreateWindow(_THIS, SDL_Window * window) Sint32 r, g, b; /* Is the colormap we need already registered in SDL? */ - if (colormap = + if ((colormap = X11_LookupColormap(data->display, - displaydata->screen, visual->visualid)) { + displaydata->screen, visual->visualid))) { xattr.colormap = colormap; /* printf("found existing colormap\n"); */ } else { From 6540320beb88f5477fea2cd47ca03919ba8e291b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 00:35:14 -0700 Subject: [PATCH 21/53] Fixed compile warnings --- include/SDL_clipboard.h | 4 ++-- src/events/SDL_clipboardevents.c | 2 +- src/events/SDL_clipboardevents_c.h | 2 +- src/video/SDL_clipboard.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h index 848c21d12..bc9e348db 100644 --- a/include/SDL_clipboard.h +++ b/include/SDL_clipboard.h @@ -53,14 +53,14 @@ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); * * \sa SDL_SetClipboardText() */ -extern DECLSPEC char * SDLCALL SDL_GetClipboardText(); +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** * \brief Returns whether the clipboard has text * * \sa SDL_GetClipboardText() */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(); +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); /* Ends C function definitions when using C++ */ diff --git a/src/events/SDL_clipboardevents.c b/src/events/SDL_clipboardevents.c index 7f8820047..2d5a2c48d 100644 --- a/src/events/SDL_clipboardevents.c +++ b/src/events/SDL_clipboardevents.c @@ -29,7 +29,7 @@ int -SDL_SendClipboardUpdate() +SDL_SendClipboardUpdate(void) { int posted; diff --git a/src/events/SDL_clipboardevents_c.h b/src/events/SDL_clipboardevents_c.h index 4d6a1f19a..9e35a5aba 100644 --- a/src/events/SDL_clipboardevents_c.h +++ b/src/events/SDL_clipboardevents_c.h @@ -24,7 +24,7 @@ #ifndef _SDL_clipboardevents_c_h #define _SDL_clipboardevents_c_h -extern int SDL_SendClipboardUpdate(); +extern int SDL_SendClipboardUpdate(void); #endif /* _SDL_clipboardevents_c_h */ diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index fc7e5fbb6..a414fa5ec 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -42,7 +42,7 @@ SDL_SetClipboardText(const char *text) } char * -SDL_GetClipboardText() +SDL_GetClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -58,7 +58,7 @@ SDL_GetClipboardText() } SDL_bool -SDL_HasClipboardText() +SDL_HasClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); From 8c81b4fdae025af68e8fd5156a655ba911c29596 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 00:35:24 -0700 Subject: [PATCH 22/53] Fixed compile warnings --- src/audio/SDL_audio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index e3b02cf94..d115de7ee 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -287,6 +287,7 @@ SDL_StreamLength(SDL_AudioStreamer * stream) } /* 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 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence) return 0; } +#endif /* Deinitialize the stream simply by freeing the buffer */ static void From b758d7ddd55e6707d5ec91264f1eb334f7af6408 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 00:36:55 -0700 Subject: [PATCH 23/53] Added X11 clipboard support. As far as I know there isn't any real way to tell when the clipboard contents have changed without polling them, so I didn't implement the clipboard update event on X11. --- src/video/x11/SDL_x11clipboard.c | 152 +++++++++++++++++++++++++++++++ src/video/x11/SDL_x11clipboard.h | 33 +++++++ src/video/x11/SDL_x11events.c | 52 +++++++++++ src/video/x11/SDL_x11sym.h | 11 ++- src/video/x11/SDL_x11video.c | 6 ++ src/video/x11/SDL_x11video.h | 2 + 6 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 src/video/x11/SDL_x11clipboard.c create mode 100644 src/video/x11/SDL_x11clipboard.h diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c new file mode 100644 index 000000000..cbf7a6de7 --- /dev/null +++ b/src/video/x11/SDL_x11clipboard.c @@ -0,0 +1,152 @@ +/* + 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 /* For INT_MAX */ + +#include "SDL_events.h" +#include "SDL_x11video.h" + + +/* 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; + } + + /* If you don't support UTF-8, you might use XA_STRING here */ + format = XInternAtom(display, "UTF8_STRING", False); + 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 SDL window that will own the selection */ + window = GetWindow(_this); + + /* If you don't support UTF-8, you might use XA_STRING here */ + format = XInternAtom(display, "UTF8_STRING", False); + + 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: */ diff --git a/src/video/x11/SDL_x11clipboard.h b/src/video/x11/SDL_x11clipboard.h new file mode 100644 index 000000000..6d9bbb085 --- /dev/null +++ b/src/video/x11/SDL_x11clipboard.h @@ -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: */ diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 147dc626d..e4d51bc6b 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -25,6 +25,7 @@ #include #include #include +#include /* For INT_MAX */ #include "SDL_x11video.h" #include "../../events/SDL_events_c.h" @@ -33,6 +34,8 @@ #include "SDL_timer.h" #include "SDL_syswm.h" +/*#define DEBUG_XEVENTS*/ + static void X11_DispatchEvent(_THIS) { @@ -286,6 +289,55 @@ X11_DispatchEvent(_THIS) } break; + /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ + case SelectionRequest: { + Display *display = videodata->display; + 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 + + sevent.xselection.type = SelectionNotify; + sevent.xselection.display = req->display; + 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); diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 0cdcfe8dc..01dc8f6a0 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -37,6 +37,7 @@ SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSe 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) @@ -71,10 +72,11 @@ SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e, 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(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 +116,15 @@ SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return) 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) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 86a9e7db9..a3a8d2c72 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -21,6 +21,8 @@ */ #include "SDL_config.h" +#include /* For getpid() and readlink() */ + #include "SDL_video.h" #include "SDL_mouse.h" #include "../SDL_sysvideo.h" @@ -225,6 +227,10 @@ X11_CreateDevice(int devindex) 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; diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index a550f8485..34647ca51 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -48,6 +48,7 @@ #include "SDL_x11dyn.h" +#include "SDL_x11clipboard.h" #include "SDL_x11events.h" #include "SDL_x11gamma.h" #include "SDL_x11keyboard.h" @@ -69,6 +70,7 @@ typedef struct SDL_VideoData int windowlistlength; Atom WM_DELETE_WINDOW; SDL_scancode key_layout[256]; + SDL_bool selection_waiting; } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void); From e026e96e9543176181271f0a617e17e0821cff1d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 00:49:26 -0700 Subject: [PATCH 24/53] Made it possible to switch the text format in one place --- src/video/x11/SDL_x11clipboard.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index cbf7a6de7..ddd8cdc41 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -27,6 +27,13 @@ #include "SDL_x11video.h" +/* If you don't support UTF-8, you might use XA_STRING here */ +#if 1 +#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) @@ -58,8 +65,8 @@ X11_SetClipboardText(_THIS, const char *text) return -1; } - /* If you don't support UTF-8, you might use XA_STRING here */ - format = XInternAtom(display, "UTF8_STRING", False); + /* 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)); @@ -88,12 +95,9 @@ X11_GetClipboardText(_THIS) text = NULL; - /* Get the SDL window that will own the selection */ + /* Get the window that holds the selection */ window = GetWindow(_this); - - /* If you don't support UTF-8, you might use XA_STRING here */ - format = XInternAtom(display, "UTF8_STRING", False); - + format = TEXT_FORMAT; owner = XGetSelectionOwner(display, XA_PRIMARY); if ((owner == None) || (owner == window)) { owner = DefaultRootWindow(display); From b07db7e9c38cb2e9eee263e913f3c5695af85b5a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 01:20:57 -0700 Subject: [PATCH 25/53] Implemented X11 system window manager info for SDL 1.3. It's simple. Really. --- include/SDL_syswm.h | 18 ------------------ src/video/x11/SDL_x11window.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 56ef7f6d2..4f7d00720 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -106,24 +106,6 @@ struct SDL_SysWMinfo { 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; }; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 9fd1350e6..78d94dab2 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -1014,8 +1014,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window) 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", From 9ecac589b85cedc48f5c23b22d3e62a5975c734c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 12 Jul 2010 22:08:50 -0700 Subject: [PATCH 26/53] Daniel Wyatt 2010-03-26 14:52:53 PDT If a non-console Windows SDL program has a non-quoted 0th argument followed optionally by more non-quoted arguments and then by an empty quoted argument, it will crash (attempts to dereference a NULL pointer). In other words, something like this: test.exe [non-quoted args] "" [...] The fix is a one-liner in ParseCommandLine() of src/main/win32/SDL_win32_main.c. You can test this with any non-console SDL program on windows like this: 1) Open a console (cmd.exe) 2) Launch the program in one of the following ways: program "" program arg1 "" program arg1 "" arg3 These will not cause a crash: "program" [...] program "arg1" "" When a Windows program is launched from Explorer, its 0th argument seems to always be quoted, so it won't be a problem in that case. I've tested this on Windows XP SP3 and Windows 7. --- src/main/win32/SDL_win32_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/win32/SDL_win32_main.c b/src/main/win32/SDL_win32_main.c index 524e0db77..ef50d5d2c 100644 --- a/src/main/win32/SDL_win32_main.c +++ b/src/main/win32/SDL_win32_main.c @@ -71,6 +71,7 @@ ParseCommandLine(char *cmdline, char **argv) ++argc; } /* Skip over word */ + lastp = bufp; while (*bufp && (*bufp != '"' || *lastp == '\\')) { lastp = bufp; ++bufp; From 322aa25962d732e069386871609078252fa6bae9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 22:22:43 -0700 Subject: [PATCH 27/53] Fixed compile warning. --- src/audio/SDL_audiodev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index dda23f8d8..67b704f9e 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -28,6 +28,7 @@ #include #include #include +#include /* For close() */ #include "SDL_stdinc.h" #include "SDL_audiodev_c.h" From eef59d7ccd692f427b38aebd354c99f042c025dd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 22:24:46 -0700 Subject: [PATCH 28/53] Fixed compile warning --- src/video/SDL_renderer_sw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/video/SDL_renderer_sw.c b/src/video/SDL_renderer_sw.c index a9911f35d..4117765e0 100644 --- a/src/video/SDL_renderer_sw.c +++ b/src/video/SDL_renderer_sw.c @@ -795,7 +795,6 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 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) { From 56a9f4854277840679297f9dd3ad753c959f4140 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 22:25:30 -0700 Subject: [PATCH 29/53] Fixed compile warning --- src/haptic/linux/SDL_syshaptic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index f68061ca6..722a8c9f9 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -254,8 +254,6 @@ SDL_SYS_HapticName(int index) 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)); From 753ad582779f1bbe3ac3ea0e2f7f0e4506ed758d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 22:26:50 -0700 Subject: [PATCH 30/53] Fixed compile warnings --- src/timer/SDL_systimer.h | 1 + src/timer/unix/SDL_systimer.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/timer/SDL_systimer.h b/src/timer/SDL_systimer.h index 5c74e3f92..d0cfd25db 100644 --- a/src/timer/SDL_systimer.h +++ b/src/timer/SDL_systimer.h @@ -38,4 +38,5 @@ extern int SDL_SYS_StartTimer(void); /* Stop a previously started timer */ extern void SDL_SYS_StopTimer(void); + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index 29c3b7b64..2a933eea2 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -31,6 +31,7 @@ #include #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 From 0c8dcac0b63cc94885d1f3349547f418fe7be493 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 22:39:46 -0700 Subject: [PATCH 31/53] Use a better switch for the clipboard property format --- src/video/x11/SDL_x11clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index ddd8cdc41..6c9740bd7 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -28,7 +28,7 @@ /* If you don't support UTF-8, you might use XA_STRING here */ -#if 1 +#ifdef X_HAVE_UTF8_STRING #define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) #else #define TEXT_FORMAT XA_STRING From 31e17885c75e8af057f2565062917b5e0efca55d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 23:05:14 -0700 Subject: [PATCH 32/53] Added test case for maximize code --- test/common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/common.c b/test/common.c index 845a7460e..f06c98ba6 100644 --- a/test/common.c +++ b/test/common.c @@ -1077,6 +1077,19 @@ CommonEvent(CommonState * state, SDL_Event * event, int *done) /* 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 */ From 332544ff400fb282144b64c581ddd39245f81b34 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 23:11:10 -0700 Subject: [PATCH 33/53] Lots of prep for the "real" way to support fullscreen mode on modern window managers. Unfortunately, this doesn't work. I also noticed that maximizing doesn't work as well. Also xprop hangs when trying to list properties of SDL windows.... ??? --- src/video/x11/SDL_x11events.c | 62 ++++++++++-- src/video/x11/SDL_x11modes.c | 5 +- src/video/x11/SDL_x11sym.h | 2 + src/video/x11/SDL_x11video.c | 53 ++++++++++- src/video/x11/SDL_x11video.h | 15 +++ src/video/x11/SDL_x11window.c | 174 ++++++++++++++++++++++------------ src/video/x11/SDL_x11window.h | 1 + 7 files changed, 242 insertions(+), 70 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index e4d51bc6b..dc4f68da3 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -34,18 +34,19 @@ #include "SDL_timer.h" #include "SDL_syswm.h" -/*#define DEBUG_XEVENTS*/ +#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 */ @@ -80,6 +81,7 @@ X11_DispatchEvent(_THIS) if (!data) { return; } + #if 0 printf("type = %d display = %d window = %d\n", xevent.type, xevent.xany.display, xevent.xany.window); @@ -182,9 +184,8 @@ X11_DispatchEvent(_THIS) #if 0 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 X11 KeyCode %d (%d), X11 KeySym 0x%X (%s).\n", keycode, keycode - min_keycode, keysym, @@ -289,9 +290,58 @@ X11_DispatchEvent(_THIS) } break; + case PropertyNotify:{ +#ifdef DEBUG_XEVENTS + char *name = XGetAtomName(display, xevent.xproperty.atom); + printf("PropertyNotify (atom = %s)\n", name ? name : "NULL"); + if (name) { + XFree(name); + } +#endif + if (xevent.xproperty.atom == videodata->_NET_WM_STATE) { + unsigned char *propdata; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left, i; + +#ifdef DEBUG_XEVENTS + printf("_NET_WM_STATE: {"); +#endif + status = XGetWindowProperty(display, data->xwindow, videodata->_NET_WM_STATE, 0L, 8192L, False, XA_ATOM, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success) { + Atom *atoms = (Atom *)propdata; + for (i = 0; i < items_read; i++) { + if (atoms[i] == videodata->_NET_WM_STATE_HIDDEN) { +#ifdef DEBUG_XEVENTS + printf(" _NET_WM_STATE_HIDDEN"); +#endif + } + if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_HORZ) { +#ifdef DEBUG_XEVENTS + printf(" _NET_WM_STATE_MAXIMIZED_HORZ"); +#endif + } + if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_VERT) { +#ifdef DEBUG_XEVENTS + printf(" _NET_WM_STATE_MAXIMIZED_VERT"); +#endif + } + if (atoms[i] == videodata->_NET_WM_STATE_FULLSCREEN) { +#ifdef DEBUG_XEVENTS + printf(" _NET_WM_STATE_FULLSCREEN"); +#endif + } + } + } +#ifdef DEBUG_XEVENTS + printf(" }\n"); +#endif + } + } + break; + /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ case SelectionRequest: { - Display *display = videodata->display; XSelectionRequestEvent *req; XEvent sevent; int seln_format; diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 211bcb885..fe8f7b5ad 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -23,7 +23,7 @@ #include "SDL_x11video.h" -//#define X11MODES_DEBUG +#define X11MODES_DEBUG #undef SDL_VIDEO_DRIVER_X11_XINERAMA #undef SDL_VIDEO_DRIVER_X11_XRANDR #undef SDL_VIDEO_DRIVER_X11_VIDMODE @@ -253,6 +253,7 @@ CheckVidMode(Display * display, int *major, int *minor) return SDL_TRUE; } +static Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr, SDL_NAME(XF86VidModeModeInfo) * info) { @@ -296,6 +297,7 @@ save_mode(Display * display, SDL_DisplayData * data) &data->saved_view.y); } +/* static void restore_mode(Display * display, SDL_DisplayData * data) { @@ -313,6 +315,7 @@ restore_mode(Display * display, SDL_DisplayData * data) data->saved_view.y); } } +*/ #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ void diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 01dc8f6a0..38855b55e 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -67,12 +67,14 @@ SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return) 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(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) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index a3a8d2c72..894837e54 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -242,6 +242,43 @@ VideoBootStrap X11_bootstrap = { }; +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) { @@ -259,8 +296,20 @@ X11_VideoInit(_THIS) #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; diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 34647ca51..d8929b1b4 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -68,7 +68,22 @@ typedef struct SDL_VideoData 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; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 78d94dab2..305c2cf1b 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -42,6 +42,20 @@ #define _NET_WM_STATE_ADD 1l #define _NET_WM_STATE_TOGGLE 2l +static SDL_bool +X11_WindowIsOldstyleFullscreen(SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; + + /* 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 void X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) { @@ -128,14 +142,10 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) } { - 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 +158,21 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) &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 +192,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) } 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 { @@ -225,6 +232,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) XSizeHints *sizehints; XWMHints *wmhints; XClassHint *classhints; + SDL_bool oldstyle_fullscreen; + + /* ICCCM2.0-compliant window managers can handle fullscreen windows */ + if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->net_wm) { + oldstyle_fullscreen = SDL_TRUE; + } else { + oldstyle_fullscreen = SDL_FALSE; + } #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -265,7 +280,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) depth = displaydata->depth; } - if (window->flags & SDL_WINDOW_FULLSCREEN) { + if (oldstyle_fullscreen) { xattr.override_redirect = True; } else { xattr.override_redirect = False; @@ -417,7 +432,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) } /* 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"); @@ -494,7 +508,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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 +517,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } 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; @@ -539,12 +553,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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; @@ -555,7 +569,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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; @@ -643,23 +657,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) } } - /* 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) { @@ -678,6 +675,26 @@ X11_CreateWindow(_THIS, SDL_Window * window) XFree(classhints); } + /* FIXME: Why doesn't this work? */ + if (window->flags & SDL_WINDOW_FULLSCREEN) { + Atom _NET_WM_STATE = data->_NET_WM_STATE; + Atom _NET_WM_STATE_FULLSCREEN = data->_NET_WM_STATE_FULLSCREEN; + XEvent e; + + e.xany.type = ClientMessage; + e.xclient.display = data->display; + e.xclient.window = w; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.data.l[0] = _NET_WM_STATE_ADD; + e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; + e.xclient.data.l[2] = 0l; + + XSendEvent(data->display, + RootWindow(data->display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } + /* Allow the window to be deleted by the window manager */ XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); @@ -716,7 +733,7 @@ X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { 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 +741,36 @@ X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) 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 +782,8 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) 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,7 +844,7 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) { 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; @@ -842,16 +883,20 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) { 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_WindowIsOldstyleFullscreen(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,15 +949,14 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) 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); + 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; XEvent e; e.xany.type = ClientMessage; - e.xany.window = data->xwindow; + e.xclient.display = display; + e.xclient.window = data->xwindow; e.xclient.message_type = _NET_WM_STATE; e.xclient.format = 32; e.xclient.data.l[0] = @@ -920,7 +964,6 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) 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); @@ -935,7 +978,12 @@ X11_MaximizeWindow(_THIS, SDL_Window * window) 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 +998,12 @@ X11_SetWindowGrab(_THIS, SDL_Window * window) { 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_WindowIsOldstyleFullscreen(window); + + if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { /* Try to grab the mouse */ for (;;) { diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 055bf733f..06d2c268d 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -35,6 +35,7 @@ typedef struct 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); From 4fa4fde20f70db52225bf0e9b2721d4e6b4f5905 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 13 Jul 2010 23:14:00 -0700 Subject: [PATCH 34/53] Turned off debug spew --- src/video/x11/SDL_x11events.c | 2 +- src/video/x11/SDL_x11modes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index dc4f68da3..6a0c66d5f 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -34,7 +34,7 @@ #include "SDL_timer.h" #include "SDL_syswm.h" -#define DEBUG_XEVENTS +/*#define DEBUG_XEVENTS*/ static void X11_DispatchEvent(_THIS) diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index fe8f7b5ad..5ff6ff0dd 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -23,7 +23,7 @@ #include "SDL_x11video.h" -#define X11MODES_DEBUG +/*#define X11MODES_DEBUG*/ #undef SDL_VIDEO_DRIVER_X11_XINERAMA #undef SDL_VIDEO_DRIVER_X11_XRANDR #undef SDL_VIDEO_DRIVER_X11_VIDMODE From 2995c71aebba3da57d379916da9f8b1beede0cd7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 00:08:46 -0700 Subject: [PATCH 35/53] Much better debugging of property changes --- src/video/x11/SDL_x11events.c | 93 ++++++++++++++++++++++------------- src/video/x11/SDL_x11window.c | 4 -- 2 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 6a0c66d5f..9c3387f8b 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -292,51 +292,77 @@ X11_DispatchEvent(_THIS) 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); - printf("PropertyNotify (atom = %s)\n", name ? name : "NULL"); if (name) { + printf("PropertyNotify: %s\n", name); XFree(name); } -#endif - if (xevent.xproperty.atom == videodata->_NET_WM_STATE) { - unsigned char *propdata; - int status, real_format; - Atom real_type; - unsigned long items_read, items_left, i; -#ifdef DEBUG_XEVENTS - printf("_NET_WM_STATE: {"); -#endif - status = XGetWindowProperty(display, data->xwindow, videodata->_NET_WM_STATE, 0L, 8192L, False, XA_ATOM, &real_type, &real_format, &items_read, &items_left, &propdata); - if (status == Success) { - Atom *atoms = (Atom *)propdata; + 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++) { - if (atoms[i] == videodata->_NET_WM_STATE_HIDDEN) { -#ifdef DEBUG_XEVENTS - printf(" _NET_WM_STATE_HIDDEN"); -#endif + 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]); } - if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_HORZ) { -#ifdef DEBUG_XEVENTS - printf(" _NET_WM_STATE_MAXIMIZED_HORZ"); -#endif + printf(" }\n"); + } else if (real_format == 16) { + Uint16 *values = (Uint16 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); } - if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_VERT) { -#ifdef DEBUG_XEVENTS - printf(" _NET_WM_STATE_MAXIMIZED_VERT"); -#endif + printf(" }\n"); + } else if (real_format == 8) { + Uint8 *values = (Uint8 *)propdata; + + printf("{"); + for (i = 0; i < items_read; i++) { + printf(" %d", values[i]); } - if (atoms[i] == videodata->_NET_WM_STATE_FULLSCREEN) { -#ifdef DEBUG_XEVENTS - printf(" _NET_WM_STATE_FULLSCREEN"); -#endif + 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); + } } -#ifdef DEBUG_XEVENTS - printf(" }\n"); -#endif } +#endif } break; @@ -355,8 +381,7 @@ X11_DispatchEvent(_THIS) req->requestor, req->target); #endif - sevent.xselection.type = SelectionNotify; - sevent.xselection.display = req->display; + sevent.xany.type = SelectionNotify; sevent.xselection.selection = req->selection; sevent.xselection.target = None; sevent.xselection.property = None; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 305c2cf1b..8dd6b4e38 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -682,8 +682,6 @@ X11_CreateWindow(_THIS, SDL_Window * window) XEvent e; e.xany.type = ClientMessage; - e.xclient.display = data->display; - e.xclient.window = w; e.xclient.message_type = _NET_WM_STATE; e.xclient.format = 32; e.xclient.data.l[0] = _NET_WM_STATE_ADD; @@ -955,8 +953,6 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) XEvent e; e.xany.type = ClientMessage; - e.xclient.display = display; - e.xclient.window = data->xwindow; e.xclient.message_type = _NET_WM_STATE; e.xclient.format = 32; e.xclient.data.l[0] = From 1fa5363e3a5afba9426f21120b647c1ee8f74693 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 00:28:15 -0700 Subject: [PATCH 36/53] Let the window manager know we're a "normal" window --- src/video/x11/SDL_x11window.c | 100 ++++++++++++++++------------------ 1 file changed, 48 insertions(+), 52 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 8dd6b4e38..1942b6823 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -224,6 +224,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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; @@ -233,6 +235,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) XWMHints *wmhints; XClassHint *classhints; SDL_bool oldstyle_fullscreen; + Atom _NET_WM_WINDOW_TYPE; + Atom _NET_WM_WINDOW_TYPE_NORMAL; /* ICCCM2.0-compliant window managers can handle fullscreen windows */ if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->net_wm) { @@ -253,7 +257,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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; } @@ -266,7 +270,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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; } @@ -305,15 +309,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) /* 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); */ @@ -392,11 +393,10 @@ X11_CreateWindow(_THIS, SDL_Window * window) } /* 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); } @@ -412,15 +412,12 @@ X11_CreateWindow(_THIS, SDL_Window * window) /* 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); */ @@ -493,18 +490,16 @@ X11_CreateWindow(_THIS, SDL_Window * window) } 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); } @@ -527,8 +522,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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); @@ -565,7 +559,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) sizehints->y = y; sizehints->flags |= USPosition; } - XSetWMNormalHints(data->display, w, sizehints); + XSetWMNormalHints(display, w, sizehints); XFree(sizehints); } @@ -577,7 +571,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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 @@ -590,40 +584,36 @@ X11_CreateWindow(_THIS, SDL_Window * window) } 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; @@ -633,27 +623,27 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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); } } @@ -662,7 +652,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) if (wmhints) { wmhints->input = True; wmhints->flags = InputHint; - XSetWMHints(data->display, w, wmhints); + XSetWMHints(display, w, wmhints); XFree(wmhints); } @@ -671,7 +661,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) if (classhints != NULL) { classhints->res_name = data->classname; classhints->res_class = data->classname; - XSetClassHint(data->display, w, classhints); + XSetClassHint(display, w, classhints); XFree(classhints); } @@ -688,16 +678,22 @@ X11_CreateWindow(_THIS, SDL_Window * window) e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; e.xclient.data.l[2] = 0l; - XSendEvent(data->display, - RootWindow(data->display, displaydata->screen), 0, + XSendEvent(display, RootWindow(display, screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } + /* 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 @@ -705,7 +701,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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 | @@ -714,7 +710,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } #else { - XSelectInput(data->display, w, + XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | From f359555c6472c4ad7527cd0e83a8c21a226e6b8c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 00:56:08 -0700 Subject: [PATCH 37/53] Fixed setting fullscreen and maximized states for windows that haven't been mapped yet. --- src/video/x11/SDL_x11window.c | 115 +++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 36 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 1942b6823..c417e6647 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -43,10 +43,9 @@ #define _NET_WM_STATE_TOGGLE 2l static SDL_bool -X11_WindowIsOldstyleFullscreen(SDL_Window * window) +X11_IsWindowOldFullscreen(_THIS, SDL_Window * window) { - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; + 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) { @@ -56,6 +55,37 @@ X11_WindowIsOldstyleFullscreen(SDL_Window * window) } } +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) { @@ -237,13 +267,11 @@ X11_CreateWindow(_THIS, SDL_Window * window) 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 */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) && !data->net_wm) { - oldstyle_fullscreen = SDL_TRUE; - } else { - oldstyle_fullscreen = SDL_FALSE; - } + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -665,21 +693,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) XFree(classhints); } - /* FIXME: Why doesn't this work? */ - if (window->flags & SDL_WINDOW_FULLSCREEN) { - Atom _NET_WM_STATE = data->_NET_WM_STATE; - Atom _NET_WM_STATE_FULLSCREEN = data->_NET_WM_STATE_FULLSCREEN; - XEvent e; - - e.xany.type = ClientMessage; - e.xclient.message_type = _NET_WM_STATE; - e.xclient.format = 32; - e.xclient.data.l[0] = _NET_WM_STATE_ADD; - e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; - e.xclient.data.l[2] = 0l; - - XSendEvent(display, RootWindow(display, screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &e); + /* 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 */ @@ -881,7 +902,7 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) int x, y; /* ICCCM2.0-compliant window managers can handle fullscreen windows */ - oldstyle_fullscreen = X11_WindowIsOldstyleFullscreen(window); + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); if (oldstyle_fullscreen || window->x == SDL_WINDOWPOS_CENTERED) { @@ -946,19 +967,41 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) 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; - XEvent e; + Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; - e.xany.type = ClientMessage; - 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; + if (X11_IsWindowMapped(_this, window)) { + XEvent e; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, - SubstructureNotifyMask | SubstructureRedirectMask, &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; + + XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + int count = 0; + Atom atoms[3]; + + 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 @@ -993,7 +1036,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window) SDL_bool oldstyle_fullscreen; /* ICCCM2.0-compliant window managers can handle fullscreen windows */ - oldstyle_fullscreen = X11_WindowIsOldstyleFullscreen(window); + oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { From 6ad28bf626ab59243546500dd0af2679d707bc87 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 01:02:18 -0700 Subject: [PATCH 38/53] Now that the fullscreen wm state works, enable the video modes. Yay! :) --- src/video/x11/SDL_x11modes.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 5ff6ff0dd..fb9cba187 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -24,9 +24,6 @@ #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 static int get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) From 2d63dc10b471ba12f6dfe3254e6e5e5a48506a91 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 07:25:07 -0700 Subject: [PATCH 39/53] Zero any fields not explicitly filled in. --- src/video/x11/SDL_x11events.c | 1 + src/video/x11/SDL_x11window.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 9c3387f8b..514a98d7c 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -381,6 +381,7 @@ X11_DispatchEvent(_THIS) req->requestor, req->target); #endif + SDL_zero(sevent); sevent.xany.type = SelectionNotify; sevent.xselection.selection = req->selection; sevent.xselection.target = None; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index c417e6647..85b2a85b0 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -972,6 +972,7 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) 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; From abe03eb79350dd602eace741e6b714ed6572d0cc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 07:31:35 -0700 Subject: [PATCH 40/53] pelya 2010-07-12 03:53:48 PDT In function GLES_RenderCopy() in SDL_renderer_gles.c:819 there is one memcpy() that can be avoided if we're updating whole texture. Because of that the SDL 1.3 in compatibility mode is working even slower than software rendering in SDL 1.2. --- src/video/SDL_renderer_gles.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/video/SDL_renderer_gles.c b/src/video/SDL_renderer_gles.c index d1d7ce4f7..80397a055 100644 --- a/src/video/SDL_renderer_gles.c +++ b/src/video/SDL_renderer_gles.c @@ -822,20 +822,25 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 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); } From a20175b6756b5846f01edab41b3271dd9befae54 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 07:48:35 -0700 Subject: [PATCH 41/53] Fixed bug #1000 Don't crash if someone tries to delete a context after we've unloaded the library. In this case it's SDL_compat that doesn't know SDL_VideoQuit() has been called. Hmm... --- src/video/SDL_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 435f01696..1673d0e0a 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -3271,7 +3271,7 @@ SDL_GL_SwapWindow(SDL_Window * window) void SDL_GL_DeleteContext(SDL_GLContext context) { - if (!_this || !context) { + if (!_this || !_this->gl_data || !context) { return; } _this->GL_MakeCurrent(_this, NULL, NULL); From 774e4ce3f5e31722df23e5acc9c4cc762cdab1aa Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 14 Jul 2010 21:25:15 -0700 Subject: [PATCH 42/53] Added support for testing window manager icons --- test/common.c | 43 ++++++++++++++++++++++++++++++++++++++++++- test/common.h | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/test/common.c b/test/common.c index f06c98ba6..f526e216d 100644 --- a/test/common.c +++ b/test/common.c @@ -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 @@ CommonArg(CommonState * state, int index) 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 @@ PrintRenderer(SDL_RendererInfo * info) } } +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 @@ CommonInit(CommonState * state) 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 diff --git a/test/common.h b/test/common.h index 8aca1f054..0a35a0378 100644 --- a/test/common.h +++ b/test/common.h @@ -24,6 +24,7 @@ typedef struct const char *videodriver; int display; const char *window_title; + const char *window_icon; Uint32 window_flags; int window_x; int window_y; From e880b725c0db53558ee5090f86257d63270fbd5e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Jul 2010 18:44:34 -0700 Subject: [PATCH 43/53] Fixed bug 1022 Fixed the X11 icon on 64-bit systems --- src/video/x11/SDL_x11window.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 85b2a85b0..2718b3bb9 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -865,7 +865,7 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * 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, @@ -879,10 +879,19 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) 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); From 6920164fadc6b44943ad668d6d96bc480984c6d8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Jul 2010 18:57:51 -0700 Subject: [PATCH 44/53] Fixed bug 1014 Don't send events for unprintable characters --- src/events/SDL_keyboard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index a2687bd26..6d991cc13 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -764,6 +764,11 @@ SDL_SendKeyboardText(const char *text) 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) { From ac279884c424152fb66b2028e0b4f45e01f8252a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Jul 2010 22:59:28 -0700 Subject: [PATCH 45/53] Fixed typo in the documentation --- include/SDL_syswm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 4f7d00720..95b7a620a 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -213,7 +213,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo; /** * \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. * From 7ba6775100fdfa0c560496037e2a626d14f634b8 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 17 Jul 2010 23:25:10 -0700 Subject: [PATCH 46/53] Added a couple missing keys on my Logitech G15 keyboard on a Mac Pro running Ubuntu 10.04. --- src/events/scancodes_xfree86.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index 1886053b4..a17af6e1e 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -274,7 +274,7 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 93 */ SDL_SCANCODE_UNKNOWN, /* 94 */ SDL_SCANCODE_UNKNOWN, /* 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, @@ -297,7 +297,7 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 116 */ SDL_SCANCODE_UNKNOWN, /* 117 */ SDL_SCANCODE_UNKNOWN, /* 118 */ SDL_SCANCODE_UNKNOWN, - /* 119 */ SDL_SCANCODE_UNKNOWN, + /* 119 */ SDL_SCANCODE_PAUSE, /* 120 */ SDL_SCANCODE_UNKNOWN, /* 121 */ SDL_SCANCODE_PAUSE, /* 122 */ SDL_SCANCODE_UNKNOWN, From 77f7140f6e5a0f98281a599376acd9a2c25c4ac3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 00:40:17 -0700 Subject: [PATCH 47/53] Logitech G15 on Ubuntu 10.04: code = 1, sym = 0xFF1B (Escape) scancode = 41 (Escape) code = 2, sym = 0x31 (1) scancode = 30 (1) code = 3, sym = 0x32 (2) scancode = 31 (2) code = 4, sym = 0x33 (3) scancode = 32 (3) code = 5, sym = 0x34 (4) scancode = 33 (4) code = 6, sym = 0x35 (5) scancode = 34 (5) code = 7, sym = 0x36 (6) scancode = 35 (6) code = 8, sym = 0x37 (7) scancode = 36 (7) code = 9, sym = 0x38 (8) scancode = 37 (8) code = 10, sym = 0x39 (9) scancode = 38 (9) code = 11, sym = 0x30 (0) scancode = 39 (0) code = 12, sym = 0x2D (minus) scancode = 45 (-) code = 13, sym = 0x3D (equal) scancode = 46 (=) code = 14, sym = 0xFF08 (BackSpace) scancode = 42 (Backspace) code = 15, sym = 0xFF09 (Tab) scancode = 43 (Tab) code = 16, sym = 0x71 (q) scancode = 20 (Q) code = 17, sym = 0x77 (w) scancode = 26 (W) code = 18, sym = 0x65 (e) scancode = 8 (E) code = 19, sym = 0x72 (r) scancode = 21 (R) code = 20, sym = 0x74 (t) scancode = 23 (T) code = 21, sym = 0x79 (y) scancode = 28 (Y) code = 22, sym = 0x75 (u) scancode = 24 (U) code = 23, sym = 0x69 (i) scancode = 12 (I) code = 24, sym = 0x6F (o) scancode = 18 (O) code = 25, sym = 0x70 (p) scancode = 19 (P) code = 26, sym = 0x5B (bracketleft) scancode = 47 ([) code = 27, sym = 0x5D (bracketright) scancode = 48 (]) code = 28, sym = 0xFF0D (Return) scancode = 40 (Return) code = 29, sym = 0xFFE3 (Control_L) scancode = 224 (Left Ctrl) code = 30, sym = 0x61 (a) scancode = 4 (A) code = 31, sym = 0x73 (s) scancode = 22 (S) code = 32, sym = 0x64 (d) scancode = 7 (D) code = 33, sym = 0x66 (f) scancode = 9 (F) code = 34, sym = 0x67 (g) scancode = 10 (G) code = 35, sym = 0x68 (h) scancode = 11 (H) code = 36, sym = 0x6A (j) scancode = 13 (J) code = 37, sym = 0x6B (k) scancode = 14 (K) code = 38, sym = 0x6C (l) scancode = 15 (L) code = 39, sym = 0x3B (semicolon) scancode = 51 (;) code = 40, sym = 0x27 (apostrophe) scancode = 52 (') code = 41, sym = 0x60 (grave) scancode = 53 (`) code = 42, sym = 0xFFE1 (Shift_L) scancode = 225 (Left Shift) code = 43, sym = 0x5C (backslash) scancode = 49 (\) code = 44, sym = 0x7A (z) scancode = 29 (Z) code = 45, sym = 0x78 (x) scancode = 27 (X) code = 46, sym = 0x63 (c) scancode = 6 (C) code = 47, sym = 0x76 (v) scancode = 25 (V) code = 48, sym = 0x62 (b) scancode = 5 (B) code = 49, sym = 0x6E (n) scancode = 17 (N) code = 50, sym = 0x6D (m) scancode = 16 (M) code = 51, sym = 0x2C (comma) scancode = 54 (,) code = 52, sym = 0x2E (period) scancode = 55 (.) code = 53, sym = 0x2F (slash) scancode = 56 (/) code = 54, sym = 0xFFE2 (Shift_R) scancode = 229 (Right Shift) code = 55, sym = 0xFFAA (KP_Multiply) scancode = 85 (Keypad *) code = 56, sym = 0xFFE9 (Alt_L) scancode = 226 (Left Alt) code = 57, sym = 0x20 (space) scancode = 44 (Space) code = 58, sym = 0xFFE5 (Caps_Lock) scancode = 57 (CapsLock) code = 59, sym = 0xFFBE (F1) scancode = 58 (F1) code = 60, sym = 0xFFBF (F2) scancode = 59 (F2) code = 61, sym = 0xFFC0 (F3) scancode = 60 (F3) code = 62, sym = 0xFFC1 (F4) scancode = 61 (F4) code = 63, sym = 0xFFC2 (F5) scancode = 62 (F5) code = 64, sym = 0xFFC3 (F6) scancode = 63 (F6) code = 65, sym = 0xFFC4 (F7) scancode = 64 (F7) code = 66, sym = 0xFFC5 (F8) scancode = 65 (F8) code = 67, sym = 0xFFC6 (F9) scancode = 66 (F9) code = 68, sym = 0xFFC7 (F10) scancode = 67 (F10) code = 69, sym = 0xFF7F (Num_Lock) scancode = 83 (Numlock) code = 70, sym = 0xFF14 (Scroll_Lock) scancode = 71 (ScrollLock) code = 71, sym = 0xFF95 (KP_Home) scancode = 95 (Keypad 7) code = 72, sym = 0xFF97 (KP_Up) scancode = 96 (Keypad 8) code = 73, sym = 0xFF9A (KP_Prior) scancode = 97 (Keypad 9) code = 74, sym = 0xFFAD (KP_Subtract) scancode = 86 (Keypad -) code = 75, sym = 0xFF96 (KP_Left) scancode = 92 (Keypad 4) code = 76, sym = 0xFF9D (KP_Begin) scancode = 93 (Keypad 5) code = 77, sym = 0xFF98 (KP_Right) scancode = 94 (Keypad 6) code = 78, sym = 0xFFAB (KP_Add) scancode = 87 (Keypad +) code = 79, sym = 0xFF9C (KP_End) scancode = 89 (Keypad 1) code = 80, sym = 0xFF99 (KP_Down) scancode = 90 (Keypad 2) code = 81, sym = 0xFF9B (KP_Next) scancode = 91 (Keypad 3) code = 82, sym = 0xFF9E (KP_Insert) scancode = 98 (Keypad 0) code = 83, sym = 0xFF9F (KP_Delete) scancode = 99 (Keypad .) code = 84, sym = 0xFE03 (ISO_Level3_Shift) scancode = 0 () code = 86, sym = 0x3C (less) scancode not found code = 87, sym = 0xFFC8 (F11) scancode = 68 (F11) code = 88, sym = 0xFFC9 (F12) scancode = 69 (F12) code = 90, sym = 0xFF26 (Katakana) scancode = 0 () code = 91, sym = 0xFF25 (Hiragana) scancode = 0 () code = 92, sym = 0xFF23 (Henkan_Mode) scancode = 0 () code = 93, sym = 0xFF27 (Hiragana_Katakana) scancode = 0 () code = 94, sym = 0xFF22 (Muhenkan) scancode = 0 () code = 96, sym = 0xFF8D (KP_Enter) scancode = 88 (Keypad Enter) code = 97, sym = 0xFFE4 (Control_R) scancode = 228 (Right Ctrl) code = 98, sym = 0xFFAF (KP_Divide) scancode = 84 (Keypad /) code = 99, sym = 0xFF61 (Print) scancode = 70 (PrintScreen) code = 100, sym = 0xFFEA (Alt_R) scancode = 230 (Right Alt) code = 101, sym = 0xFF0A (Linefeed) scancode = 0 () code = 102, sym = 0xFF50 (Home) scancode = 74 (Home) code = 103, sym = 0xFF52 (Up) scancode = 82 (Up) code = 104, sym = 0xFF55 (Prior) scancode = 75 (PageUp) code = 105, sym = 0xFF51 (Left) scancode = 80 (Left) code = 106, sym = 0xFF53 (Right) scancode = 79 (Right) code = 107, sym = 0xFF57 (End) scancode = 77 (End) code = 108, sym = 0xFF54 (Down) scancode = 81 (Down) code = 109, sym = 0xFF56 (Next) scancode = 78 (PageDown) code = 110, sym = 0xFF63 (Insert) scancode = 73 (Insert) code = 111, sym = 0xFFFF (Delete) scancode = 76 (Delete) code = 113, sym = 0x1008FF12 (XF86AudioMute) scancode = 0 () code = 114, sym = 0x1008FF11 (XF86AudioLowerVolume) scancode = 0 () code = 115, sym = 0x1008FF13 (XF86AudioRaiseVolume) scancode = 0 () code = 116, sym = 0x1008FF2A (XF86PowerOff) scancode = 0 () code = 117, sym = 0xFFBD (KP_Equal) scancode = 103 (Keypad =) code = 118, sym = 0xB1 (plusminus) scancode not found code = 119, sym = 0xFF13 (Pause) scancode = 72 (Pause) code = 120, sym = 0x1008FF4A (XF86LaunchA) scancode = 0 () code = 121, sym = 0xFFAE (KP_Decimal) scancode = 99 (Keypad .) code = 122, sym = 0xFF31 (Hangul) scancode = 0 () code = 123, sym = 0xFF34 (Hangul_Hanja) scancode = 0 () code = 125, sym = 0xFFEB (Super_L) scancode = 227 (Left GUI) code = 126, sym = 0xFFEC (Super_R) scancode = 231 (Right GUI) code = 127, sym = 0xFF67 (Menu) scancode = 118 (Menu) code = 128, sym = 0xFF69 (Cancel) scancode = 120 (Stop) code = 129, sym = 0xFF66 (Redo) scancode = 121 (Again) code = 130, sym = 0x1005FF70 (SunProps) scancode = 0 () code = 131, sym = 0xFF65 (Undo) scancode = 122 (Undo) code = 132, sym = 0x1005FF71 (SunFront) scancode = 0 () code = 133, sym = 0x1008FF57 (XF86Copy) scancode = 0 () code = 134, sym = 0x1005FF73 (SunOpen) scancode = 0 () code = 135, sym = 0x1008FF6D (XF86Paste) scancode = 0 () code = 136, sym = 0xFF68 (Find) scancode = 126 (Find) code = 137, sym = 0x1008FF58 (XF86Cut) scancode = 0 () code = 138, sym = 0xFF6A (Help) scancode = 117 (Help) code = 139, sym = 0x1008FF65 (XF86MenuKB) scancode = 0 () code = 140, sym = 0x1008FF1D (XF86Calculator) scancode = 0 () code = 142, sym = 0x1008FF2F (XF86Sleep) scancode = 0 () code = 143, sym = 0x1008FF2B (XF86WakeUp) scancode = 0 () code = 144, sym = 0x1008FF5D (XF86Explorer) scancode = 0 () code = 145, sym = 0x1008FF7B (XF86Send) scancode = 0 () code = 147, sym = 0x1008FF8A (XF86Xfer) scancode = 0 () code = 148, sym = 0x1008FF41 (XF86Launch1) scancode = 0 () code = 149, sym = 0x1008FF42 (XF86Launch2) scancode = 0 () code = 150, sym = 0x1008FF2E (XF86WWW) scancode = 0 () code = 151, sym = 0x1008FF5A (XF86DOS) scancode = 0 () code = 152, sym = 0x1008FF2D (XF86ScreenSaver) scancode = 0 () code = 154, sym = 0x1008FF74 (XF86RotateWindows) scancode = 0 () code = 155, sym = 0x1008FF19 (XF86Mail) scancode = 0 () code = 156, sym = 0x1008FF30 (XF86Favorites) scancode = 0 () code = 157, sym = 0x1008FF33 (XF86MyComputer) scancode = 0 () code = 158, sym = 0x1008FF26 (XF86Back) scancode = 0 () code = 159, sym = 0x1008FF27 (XF86Forward) scancode = 0 () code = 161, sym = 0x1008FF2C (XF86Eject) scancode = 0 () code = 162, sym = 0x1008FF2C (XF86Eject) scancode = 0 () code = 163, sym = 0x1008FF17 (XF86AudioNext) scancode = 0 () code = 164, sym = 0x1008FF14 (XF86AudioPlay) scancode = 0 () code = 165, sym = 0x1008FF16 (XF86AudioPrev) scancode = 0 () code = 166, sym = 0x1008FF15 (XF86AudioStop) scancode = 0 () code = 167, sym = 0x1008FF1C (XF86AudioRecord) scancode = 0 () code = 168, sym = 0x1008FF3E (XF86AudioRewind) scancode = 0 () code = 169, sym = 0x1008FF6E (XF86Phone) scancode = 0 () code = 171, sym = 0x1008FF81 (XF86Tools) scancode = 0 () code = 172, sym = 0x1008FF18 (XF86HomePage) scancode = 0 () code = 173, sym = 0x1008FF73 (XF86Reload) scancode = 0 () code = 174, sym = 0x1008FF56 (XF86Close) scancode = 0 () code = 177, sym = 0x1008FF78 (XF86ScrollUp) scancode = 0 () code = 178, sym = 0x1008FF79 (XF86ScrollDown) scancode = 0 () code = 179, sym = 0x28 (parenleft) scancode not found code = 180, sym = 0x29 (parenright) scancode not found code = 181, sym = 0x1008FF68 (XF86New) scancode = 0 () code = 182, sym = 0xFF66 (Redo) scancode = 121 (Again) code = 183, sym = 0x1008FF81 (XF86Tools) scancode = 0 () code = 184, sym = 0x1008FF45 (XF86Launch5) scancode = 0 () code = 185, sym = 0x1008FF65 (XF86MenuKB) scancode = 0 () code = 192, sym = 0x1008FFA9 (XF86TouchpadToggle) scancode = 0 () code = 195, sym = 0xFF7E (Mode_switch) scancode = 257 (ModeSwitch) code = 200, sym = 0x1008FF14 (XF86AudioPlay) scancode = 0 () code = 201, sym = 0x1008FF31 (XF86AudioPause) scancode = 0 () code = 202, sym = 0x1008FF43 (XF86Launch3) scancode = 0 () code = 203, sym = 0x1008FF44 (XF86Launch4) scancode = 0 () code = 204, sym = 0x1008FF4B (XF86LaunchB) scancode = 0 () code = 205, sym = 0x1008FFA7 (XF86Suspend) scancode = 0 () code = 206, sym = 0x1008FF56 (XF86Close) scancode = 0 () code = 207, sym = 0x1008FF14 (XF86AudioPlay) scancode = 0 () code = 208, sym = 0x1008FF97 (XF86AudioForward) scancode = 0 () code = 210, sym = 0xFF61 (Print) scancode = 70 (PrintScreen) code = 212, sym = 0x1008FF8F (XF86WebCam) scancode = 0 () code = 215, sym = 0x1008FF19 (XF86Mail) scancode = 0 () code = 217, sym = 0x1008FF1B (XF86Search) scancode = 0 () code = 219, sym = 0x1008FF3C (XF86Finance) scancode = 0 () code = 221, sym = 0x1008FF36 (XF86Shop) scancode = 0 () code = 223, sym = 0xFF69 (Cancel) scancode = 120 (Stop) code = 224, sym = 0x1008FF03 (XF86MonBrightnessDown) scancode = 0 () code = 225, sym = 0x1008FF02 (XF86MonBrightnessUp) scancode = 0 () code = 226, sym = 0x1008FF32 (XF86AudioMedia) scancode = 0 () code = 227, sym = 0x1008FF59 (XF86Display) scancode = 0 () code = 228, sym = 0x1008FF04 (XF86KbdLightOnOff) scancode = 0 () code = 229, sym = 0x1008FF06 (XF86KbdBrightnessDown) scancode = 0 () code = 230, sym = 0x1008FF05 (XF86KbdBrightnessUp) scancode = 0 () code = 231, sym = 0x1008FF7B (XF86Send) scancode = 0 () code = 232, sym = 0x1008FF72 (XF86Reply) scancode = 0 () code = 233, sym = 0x1008FF90 (XF86MailForward) scancode = 0 () code = 234, sym = 0x1008FF77 (XF86Save) scancode = 0 () code = 235, sym = 0x1008FF5B (XF86Documents) scancode = 0 () code = 236, sym = 0x1008FF93 (XF86Battery) scancode = 0 () code = 237, sym = 0x1008FF94 (XF86Bluetooth) scancode = 0 () code = 238, sym = 0x1008FF95 (XF86WLAN) scancode = 0 () --- src/events/scancodes_xfree86.h | 180 +++++++++++++++++++++++++-------- 1 file changed, 137 insertions(+), 43 deletions(-) diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index a17af6e1e..eee9f297f 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -262,24 +262,24 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 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_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,134 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 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_PAUSE, - /* 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_PAUSE, + /* 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 */ + /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ + /* 156 */ SDL_SCANCODE_MAIL, + /* 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 */ SDLK_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* */ From 9f03a464200ab9a0df8cd8df0e9ab336a846e724 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 00:50:18 -0700 Subject: [PATCH 48/53] Missed the numbering --- src/events/scancodes_xfree86.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index eee9f297f..630b07120 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -335,8 +335,6 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ /* 155 */ SDL_SCANCODE_MAIL, /* 156 */ SDL_SCANCODE_UNKNOWN, /* XF86Favorites */ - /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ - /* 156 */ SDL_SCANCODE_MAIL, /* 157 */ SDL_SCANCODE_COMPUTER, /* 158 */ SDL_SCANCODE_AC_BACK, /* 159 */ SDL_SCANCODE_AC_FORWARD, From 93aee3a1f7e8981fa7e9f6c962e7ab0985da4f17 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 00:54:26 -0700 Subject: [PATCH 49/53] Don't put a keysym in there! Shame on you! :) --- src/events/scancodes_xfree86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index 630b07120..296370edb 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -373,7 +373,7 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */ /* 193 */ SDL_SCANCODE_UNKNOWN, /* 194 */ SDL_SCANCODE_UNKNOWN, - /* 195 */ SDLK_MODE, + /* 195 */ SDL_SCANCODE_MODE, /* 196 */ SDL_SCANCODE_UNKNOWN, /* 197 */ SDL_SCANCODE_UNKNOWN, /* 198 */ SDL_SCANCODE_UNKNOWN, From d49a84bb858d3957ed466c93ccb7fc08dae0a50f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 01:00:01 -0700 Subject: [PATCH 50/53] Added back in a little more debugging for the X11 keyboard code --- src/video/x11/SDL_x11events.c | 4 ++-- src/video/x11/SDL_x11keyboard.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 514a98d7c..1b03b6d13 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -34,7 +34,7 @@ #include "SDL_timer.h" #include "SDL_syswm.h" -/*#define DEBUG_XEVENTS*/ +#define DEBUG_XEVENTS static void X11_DispatchEvent(_THIS) @@ -181,7 +181,7 @@ X11_DispatchEvent(_THIS) 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(display, &min_keycode, &max_keycode); diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index dc80195a1..d6d5b7f8d 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -211,7 +211,9 @@ X11_InitKeyboard(_THIS) } } 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; From f2b5f50026c2d42cd74db953aaaa4f7b74c39cfa Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 01:04:18 -0700 Subject: [PATCH 51/53] Double-confirmed, that's not the pause scancode --- src/events/scancodes_xfree86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events/scancodes_xfree86.h b/src/events/scancodes_xfree86.h index 296370edb..6d9f4e61c 100644 --- a/src/events/scancodes_xfree86.h +++ b/src/events/scancodes_xfree86.h @@ -299,7 +299,7 @@ static const SDL_scancode xfree86_scancode_table2[] = { /* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */ /* 119 */ SDL_SCANCODE_PAUSE, /* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */ - /* 121 */ SDL_SCANCODE_PAUSE, + /* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */ /* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */ /* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */ /* 124 */ SDL_SCANCODE_UNKNOWN, From 45bccbbc5cc2194f7d42e48010ba98b6808fe6f0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 08:12:28 -0700 Subject: [PATCH 52/53] Debian patch: 215_kfreebsd_gnu.diff --- src/joystick/bsd/SDL_sysjoystick.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c index d2e7e1c29..5fd15cad3 100644 --- a/src/joystick/bsd/SDL_sysjoystick.c +++ b/src/joystick/bsd/SDL_sysjoystick.c @@ -59,7 +59,7 @@ #include #endif -#ifdef __FREEBSD__ +#ifdef defined(__FREEBSD__) || defined(__FreeBSD_kernel__) #ifndef __DragonFly__ #include #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 char *joydevnames[MAX_JOYS]; 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 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy) 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 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy) 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 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) 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 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy) 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); From 99e65988f002f229ebbb804a1625a8e34ea7ebcf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 18 Jul 2010 10:26:46 -0700 Subject: [PATCH 53/53] Better fix for bug 936 Check to for overruns before they happen instead of afterwards. --- src/video/SDL_stretch.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 818d0dedc..09a9a24df 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -80,7 +80,7 @@ generate_rowbytes(int src_w, int dst_w, int bpp) 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 @@ generate_rowbytes(int src_w, int dst_w, int bpp) 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 @@ generate_rowbytes(int src_w, int dst_w, int bpp) } *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) {