src/video/cocoa/SDL_cocoaclipboard.m
changeset 4503 524dfefd554c
parent 4501 0cf025066b6f
child 4504 9faebccfefb3
     1.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 06:21:48 2010 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Thu Jul 08 22:54:03 2010 -0700
     1.3 @@ -22,6 +22,7 @@
     1.4  #include "SDL_config.h"
     1.5  
     1.6  #include "SDL_cocoavideo.h"
     1.7 +#include "../../events/SDL_clipboardevents_c.h"
     1.8  
     1.9  static NSString *
    1.10  GetTextFormat(_THIS)
    1.11 @@ -42,6 +43,7 @@
    1.12  int
    1.13  Cocoa_SetClipboardText(_THIS, const char *text)
    1.14  {
    1.15 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.16      NSAutoreleasePool *pool;
    1.17  	NSPasteboard *pasteboard;
    1.18      NSString *format = GetTextFormat(_this);
    1.19 @@ -49,7 +51,7 @@
    1.20      pool = [[NSAutoreleasePool alloc] init];
    1.21  
    1.22      pasteboard = [NSPasteboard generalPasteboard];
    1.23 -    [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    1.24 +    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    1.25      [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    1.26  
    1.27      [pool release];
    1.28 @@ -114,4 +116,25 @@
    1.29      return result;
    1.30  }
    1.31  
    1.32 +void
    1.33 +Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
    1.34 +{
    1.35 +    NSAutoreleasePool *pool;
    1.36 +	NSPasteboard *pasteboard;
    1.37 +    NSInteger count;
    1.38 +
    1.39 +    pool = [[NSAutoreleasePool alloc] init];
    1.40 +
    1.41 +    pasteboard = [NSPasteboard generalPasteboard];
    1.42 +    count = [pasteboard changeCount];
    1.43 +    if (count != data->clipboard_count) {
    1.44 +        if (data->clipboard_count) {
    1.45 +            SDL_SendClipboardUpdate();
    1.46 +        }
    1.47 +        data->clipboard_count = count;
    1.48 +    }
    1.49 +
    1.50 +    [pool release];
    1.51 +}
    1.52 +
    1.53  /* vi: set ts=4 sw=4 expandtab: */