Amazingly the Windows code is almost identical to the Mac OS X code. :)
authorSam Lantinga
Thu, 08 Jul 2010 23:07:34 -0700
changeset 45049faebccfefb3
parent 4503 524dfefd554c
child 4505 f78a602ac135
Amazingly the Windows code is almost identical to the Mac OS X code. :)
VisualC/SDL/SDL_VS2005.vcproj
VisualC/SDL/SDL_VS2008.vcproj
src/video/cocoa/SDL_cocoaclipboard.m
src/video/win32/SDL_win32clipboard.c
src/video/win32/SDL_win32clipboard.h
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
     1.1 --- a/VisualC/SDL/SDL_VS2005.vcproj	Thu Jul 08 22:54:03 2010 -0700
     1.2 +++ b/VisualC/SDL/SDL_VS2005.vcproj	Thu Jul 08 23:07:34 2010 -0700
     1.3 @@ -569,6 +569,14 @@
     1.4  			>
     1.5  		</File>
     1.6  		<File
     1.7 +			RelativePath="..\..\src\events\SDL_clipboardevents.c"
     1.8 +			>
     1.9 +		</File>
    1.10 +		<File
    1.11 +			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
    1.12 +			>
    1.13 +		</File>
    1.14 +		<File
    1.15  			RelativePath="..\..\src\SDL_compat.c"
    1.16  			>
    1.17  		</File>
     2.1 --- a/VisualC/SDL/SDL_VS2008.vcproj	Thu Jul 08 22:54:03 2010 -0700
     2.2 +++ b/VisualC/SDL/SDL_VS2008.vcproj	Thu Jul 08 23:07:34 2010 -0700
     2.3 @@ -724,6 +724,14 @@
     2.4  			>
     2.5  		</File>
     2.6  		<File
     2.7 +			RelativePath="..\..\src\events\SDL_clipboardevents.c"
     2.8 +			>
     2.9 +		</File>
    2.10 +		<File
    2.11 +			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
    2.12 +			>
    2.13 +		</File>
    2.14 +		<File
    2.15  			RelativePath="..\..\src\SDL_compat.c"
    2.16  			>
    2.17  		</File>
     3.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 22:54:03 2010 -0700
     3.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 23:07:34 2010 -0700
     3.3 @@ -45,7 +45,7 @@
     3.4  {
     3.5      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     3.6      NSAutoreleasePool *pool;
     3.7 -	NSPasteboard *pasteboard;
     3.8 +    NSPasteboard *pasteboard;
     3.9      NSString *format = GetTextFormat(_this);
    3.10  
    3.11      pool = [[NSAutoreleasePool alloc] init];
    3.12 @@ -63,7 +63,7 @@
    3.13  Cocoa_GetClipboardText(_THIS)
    3.14  {
    3.15      NSAutoreleasePool *pool;
    3.16 -	NSPasteboard *pasteboard;
    3.17 +    NSPasteboard *pasteboard;
    3.18      NSString *format = GetTextFormat(_this);
    3.19      NSString *available;
    3.20      char *text;
    3.21 @@ -96,7 +96,7 @@
    3.22  Cocoa_HasClipboardText(_THIS)
    3.23  {
    3.24      NSAutoreleasePool *pool;
    3.25 -	NSPasteboard *pasteboard;
    3.26 +    NSPasteboard *pasteboard;
    3.27      NSString *format = GetTextFormat(_this);
    3.28      NSString *available;
    3.29      SDL_bool result;
    3.30 @@ -120,7 +120,7 @@
    3.31  Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
    3.32  {
    3.33      NSAutoreleasePool *pool;
    3.34 -	NSPasteboard *pasteboard;
    3.35 +    NSPasteboard *pasteboard;
    3.36      NSInteger count;
    3.37  
    3.38      pool = [[NSAutoreleasePool alloc] init];
     4.1 --- a/src/video/win32/SDL_win32clipboard.c	Thu Jul 08 22:54:03 2010 -0700
     4.2 +++ b/src/video/win32/SDL_win32clipboard.c	Thu Jul 08 23:07:34 2010 -0700
     4.3 @@ -23,6 +23,7 @@
     4.4  
     4.5  #include "SDL_win32video.h"
     4.6  #include "SDL_win32window.h"
     4.7 +#include "../../events/SDL_clipboardevents_c.h"
     4.8  
     4.9  
    4.10  #ifdef UNICODE
    4.11 @@ -52,6 +53,7 @@
    4.12  int
    4.13  WIN_SetClipboardText(_THIS, const char *text)
    4.14  {
    4.15 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    4.16      int result = 0;
    4.17  
    4.18      if (OpenClipboard(GetWindowHandle(_this))) {
    4.19 @@ -93,6 +95,7 @@
    4.20                  WIN_SetError("Couldn't set clipboard data");
    4.21                  result = -1;
    4.22              }
    4.23 +            data->clipboard_count = GetClipboardSequenceNumber();
    4.24          }
    4.25          SDL_free(tstr);
    4.26  
    4.27 @@ -141,4 +144,18 @@
    4.28      }
    4.29  }
    4.30  
    4.31 +void
    4.32 +WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
    4.33 +{
    4.34 +    DWORD count;
    4.35 +
    4.36 +    count = GetClipboardSequenceNumber();
    4.37 +    if (count != data->clipboard_count) {
    4.38 +        if (data->clipboard_count) {
    4.39 +            SDL_SendClipboardUpdate();
    4.40 +        }
    4.41 +        data->clipboard_count = count;
    4.42 +    }
    4.43 +}
    4.44 +
    4.45  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/win32/SDL_win32clipboard.h	Thu Jul 08 22:54:03 2010 -0700
     5.2 +++ b/src/video/win32/SDL_win32clipboard.h	Thu Jul 08 23:07:34 2010 -0700
     5.3 @@ -24,9 +24,13 @@
     5.4  #ifndef _SDL_win32clipboard_h
     5.5  #define _SDL_win32clipboard_h
     5.6  
     5.7 +/* Forward declaration */
     5.8 +struct SDL_VideoData;
     5.9 +
    5.10  extern int WIN_SetClipboardText(_THIS, const char *text);
    5.11  extern char *WIN_GetClipboardText(_THIS);
    5.12  extern SDL_bool WIN_HasClipboardText(_THIS);
    5.13 +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data);
    5.14  
    5.15  #endif /* _SDL_win32clipboard_h */
    5.16  
     6.1 --- a/src/video/win32/SDL_win32events.c	Thu Jul 08 22:54:03 2010 -0700
     6.2 +++ b/src/video/win32/SDL_win32events.c	Thu Jul 08 23:07:34 2010 -0700
     6.3 @@ -162,7 +162,10 @@
     6.4                  if (SDL_GetKeyboardFocus() != data->window) {
     6.5                      SDL_SetKeyboardFocus(data->window);
     6.6                  }
     6.7 -                /* FIXME: Update keyboard state */
     6.8 +                /*
     6.9 +                 * FIXME: Update keyboard state
    6.10 +                 */
    6.11 +                WIN_CheckClipboardUpdate(data->videodata);
    6.12              } else {
    6.13                  if (SDL_GetKeyboardFocus() == data->window) {
    6.14                      SDL_SetKeyboardFocus(NULL);
     7.1 --- a/src/video/win32/SDL_win32video.c	Thu Jul 08 22:54:03 2010 -0700
     7.2 +++ b/src/video/win32/SDL_win32video.c	Thu Jul 08 23:07:34 2010 -0700
     7.3 @@ -28,7 +28,6 @@
     7.4  #include "../SDL_pixels_c.h"
     7.5  
     7.6  #include "SDL_win32video.h"
     7.7 -#include "SDL_win32clipboard.h"
     7.8  #include "SDL_d3drender.h"
     7.9  #include "SDL_gdirender.h"
    7.10  
     8.1 --- a/src/video/win32/SDL_win32video.h	Thu Jul 08 22:54:03 2010 -0700
     8.2 +++ b/src/video/win32/SDL_win32video.h	Thu Jul 08 23:07:34 2010 -0700
     8.3 @@ -45,6 +45,7 @@
     8.4  #include "ddraw.h"
     8.5  #endif
     8.6  
     8.7 +#include "SDL_win32clipboard.h"
     8.8  #include "SDL_win32events.h"
     8.9  #include "SDL_win32gamma.h"
    8.10  #include "SDL_win32keyboard.h"
    8.11 @@ -75,6 +76,8 @@
    8.12      IDirectDraw *ddraw;
    8.13  #endif
    8.14  
    8.15 +    DWORD clipboard_count;
    8.16 +
    8.17      const SDL_scancode *key_layout;
    8.18  } SDL_VideoData;
    8.19