Commit 4ae5b106 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Enable pasteboard functions to operate on arbitrary pasteboards.

... not just the general pasteboard (although the general pasteboard is still the default).
parent 761ad810
...@@ -1326,7 +1326,7 @@ INT CDECL macdrv_CountClipboardFormats(void) ...@@ -1326,7 +1326,7 @@ INT CDECL macdrv_CountClipboardFormats(void)
return 0; return 0;
} }
types = macdrv_copy_pasteboard_types(); types = macdrv_copy_pasteboard_types(NULL);
if (!types) if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); WARN("Failed to copy pasteboard types\n");
...@@ -1396,7 +1396,7 @@ UINT CDECL macdrv_EnumClipboardFormats(UINT prev_format) ...@@ -1396,7 +1396,7 @@ UINT CDECL macdrv_EnumClipboardFormats(UINT prev_format)
TRACE("prev_format %s\n", debugstr_format(prev_format)); TRACE("prev_format %s\n", debugstr_format(prev_format));
check_clipboard_ownership(NULL); check_clipboard_ownership(NULL);
types = macdrv_copy_pasteboard_types(); types = macdrv_copy_pasteboard_types(NULL);
if (!types) if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); WARN("Failed to copy pasteboard types\n");
...@@ -1490,7 +1490,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format) ...@@ -1490,7 +1490,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format)
TRACE("desired_format %s\n", debugstr_format(desired_format)); TRACE("desired_format %s\n", debugstr_format(desired_format));
check_clipboard_ownership(NULL); check_clipboard_ownership(NULL);
types = macdrv_copy_pasteboard_types(); types = macdrv_copy_pasteboard_types(NULL);
if (!types) if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); WARN("Failed to copy pasteboard types\n");
...@@ -1526,7 +1526,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format) ...@@ -1526,7 +1526,7 @@ HANDLE CDECL macdrv_GetClipboardData(UINT desired_format)
if (best_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)); 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) ...@@ -1556,7 +1556,7 @@ BOOL CDECL macdrv_IsClipboardFormatAvailable(UINT desired_format)
TRACE("desired_format %s\n", debugstr_format(desired_format)); TRACE("desired_format %s\n", debugstr_format(desired_format));
check_clipboard_ownership(NULL); check_clipboard_ownership(NULL);
types = macdrv_copy_pasteboard_types(); types = macdrv_copy_pasteboard_types(NULL);
if (!types) if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); WARN("Failed to copy pasteboard types\n");
...@@ -1758,7 +1758,7 @@ BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) ...@@ -1758,7 +1758,7 @@ BOOL query_pasteboard_data(HWND hwnd, CFStringRef type)
if (!types) if (!types)
{ {
types = macdrv_copy_pasteboard_types(); types = macdrv_copy_pasteboard_types(NULL);
if (!types) if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); WARN("Failed to copy pasteboard types\n");
......
...@@ -53,8 +53,9 @@ int macdrv_is_pasteboard_owner(void) ...@@ -53,8 +53,9 @@ int macdrv_is_pasteboard_owner(void)
* the pasteboard, or NULL on error. The caller is responsible for * the pasteboard, or NULL on error. The caller is responsible for
* releasing the returned array with CFRelease(). * 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; __block CFArrayRef ret = NULL;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
...@@ -79,8 +80,11 @@ CFArrayRef macdrv_copy_pasteboard_types(void) ...@@ -79,8 +80,11 @@ CFArrayRef macdrv_copy_pasteboard_types(void)
OnMainThread(^{ OnMainThread(^{
@try @try
{ {
NSPasteboard* pb = [NSPasteboard generalPasteboard]; NSPasteboard* local_pb = pb;
NSArray* types = [pb types]; NSArray* types;
if (!local_pb) local_pb = [NSPasteboard generalPasteboard];
types = [local_pb types];
// If there are any types understood by NSBitmapImageRep, then we // If there are any types understood by NSBitmapImageRep, then we
// can offer all of the types that it can output, too. For example, // can offer all of the types that it can output, too. For example,
...@@ -115,22 +119,24 @@ CFArrayRef macdrv_copy_pasteboard_types(void) ...@@ -115,22 +119,24 @@ CFArrayRef macdrv_copy_pasteboard_types(void)
* if there's no such type on the pasteboard. The caller is responsible * if there's no such type on the pasteboard. The caller is responsible
* for releasing the returned data object with CFRelease(). * 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; __block NSData* ret = nil;
OnMainThread(^{ OnMainThread(^{
@try @try
{ {
NSPasteboard* pb = [NSPasteboard generalPasteboard]; NSPasteboard* local_pb = pb;
if ([pb availableTypeFromArray:[NSArray arrayWithObject:(NSString*)type]]) if (!local_pb) local_pb = [NSPasteboard generalPasteboard];
ret = [[pb dataForType:(NSString*)type] copy]; if ([local_pb availableTypeFromArray:[NSArray arrayWithObject:(NSString*)type]])
ret = [[local_pb dataForType:(NSString*)type] copy];
else else
{ {
NSNumber* bitmapType = [BitmapOutputTypeMap objectForKey:(NSString*)type]; NSNumber* bitmapType = [BitmapOutputTypeMap objectForKey:(NSString*)type];
if (bitmapType) if (bitmapType)
{ {
NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:pb]; NSArray* reps = [NSBitmapImageRep imageRepsWithPasteboard:local_pb];
ret = [NSBitmapImageRep representationOfImageRepsInArray:reps ret = [NSBitmapImageRep representationOfImageRepsInArray:reps
usingType:[bitmapType unsignedIntegerValue] usingType:[bitmapType unsignedIntegerValue]
properties:nil]; properties:nil];
......
...@@ -304,8 +304,8 @@ extern CFDataRef macdrv_copy_keyboard_layout(CGEventSourceKeyboardType* keyboard ...@@ -304,8 +304,8 @@ extern CFDataRef macdrv_copy_keyboard_layout(CGEventSourceKeyboardType* keyboard
/* clipboard */ /* clipboard */
extern CFArrayRef macdrv_copy_pasteboard_types(void) DECLSPEC_HIDDEN; extern CFArrayRef macdrv_copy_pasteboard_types(CFTypeRef pasteboard) DECLSPEC_HIDDEN;
extern CFDataRef macdrv_copy_pasteboard_data(CFStringRef type) DECLSPEC_HIDDEN; extern CFDataRef macdrv_copy_pasteboard_data(CFTypeRef pasteboard, CFStringRef type) DECLSPEC_HIDDEN;
extern int macdrv_is_pasteboard_owner(void) DECLSPEC_HIDDEN; extern int macdrv_is_pasteboard_owner(void) DECLSPEC_HIDDEN;
extern void macdrv_clear_pasteboard(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; extern int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data, macdrv_window w) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment