Module: wine Branch: master Commit: 4ae5b106f80eb29ed0b05b74edf054b622fb7ac8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4ae5b106f80eb29ed0b05b74ed...
Author: Ken Thomases ken@codeweavers.com Date: Wed Mar 13 16:53:04 2013 -0500
winemac: Enable pasteboard functions to operate on arbitrary pasteboards.
... not just the general pasteboard (although the general pasteboard is still the default).
---
dlls/winemac.drv/clipboard.c | 12 ++++++------ dlls/winemac.drv/cocoa_clipboard.m | 22 ++++++++++++++-------- dlls/winemac.drv/macdrv_cocoa.h | 4 ++-- 3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 2219df6..4a6f859 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -1326,7 +1326,7 @@ INT CDECL macdrv_CountClipboardFormats(void) return 0; }
- types = macdrv_copy_pasteboard_types(); + types = macdrv_copy_pasteboard_types(NULL); if (!types) { WARN("Failed to copy pasteboard types\n"); @@ -1396,7 +1396,7 @@ UINT CDECL macdrv_EnumClipboardFormats(UINT prev_format) TRACE("prev_format %s\n", debugstr_format(prev_format)); check_clipboard_ownership(NULL);
- types = macdrv_copy_pasteboard_types(); + types = macdrv_copy_pasteboard_types(NULL); if (!types) { WARN("Failed to copy pasteboard types\n"); @@ -1490,7 +1490,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format) TRACE("desired_format %s\n", debugstr_format(desired_format)); check_clipboard_ownership(NULL);
- types = macdrv_copy_pasteboard_types(); + types = macdrv_copy_pasteboard_types(NULL); if (!types) { WARN("Failed to copy pasteboard types\n"); @@ -1526,7 +1526,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format)
if (best_format) { - CFDataRef pasteboard_data = macdrv_copy_pasteboard_data(best_type); + CFDataRef pasteboard_data = macdrv_copy_pasteboard_data(NULL, best_type);
TRACE("got pasteboard data for type %s: %s\n", debugstr_cf(best_type), debugstr_cf(pasteboard_data));
@@ -1556,7 +1556,7 @@ BOOL CDECL macdrv_IsClipboardFormatAvailable(UINT desired_format) TRACE("desired_format %s\n", debugstr_format(desired_format)); check_clipboard_ownership(NULL);
- types = macdrv_copy_pasteboard_types(); + types = macdrv_copy_pasteboard_types(NULL); if (!types) { WARN("Failed to copy pasteboard types\n"); @@ -1758,7 +1758,7 @@ BOOL query_pasteboard_data(HWND hwnd, CFStringRef type)
if (!types) { - types = macdrv_copy_pasteboard_types(); + types = macdrv_copy_pasteboard_types(NULL); if (!types) { WARN("Failed to copy pasteboard types\n"); diff --git a/dlls/winemac.drv/cocoa_clipboard.m b/dlls/winemac.drv/cocoa_clipboard.m index 8d29326..b8ca796 100644 --- a/dlls/winemac.drv/cocoa_clipboard.m +++ b/dlls/winemac.drv/cocoa_clipboard.m @@ -53,8 +53,9 @@ int macdrv_is_pasteboard_owner(void) * the pasteboard, or NULL on error. The caller is responsible for * releasing the returned array with CFRelease(). */ -CFArrayRef macdrv_copy_pasteboard_types(void) +CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) { + NSPasteboard* pb = (NSPasteboard*)pasteboard; __block CFArrayRef ret = NULL; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -79,8 +80,11 @@ CFArrayRef macdrv_copy_pasteboard_types(void) OnMainThread(^{ @try { - NSPasteboard* pb = [NSPasteboard generalPasteboard]; - NSArray* types = [pb types]; + NSPasteboard* local_pb = pb; + NSArray* types; + + if (!local_pb) local_pb = [NSPasteboard generalPasteboard]; + types = [local_pb types];
// If there are any types understood by NSBitmapImageRep, then we // can offer all of the types that it can output, too. For example, @@ -115,22 +119,24 @@ CFArrayRef macdrv_copy_pasteboard_types(void) * if there's no such type on the pasteboard. The caller is responsible * for releasing the returned data object with CFRelease(). */ -CFDataRef macdrv_copy_pasteboard_data(CFStringRef type) +CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) { + NSPasteboard* pb = (NSPasteboard*)pasteboard; __block NSData* ret = nil;
OnMainThread(^{ @try { - NSPasteboard* pb = [NSPasteboard generalPasteboard]; - if ([pb availableTypeFromArray:[NSArray arrayWithObject:(NSString*)type]]) - ret = [[pb dataForType:(NSString*)type] copy]; + NSPasteboard* local_pb = pb; + if (!local_pb) local_pb = [NSPasteboard generalPasteboard]; + if ([local_pb availableTypeFromArray:[NSArray arrayWithObject:(NSString*)type]]) + ret = [[local_pb dataForType:(NSString*)type] copy]; else { NSNumber* bitmapType = [BitmapOutputTypeMap objectForKey:(NSString*)type]; if (bitmapType) { - NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:pb]; + NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:local_pb]; ret = [NSBitmapImageRep representationOfImageRepsInArray:reps usingType:[bitmapType unsignedIntegerValue] properties:nil]; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index bbd3424..95a3720 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -304,8 +304,8 @@ extern CFDataRef macdrv_copy_keyboard_layout(CGEventSourceKeyboardType* keyboard
/* clipboard */ -extern CFArrayRef macdrv_copy_pasteboard_types(void) DECLSPEC_HIDDEN; -extern CFDataRef macdrv_copy_pasteboard_data(CFStringRef type) DECLSPEC_HIDDEN; +extern CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) DECLSPEC_HIDDEN; +extern CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) DECLSPEC_HIDDEN; extern int macdrv_is_pasteboard_owner(void) DECLSPEC_HIDDEN; extern void macdrv_clear_pasteboard(void) DECLSPEC_HIDDEN; extern int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) DECLSPEC_HIDDEN;