winemac: Ignore Mac-originating pasteboard types which aren't mapped to standard clipboard formats.

New clipboard formats had been registered for them, but that was pointless.
No Windows app would ever expect or make use of such clipboard formats or the
associated pasteboard data.
This commit is contained in:
Ken Thomases 2013-11-22 04:31:25 -06:00 committed by Alexandre Julliard
parent 788e2034f6
commit a983cfb01d
1 changed files with 18 additions and 39 deletions

View File

@ -122,16 +122,13 @@ static struct list format_list = LIST_INIT(format_list);
prepending "org.winehq.registered." to the registered name. prepending "org.winehq.registered." to the registered name.
Likewise, Mac pasteboard types which originate in other apps may have Likewise, Mac pasteboard types which originate in other apps may have
arbitrary type strings. We construct a Win32 clipboard format name from arbitrary type strings. We ignore these.
these by prepending "org.winehq.mac-type." to the Mac pasteboard type.
Summary: Summary:
Win32 clipboard format names: Win32 clipboard format names:
<none> standard clipboard format; maps via <none> standard clipboard format; maps via
format_list to either a predefined Mac UTI format_list to either a predefined Mac UTI
or org.winehq.builtin.<format>. or org.winehq.builtin.<format>.
org.winehq.mac-type.<Mac type> representation of Mac type in Win32 land;
maps to <Mac type>
<other> name registered within Win32 land; maps to <other> name registered within Win32 land; maps to
org.winehq.registered.<other> org.winehq.registered.<other>
Mac pasteboard type names: Mac pasteboard type names:
@ -142,8 +139,7 @@ static struct list format_list = LIST_INIT(format_list);
clipboard format name; maps to <format name> clipboard format name; maps to <format name>
<other> Mac pasteboard type originating with system <other> Mac pasteboard type originating with system
or other apps; either maps via format_list or other apps; either maps via format_list
to a standard clipboard format or maps to to a standard clipboard format or ignored
org.winehq.mac-type.<other>
*/ */
static const struct static const struct
@ -221,9 +217,6 @@ static const struct
{ CFSTR_SHELLURLW, CFSTR("public.url"), import_utf8_to_text, export_text_to_utf8 }, { CFSTR_SHELLURLW, CFSTR("public.url"), import_utf8_to_text, export_text_to_utf8 },
}; };
/* The prefix prepended to an external Mac pasteboard type to make a Win32 clipboard format name. org.winehq.mac-type. */
static const WCHAR mac_type_name_prefix[] = {'o','r','g','.','w','i','n','e','h','q','.','m','a','c','-','t','y','p','e','.',0};
/* The prefix prepended to a Win32 clipboard format name to make a Mac pasteboard type. */ /* The prefix prepended to a Win32 clipboard format name to make a Mac pasteboard type. */
static const CFStringRef registered_name_type_prefix = CFSTR("org.winehq.registered."); static const CFStringRef registered_name_type_prefix = CFSTR("org.winehq.registered.");
@ -309,17 +302,9 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type)
return NULL; return NULL;
} }
if (!strncmpW(buffer, mac_type_name_prefix, strlenW(mac_type_name_prefix)))
{
const WCHAR *p = buffer + strlenW(mac_type_name_prefix);
format->type = CFStringCreateWithCharacters(NULL, (UniChar*)p, strlenW(p));
}
else
{
format->type = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%S"), format->type = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%S"),
registered_name_type_prefix, buffer); registered_name_type_prefix, buffer);
} }
}
list_add_tail(&format_list, &format->entry); list_add_tail(&format_list, &format->entry);
@ -367,31 +352,20 @@ static WINE_CLIPFORMAT* format_for_type(WINE_CLIPFORMAT *current, CFStringRef ty
format = NULL; format = NULL;
if (!current) if (!current)
{ {
LPWSTR name;
if (CFStringHasPrefix(type, CFSTR("org.winehq.builtin."))) if (CFStringHasPrefix(type, CFSTR("org.winehq.builtin.")))
{ {
ERR("Shouldn't happen. Built-in type %s should have matched something in format list.\n", ERR("Shouldn't happen. Built-in type %s should have matched something in format list.\n",
debugstr_cf(type)); debugstr_cf(type));
goto done;
} }
else if (CFStringHasPrefix(type, registered_name_type_prefix)) else if (CFStringHasPrefix(type, registered_name_type_prefix))
{ {
LPWSTR name;
int len = CFStringGetLength(type) - CFStringGetLength(registered_name_type_prefix); int len = CFStringGetLength(type) - CFStringGetLength(registered_name_type_prefix);
name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
CFStringGetCharacters(type, CFRangeMake(CFStringGetLength(registered_name_type_prefix), len), CFStringGetCharacters(type, CFRangeMake(CFStringGetLength(registered_name_type_prefix), len),
(UniChar*)name); (UniChar*)name);
name[len] = 0; name[len] = 0;
}
else
{
int len = strlenW(mac_type_name_prefix) + CFStringGetLength(type);
name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
memcpy(name, mac_type_name_prefix, sizeof(mac_type_name_prefix));
CFStringGetCharacters(type, CFRangeMake(0, CFStringGetLength(type)),
(UniChar*)name + strlenW(mac_type_name_prefix));
name[len] = 0;
}
format = register_format(RegisterClipboardFormatW(name), type); format = register_format(RegisterClipboardFormatW(name), type);
if (!format) if (!format)
@ -399,6 +373,7 @@ static WINE_CLIPFORMAT* format_for_type(WINE_CLIPFORMAT *current, CFStringRef ty
HeapFree(GetProcessHeap(), 0, name); HeapFree(GetProcessHeap(), 0, name);
} }
}
done: done:
TRACE(" -> %p/%s\n", format, debugstr_format(format ? format->format_id : 0)); TRACE(" -> %p/%s\n", format, debugstr_format(format ? format->format_id : 0));
@ -1777,12 +1752,16 @@ UINT CDECL macdrv_EnumClipboardFormats(UINT prev_format)
count = CFArrayGetCount(types); count = CFArrayGetCount(types);
TRACE("got %ld types\n", count); TRACE("got %ld types\n", count);
if (count) for (i = 0; i < count; i++)
{ {
CFStringRef type = CFArrayGetValueAtIndex(types, 0); CFStringRef type = CFArrayGetValueAtIndex(types, i);
WINE_CLIPFORMAT *format = format_for_type(NULL, type); WINE_CLIPFORMAT *format = format_for_type(NULL, type);
ret = format ? format->format_id : 0; if (format)
{
ret = format->format_id;
break;
}
} }
CFRelease(types); CFRelease(types);