Commit bf824ed3 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Implement setting of clipboard data with support for text formats.

parent 764a8edb
......@@ -22,6 +22,25 @@
#import "cocoa_app.h"
static int owned_change_count = -1;
/***********************************************************************
* macdrv_is_pasteboard_owner
*/
int macdrv_is_pasteboard_owner(void)
{
__block int ret;
OnMainThread(^{
NSPasteboard* pb = [NSPasteboard generalPasteboard];
ret = ([pb changeCount] == owned_change_count);
});
return ret;
}
/***********************************************************************
* macdrv_copy_pasteboard_types
*
......@@ -78,3 +97,61 @@ CFDataRef macdrv_copy_pasteboard_data(CFStringRef type)
return (CFDataRef)ret;
}
/***********************************************************************
* macdrv_clear_pasteboard
*
* Takes ownership of the Mac pasteboard and clears it of all data types.
*/
void macdrv_clear_pasteboard(void)
{
OnMainThreadAsync(^{
@try
{
NSPasteboard* pb = [NSPasteboard generalPasteboard];
owned_change_count = [pb declareTypes:[NSArray array] owner:nil];
}
@catch (id e)
{
ERR(@"Exception discarded while clearing pasteboard: %@\n", e);
}
});
}
/***********************************************************************
* macdrv_set_pasteboard_data
*
* Sets the pasteboard data for a specified type. Replaces any data of
* that type already on the pasteboard.
*
* Returns 0 on error, non-zero on success.
*/
int macdrv_set_pasteboard_data(CFStringRef type, CFDataRef data)
{
__block int ret = 0;
OnMainThread(^{
@try
{
NSPasteboard* pb = [NSPasteboard generalPasteboard];
NSInteger change_count = [pb addTypes:[NSArray arrayWithObject:(NSString*)type]
owner:nil];
if (change_count)
{
owned_change_count = change_count;
if (data)
ret = [pb setData:(NSData*)data forType:(NSString*)type];
else
ret = 1;
}
}
@catch (id e)
{
ERR(@"Exception discarded while copying pasteboard types: %@\n", e);
}
});
return ret;
}
......@@ -276,6 +276,9 @@ 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 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) DECLSPEC_HIDDEN;
/* opengl */
......
......@@ -4,6 +4,7 @@
# USER driver
@ cdecl AcquireClipboard(long) macdrv_AcquireClipboard
@ cdecl ActivateKeyboardLayout(long long) macdrv_ActivateKeyboardLayout
@ cdecl Beep() macdrv_Beep
@ cdecl ChangeDisplaySettingsEx(ptr ptr long long long) macdrv_ChangeDisplaySettingsEx
......@@ -13,6 +14,8 @@
@ cdecl CreateWindow(long) macdrv_CreateWindow
@ cdecl DestroyCursorIcon(long) macdrv_DestroyCursorIcon
@ cdecl DestroyWindow(long) macdrv_DestroyWindow
@ cdecl EmptyClipboard(long) macdrv_EmptyClipboard
@ cdecl EndClipboardUpdate() macdrv_EndClipboardUpdate
@ cdecl EnumClipboardFormats(long) macdrv_EnumClipboardFormats
@ cdecl EnumDisplayMonitors(long ptr ptr long) macdrv_EnumDisplayMonitors
@ cdecl EnumDisplaySettingsEx(ptr long ptr long) macdrv_EnumDisplaySettingsEx
......@@ -26,6 +29,7 @@
@ cdecl MapVirtualKeyEx(long long long) macdrv_MapVirtualKeyEx
@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) macdrv_MsgWaitForMultipleObjectsEx
@ cdecl ScrollDC(long long long ptr ptr long ptr) macdrv_ScrollDC
@ cdecl SetClipboardData(long long long) macdrv_SetClipboardData
@ cdecl SetCursor(long) macdrv_SetCursor
@ cdecl SetCursorPos(long long) macdrv_SetCursorPos
@ cdecl SetFocus(long) macdrv_SetFocus
......
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