Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
authorSam Lantinga
Thu, 08 Jul 2010 22:54:03 -0700
changeset 4503524dfefd554c
parent 4502 b3540fa08474
child 4504 9faebccfefb3
Added an event when the clipboard is updated, triggered after the window gains the keyboard focus.
Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj
Xcode/SDL/SDL.xcodeproj/project.pbxproj
include/SDL_events.h
src/events/SDL_clipboardevents.c
src/events/SDL_clipboardevents_c.h
src/video/cocoa/SDL_cocoaclipboard.h
src/video/cocoa/SDL_cocoaclipboard.m
src/video/cocoa/SDL_cocoavideo.h
src/video/cocoa/SDL_cocoawindow.m
test/common.c
     1.1 --- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Thu Jul 08 06:21:48 2010 -0700
     1.2 +++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Thu Jul 08 22:54:03 2010 -0700
     1.3 @@ -62,6 +62,8 @@
     1.4  		0098A5631195B4D900343137 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5621195B4D900343137 /* OpenGLES.framework */; };
     1.5  		0098A5651195B4D900343137 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5641195B4D900343137 /* UIKit.framework */; };
     1.6  		0098A5851195B5E200343137 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5841195B5E200343137 /* QuartzCore.framework */; };
     1.7 +		0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; };
     1.8 +		0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; };
     1.9  		043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */; };
    1.10  		043DD77010FD8A0000DED673 /* SDL_alphamult.h in Headers */ = {isa = PBXBuildFile; fileRef = 043DD76C10FD8A0000DED673 /* SDL_alphamult.h */; };
    1.11  		043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */; };
    1.12 @@ -311,6 +313,8 @@
    1.13  		0098A5621195B4D900343137 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
    1.14  		0098A5641195B4D900343137 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
    1.15  		0098A5841195B5E200343137 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
    1.16 +		0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
    1.17 +		0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
    1.18  		043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; };
    1.19  		043DD76C10FD8A0000DED673 /* SDL_alphamult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_alphamult.h; sourceTree = "<group>"; };
    1.20  		043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
    1.21 @@ -958,6 +962,8 @@
    1.22  				FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */,
    1.23  				FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */,
    1.24  				FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */,
    1.25 +				0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */,
    1.26 +				0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */,
    1.27  				FD99B9930DD52EDC00FB1D6B /* SDL_events.c */,
    1.28  				FD99B9940DD52EDC00FB1D6B /* SDL_events_c.h */,
    1.29  				FD99B9950DD52EDC00FB1D6B /* SDL_keyboard.c */,
    1.30 @@ -1184,6 +1190,7 @@
    1.31  				006E9888119552DD001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
    1.32  				044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */,
    1.33  				044E5FB611E6069F0076F181 /* SDL_input.h in Headers */,
    1.34 +				0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
    1.35  			);
    1.36  			runOnlyForDeploymentPostprocessing = 0;
    1.37  		};
    1.38 @@ -1423,6 +1430,7 @@
    1.39  				56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */,
    1.40  				006E9889119552DD001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
    1.41  				044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */,
    1.42 +				0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */,
    1.43  			);
    1.44  			runOnlyForDeploymentPostprocessing = 0;
    1.45  		};
     2.1 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Thu Jul 08 06:21:48 2010 -0700
     2.2 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Thu Jul 08 22:54:03 2010 -0700
     2.3 @@ -438,6 +438,22 @@
     2.4  		00D8DA281195093100638393 /* SDL_at.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA151195093100638393 /* SDL_at.c */; };
     2.5  		00D8DA291195093100638393 /* surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA181195093100638393 /* surface.c */; };
     2.6  		00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; };
     2.7 +		0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; };
     2.8 +		0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; };
     2.9 +		0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */; };
    2.10 +		0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */; };
    2.11 +		0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; };
    2.12 +		0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; };
    2.13 +		0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; };
    2.14 +		0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; };
    2.15 +		0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; };
    2.16 +		0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; };
    2.17 +		0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497411E6F052007E7EC9 /* blank_cursor.h */; };
    2.18 +		0420498111E6F052007E7EC9 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497511E6F052007E7EC9 /* default_cursor.h */; };
    2.19 +		0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497611E6F052007E7EC9 /* scancodes_darwin.h */; };
    2.20 +		0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497711E6F052007E7EC9 /* scancodes_linux.h */; };
    2.21 +		0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497811E6F052007E7EC9 /* scancodes_win32.h */; };
    2.22 +		0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420497911E6F052007E7EC9 /* scancodes_xfree86.h */; };
    2.23  		044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
    2.24  		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
    2.25  		046B91EC0A11B53500FB151C /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 046B91E90A11B53500FB151C /* SDL_sysloadso.c */; };
    2.26 @@ -805,6 +821,14 @@
    2.27  		01538439006D7D947F000001 /* SDL_fatal.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL_fatal.c; path = ../../src/SDL_fatal.c; sourceTree = SOURCE_ROOT; };
    2.28  		0153843C006D7D947F000001 /* SDL.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SDL.c; path = ../../src/SDL.c; sourceTree = SOURCE_ROOT; };
    2.29  		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; };
    2.30 +		0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
    2.31 +		0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
    2.32 +		0420497411E6F052007E7EC9 /* blank_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blank_cursor.h; sourceTree = "<group>"; };
    2.33 +		0420497511E6F052007E7EC9 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
    2.34 +		0420497611E6F052007E7EC9 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
    2.35 +		0420497711E6F052007E7EC9 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
    2.36 +		0420497811E6F052007E7EC9 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
    2.37 +		0420497911E6F052007E7EC9 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
    2.38  		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
    2.39  		046B91E90A11B53500FB151C /* SDL_sysloadso.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_sysloadso.c; sourceTree = "<group>"; };
    2.40  		046B92100A11B8AD00FB151C /* SDL_dlcompat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SDL_dlcompat.c; sourceTree = "<group>"; };
    2.41 @@ -1329,6 +1353,14 @@
    2.42  		01538367006D79147F000001 /* events */ = {
    2.43  			isa = PBXGroup;
    2.44  			children = (
    2.45 +				0420497411E6F052007E7EC9 /* blank_cursor.h */,
    2.46 +				0420497511E6F052007E7EC9 /* default_cursor.h */,
    2.47 +				0420497611E6F052007E7EC9 /* scancodes_darwin.h */,
    2.48 +				0420497711E6F052007E7EC9 /* scancodes_linux.h */,
    2.49 +				0420497811E6F052007E7EC9 /* scancodes_win32.h */,
    2.50 +				0420497911E6F052007E7EC9 /* scancodes_xfree86.h */,
    2.51 +				0420495F11E6EFD3007E7EC9 /* SDL_clipboardevents_c.h */,
    2.52 +				0420496011E6EFD3007E7EC9 /* SDL_clipboardevents.c */,
    2.53  				00CFA6C2106B480800758660 /* SDL_events_c.h */,
    2.54  				01538369006D79147F000001 /* SDL_events.c */,
    2.55  				00CFA6C3106B480800758660 /* SDL_keyboard_c.h */,
    2.56 @@ -1766,6 +1798,13 @@
    2.57  				04DEA57111E6006A00386CAC /* SDL_input.h in Headers */,
    2.58  				04DEA57911E600A600386CAC /* SDL_cocoaclipboard.h in Headers */,
    2.59  				044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */,
    2.60 +				0420496111E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
    2.61 +				0420497A11E6F052007E7EC9 /* blank_cursor.h in Headers */,
    2.62 +				0420497B11E6F052007E7EC9 /* default_cursor.h in Headers */,
    2.63 +				0420497C11E6F052007E7EC9 /* scancodes_darwin.h in Headers */,
    2.64 +				0420497D11E6F052007E7EC9 /* scancodes_linux.h in Headers */,
    2.65 +				0420497E11E6F052007E7EC9 /* scancodes_win32.h in Headers */,
    2.66 +				0420497F11E6F052007E7EC9 /* scancodes_xfree86.h in Headers */,
    2.67  			);
    2.68  			runOnlyForDeploymentPostprocessing = 0;
    2.69  		};
    2.70 @@ -1869,6 +1908,13 @@
    2.71  				04DEA57311E6006A00386CAC /* SDL_input.h in Headers */,
    2.72  				04DEA57B11E600A600386CAC /* SDL_cocoaclipboard.h in Headers */,
    2.73  				044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */,
    2.74 +				0420496311E6EFD3007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
    2.75 +				0420498011E6F052007E7EC9 /* blank_cursor.h in Headers */,
    2.76 +				0420498111E6F052007E7EC9 /* default_cursor.h in Headers */,
    2.77 +				0420498211E6F052007E7EC9 /* scancodes_darwin.h in Headers */,
    2.78 +				0420498311E6F052007E7EC9 /* scancodes_linux.h in Headers */,
    2.79 +				0420498411E6F052007E7EC9 /* scancodes_win32.h in Headers */,
    2.80 +				0420498511E6F052007E7EC9 /* scancodes_xfree86.h in Headers */,
    2.81  			);
    2.82  			runOnlyForDeploymentPostprocessing = 0;
    2.83  		};
    2.84 @@ -2230,6 +2276,7 @@
    2.85  				006E95B111952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
    2.86  				04DEA57511E6009000386CAC /* SDL_clipboard.c in Sources */,
    2.87  				04DEA57A11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */,
    2.88 +				0420496211E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */,
    2.89  			);
    2.90  			runOnlyForDeploymentPostprocessing = 0;
    2.91  		};
    2.92 @@ -2348,6 +2395,7 @@
    2.93  				006E95B311952992001DE610 /* SDL_rwopsbundlesupport.m in Sources */,
    2.94  				04DEA57611E6009000386CAC /* SDL_clipboard.c in Sources */,
    2.95  				04DEA57C11E600A600386CAC /* SDL_cocoaclipboard.m in Sources */,
    2.96 +				0420496411E6EFD3007E7EC9 /* SDL_clipboardevents.c in Sources */,
    2.97  			);
    2.98  			runOnlyForDeploymentPostprocessing = 0;
    2.99  		};
     3.1 --- a/include/SDL_events.h	Thu Jul 08 06:21:48 2010 -0700
     3.2 +++ b/include/SDL_events.h	Thu Jul 08 22:54:03 2010 -0700
     3.3 @@ -90,6 +90,9 @@
     3.4      SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
     3.5      SDL_JOYBUTTONUP,            /**< Joystick button released */
     3.6  
     3.7 +    /* Clipboard events */
     3.8 +    SDL_CLIPBOARDUPDATE = 0x700, /**< The clipboard changed */
     3.9 +
    3.10      /* Obsolete events */
    3.11      SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
    3.12      SDL_EVENT_COMPAT2,
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/events/SDL_clipboardevents.c	Thu Jul 08 22:54:03 2010 -0700
     4.3 @@ -0,0 +1,47 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2010 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +/* Clipboard event handling code for SDL */
    4.28 +
    4.29 +#include "SDL_events.h"
    4.30 +#include "SDL_events_c.h"
    4.31 +#include "SDL_clipboardevents_c.h"
    4.32 +
    4.33 +
    4.34 +int
    4.35 +SDL_SendClipboardUpdate()
    4.36 +{
    4.37 +    int posted;
    4.38 +
    4.39 +    /* Post the event, if desired */
    4.40 +    posted = 0;
    4.41 +    if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) {
    4.42 +        SDL_Event event;
    4.43 +        event.type = SDL_CLIPBOARDUPDATE;
    4.44 +
    4.45 +        posted = (SDL_PushEvent(&event) > 0);
    4.46 +    }
    4.47 +    return (posted);
    4.48 +}
    4.49 +
    4.50 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/events/SDL_clipboardevents_c.h	Thu Jul 08 22:54:03 2010 -0700
     5.3 @@ -0,0 +1,31 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2010 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +#include "SDL_config.h"
    5.26 +
    5.27 +#ifndef _SDL_clipboardevents_c_h
    5.28 +#define _SDL_clipboardevents_c_h
    5.29 +
    5.30 +extern int SDL_SendClipboardUpdate();
    5.31 +
    5.32 +#endif /* _SDL_clipboardevents_c_h */
    5.33 +
    5.34 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/cocoa/SDL_cocoaclipboard.h	Thu Jul 08 06:21:48 2010 -0700
     6.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.h	Thu Jul 08 22:54:03 2010 -0700
     6.3 @@ -24,9 +24,13 @@
     6.4  #ifndef _SDL_cocoaclipboard_h
     6.5  #define _SDL_cocoaclipboard_h
     6.6  
     6.7 +/* Forward declaration */
     6.8 +struct SDL_VideoData;
     6.9 +
    6.10  extern int Cocoa_SetClipboardText(_THIS, const char *text);
    6.11  extern char *Cocoa_GetClipboardText(_THIS);
    6.12  extern SDL_bool Cocoa_HasClipboardText(_THIS);
    6.13 +extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data);
    6.14  
    6.15  #endif /* _SDL_cocoaclipboard_h */
    6.16  
     7.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 06:21:48 2010 -0700
     7.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 22:54:03 2010 -0700
     7.3 @@ -22,6 +22,7 @@
     7.4  #include "SDL_config.h"
     7.5  
     7.6  #include "SDL_cocoavideo.h"
     7.7 +#include "../../events/SDL_clipboardevents_c.h"
     7.8  
     7.9  static NSString *
    7.10  GetTextFormat(_THIS)
    7.11 @@ -42,6 +43,7 @@
    7.12  int
    7.13  Cocoa_SetClipboardText(_THIS, const char *text)
    7.14  {
    7.15 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    7.16      NSAutoreleasePool *pool;
    7.17  	NSPasteboard *pasteboard;
    7.18      NSString *format = GetTextFormat(_this);
    7.19 @@ -49,7 +51,7 @@
    7.20      pool = [[NSAutoreleasePool alloc] init];
    7.21  
    7.22      pasteboard = [NSPasteboard generalPasteboard];
    7.23 -    [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    7.24 +    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    7.25      [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    7.26  
    7.27      [pool release];
    7.28 @@ -114,4 +116,25 @@
    7.29      return result;
    7.30  }
    7.31  
    7.32 +void
    7.33 +Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
    7.34 +{
    7.35 +    NSAutoreleasePool *pool;
    7.36 +	NSPasteboard *pasteboard;
    7.37 +    NSInteger count;
    7.38 +
    7.39 +    pool = [[NSAutoreleasePool alloc] init];
    7.40 +
    7.41 +    pasteboard = [NSPasteboard generalPasteboard];
    7.42 +    count = [pasteboard changeCount];
    7.43 +    if (count != data->clipboard_count) {
    7.44 +        if (data->clipboard_count) {
    7.45 +            SDL_SendClipboardUpdate();
    7.46 +        }
    7.47 +        data->clipboard_count = count;
    7.48 +    }
    7.49 +
    7.50 +    [pool release];
    7.51 +}
    7.52 +
    7.53  /* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/cocoa/SDL_cocoavideo.h	Thu Jul 08 06:21:48 2010 -0700
     8.2 +++ b/src/video/cocoa/SDL_cocoavideo.h	Thu Jul 08 22:54:03 2010 -0700
     8.3 @@ -60,6 +60,7 @@
     8.4      unsigned int modifierFlags;
     8.5      void *key_layout;
     8.6      SDLTranslatorResponder *fieldEdit;
     8.7 +    NSInteger clipboard_count;
     8.8      Uint32 screensaver_activity;
     8.9  } SDL_VideoData;
    8.10  
     9.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Jul 08 06:21:48 2010 -0700
     9.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Jul 08 22:54:03 2010 -0700
     9.3 @@ -128,6 +128,9 @@
     9.4  {
     9.5      /* We're going to get keyboard events, since we're key. */
     9.6      SDL_SetKeyboardFocus(_data->window);
     9.7 +
     9.8 +    /* Check to see if someone updated the clipboard */
     9.9 +    Cocoa_CheckClipboardUpdate(_data->videodata);
    9.10  }
    9.11  
    9.12  - (void)windowDidResignKey:(NSNotification *)aNotification
    10.1 --- a/test/common.c	Thu Jul 08 06:21:48 2010 -0700
    10.2 +++ b/test/common.c	Thu Jul 08 22:54:03 2010 -0700
    10.3 @@ -1017,6 +1017,9 @@
    10.4          fprintf(stderr, "Joystick %d: button %d released",
    10.5                  event->jbutton.which, event->jbutton.button);
    10.6          break;
    10.7 +    case SDL_CLIPBOARDUPDATE:
    10.8 +        fprintf(stderr, "Clipboard updated");
    10.9 +        break;
   10.10      case SDL_QUIT:
   10.11          fprintf(stderr, "Quit requested");
   10.12          break;