changeset 4504:9faebccfefb3

Amazingly the Windows code is almost identical to the Mac OS X code. :)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 08 Jul 2010 23:07:34 -0700
parents 524dfefd554c
children f78a602ac135
files 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
diffstat 8 files changed, 48 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/VisualC/SDL/SDL_VS2005.vcproj	Thu Jul 08 22:54:03 2010 -0700
+++ b/VisualC/SDL/SDL_VS2005.vcproj	Thu Jul 08 23:07:34 2010 -0700
@@ -569,6 +569,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\events\SDL_clipboardevents.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\SDL_compat.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2008.vcproj	Thu Jul 08 22:54:03 2010 -0700
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Thu Jul 08 23:07:34 2010 -0700
@@ -724,6 +724,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\events\SDL_clipboardevents.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\SDL_compat.c"
 			>
 		</File>
--- a/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 23:07:34 2010 -0700
@@ -45,7 +45,7 @@
 {
     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 @@
 Cocoa_GetClipboardText(_THIS)
 {
     NSAutoreleasePool *pool;
-	NSPasteboard *pasteboard;
+    NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
     NSString *available;
     char *text;
@@ -96,7 +96,7 @@
 Cocoa_HasClipboardText(_THIS)
 {
     NSAutoreleasePool *pool;
-	NSPasteboard *pasteboard;
+    NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
     NSString *available;
     SDL_bool result;
@@ -120,7 +120,7 @@
 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
 {
     NSAutoreleasePool *pool;
-	NSPasteboard *pasteboard;
+    NSPasteboard *pasteboard;
     NSInteger count;
 
     pool = [[NSAutoreleasePool alloc] init];
--- a/src/video/win32/SDL_win32clipboard.c	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/win32/SDL_win32clipboard.c	Thu Jul 08 23:07:34 2010 -0700
@@ -23,6 +23,7 @@
 
 #include "SDL_win32video.h"
 #include "SDL_win32window.h"
+#include "../../events/SDL_clipboardevents_c.h"
 
 
 #ifdef UNICODE
@@ -52,6 +53,7 @@
 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_SetError("Couldn't set clipboard data");
                 result = -1;
             }
+            data->clipboard_count = GetClipboardSequenceNumber();
         }
         SDL_free(tstr);
 
@@ -141,4 +144,18 @@
     }
 }
 
+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: */
--- a/src/video/win32/SDL_win32clipboard.h	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/win32/SDL_win32clipboard.h	Thu Jul 08 23:07:34 2010 -0700
@@ -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 */
 
--- a/src/video/win32/SDL_win32events.c	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/win32/SDL_win32events.c	Thu Jul 08 23:07:34 2010 -0700
@@ -162,7 +162,10 @@
                 if (SDL_GetKeyboardFocus() != data->window) {
                     SDL_SetKeyboardFocus(data->window);
                 }
-                /* FIXME: Update keyboard state */
+                /*
+                 * FIXME: Update keyboard state
+                 */
+                WIN_CheckClipboardUpdate(data->videodata);
             } else {
                 if (SDL_GetKeyboardFocus() == data->window) {
                     SDL_SetKeyboardFocus(NULL);
--- a/src/video/win32/SDL_win32video.c	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/win32/SDL_win32video.c	Thu Jul 08 23:07:34 2010 -0700
@@ -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"
 
--- a/src/video/win32/SDL_win32video.h	Thu Jul 08 22:54:03 2010 -0700
+++ b/src/video/win32/SDL_win32video.h	Thu Jul 08 23:07:34 2010 -0700
@@ -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 @@
     IDirectDraw *ddraw;
 #endif
 
+    DWORD clipboard_count;
+
     const SDL_scancode *key_layout;
 } SDL_VideoData;