From: Jacek Caban jacek@codeweavers.com
It's synthesized in user32 from DIB.
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 101 ----------------------------------- 1 file changed, 101 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 9a498cde2f7..be0ddbecd8c 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -67,7 +67,6 @@ typedef struct _WINE_CLIPFORMAT **************************************************************************/
static HANDLE import_clipboard_data(CFDataRef data); -static HANDLE import_bmp_to_bitmap(CFDataRef data); static HANDLE import_bmp_to_dib(CFDataRef data); static HANDLE import_enhmetafile(CFDataRef data); static HANDLE import_html(CFDataRef data); @@ -78,7 +77,6 @@ static HANDLE import_utf8_to_unicodetext(CFDataRef data); static HANDLE import_utf16_to_unicodetext(CFDataRef data);
static CFDataRef export_clipboard_data(HANDLE data); -static CFDataRef export_bitmap_to_bmp(HANDLE data); static CFDataRef export_dib_to_bmp(HANDLE data); static CFDataRef export_enhmetafile(HANDLE data); static CFDataRef export_hdrop_to_filenames(HANDLE data); @@ -142,7 +140,6 @@ static const struct BOOL synthesized; } builtin_format_ids[] = { - { CF_BITMAP, CFSTR("org.winehq.builtin.bitmap"), import_bmp_to_bitmap, export_bitmap_to_bmp, FALSE }, { CF_DIBV5, CFSTR("org.winehq.builtin.dibv5"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_DIF, CFSTR("org.winehq.builtin.dif"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_enhmetafile, export_enhmetafile, FALSE }, @@ -470,66 +467,6 @@ static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse) }
-/*********************************************************************** - * create_dib_from_bitmap - * - * Allocates a packed DIB and copies the bitmap data into it. - */ -static HGLOBAL create_dib_from_bitmap(HBITMAP bitmap) -{ - HANDLE ret = 0; - BITMAPINFOHEADER header; - HDC hdc = NtUserGetDCEx(0, 0, DCX_USESTYLE); - DWORD header_size; - BITMAPINFO *bmi; - - memset(&header, 0, sizeof(header)); - header.biSize = sizeof(header); - if (!GetDIBits(hdc, bitmap, 0, 0, NULL, (BITMAPINFO *)&header, DIB_RGB_COLORS)) goto done; - - header_size = bitmap_info_size((BITMAPINFO *)&header, DIB_RGB_COLORS); - if (!(ret = GlobalAlloc(GMEM_FIXED, header_size + header.biSizeImage))) goto done; - bmi = (BITMAPINFO *)ret; - memset(bmi, 0, header_size); - memcpy(bmi, &header, header.biSize); - GetDIBits(hdc, bitmap, 0, abs(header.biHeight), (char *)bmi + header_size, bmi, DIB_RGB_COLORS); - -done: - NtUserReleaseDC(0, hdc); - return ret; -} - - -/************************************************************************** - * create_bitmap_from_dib - * - * Given a packed DIB, creates a bitmap object from it. - */ -static HANDLE create_bitmap_from_dib(HANDLE dib) -{ - HANDLE ret = 0; - BITMAPINFO *bmi; - - if (dib && (bmi = GlobalLock(dib))) - { - HDC hdc; - unsigned int offset; - - hdc = NtUserGetDCEx(NULL, 0, DCX_USESTYLE); - - offset = bitmap_info_size(bmi, DIB_RGB_COLORS); - - ret = CreateDIBitmap(hdc, &bmi->bmiHeader, CBM_INIT, (LPBYTE)bmi + offset, - bmi, DIB_RGB_COLORS); - - GlobalUnlock(dib); - NtUserReleaseDC(NULL, hdc); - } - - return ret; -} - - /************************************************************************** * get_html_description_field * @@ -587,23 +524,6 @@ static HANDLE import_clipboard_data(CFDataRef data) }
-/************************************************************************** - * import_bmp_to_bitmap - * - * Import BMP data, converting to CF_BITMAP format. - */ -static HANDLE import_bmp_to_bitmap(CFDataRef data) -{ - HANDLE ret; - HANDLE dib = import_bmp_to_dib(data); - - ret = create_bitmap_from_dib(dib); - - GlobalFree(dib); - return ret; -} - - /************************************************************************** * import_bmp_to_dib * @@ -995,27 +915,6 @@ static CFDataRef export_clipboard_data(HANDLE data) }
-/************************************************************************** - * export_bitmap_to_bmp - * - * Export CF_BITMAP to BMP file format. - */ -static CFDataRef export_bitmap_to_bmp(HANDLE data) -{ - CFDataRef ret = NULL; - HGLOBAL dib; - - dib = create_dib_from_bitmap(data); - if (dib) - { - ret = export_dib_to_bmp(dib); - GlobalFree(dib); - } - - return ret; -} - - /************************************************************************** * export_dib_to_bmp *
From: Jacek Caban jacek@codeweavers.com
It's synthesized in user32 from EMF.
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 57 ------------------------------------ 1 file changed, 57 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index be0ddbecd8c..ec8aa130211 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -70,7 +70,6 @@ static HANDLE import_clipboard_data(CFDataRef data); static HANDLE import_bmp_to_dib(CFDataRef data); static HANDLE import_enhmetafile(CFDataRef data); static HANDLE import_html(CFDataRef data); -static HANDLE import_metafilepict(CFDataRef data); static HANDLE import_nsfilenames_to_hdrop(CFDataRef data); static HANDLE import_utf8_to_text(CFDataRef data); static HANDLE import_utf8_to_unicodetext(CFDataRef data); @@ -81,7 +80,6 @@ static CFDataRef export_dib_to_bmp(HANDLE data); static CFDataRef export_enhmetafile(HANDLE data); static CFDataRef export_hdrop_to_filenames(HANDLE data); static CFDataRef export_html(HANDLE data); -static CFDataRef export_metafilepict(HANDLE data); static CFDataRef export_text_to_utf8(HANDLE data); static CFDataRef export_unicodetext_to_utf8(HANDLE data); static CFDataRef export_unicodetext_to_utf16(HANDLE data); @@ -144,7 +142,6 @@ static const struct { CF_DIF, CFSTR("org.winehq.builtin.dif"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_enhmetafile, export_enhmetafile, FALSE }, { CF_LOCALE, CFSTR("org.winehq.builtin.locale"), import_clipboard_data, export_clipboard_data, FALSE }, - { CF_METAFILEPICT, CFSTR("org.winehq.builtin.metafilepict"), import_metafilepict, export_metafilepict, FALSE }, { CF_OEMTEXT, CFSTR("org.winehq.builtin.oemtext"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_PALETTE, CFSTR("org.winehq.builtin.palette"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_PENDATA, CFSTR("org.winehq.builtin.pendata"), import_clipboard_data, export_clipboard_data, FALSE }, @@ -610,33 +607,6 @@ static HANDLE import_html(CFDataRef data) }
-/************************************************************************** - * import_metafilepict - * - * Import metafile picture data, converting it to CF_METAFILEPICT. - */ -static HANDLE import_metafilepict(CFDataRef data) -{ - HANDLE ret = 0; - CFIndex len = CFDataGetLength(data); - METAFILEPICT *mfp; - - TRACE("data %s\n", debugstr_cf(data)); - - if (len >= sizeof(*mfp) && (ret = GlobalAlloc(GMEM_FIXED, sizeof(*mfp)))) - { - const BYTE *bytes = (const BYTE*)CFDataGetBytePtr(data); - - mfp = GlobalLock(ret); - memcpy(mfp, bytes, sizeof(*mfp)); - mfp->hMF = SetMetaFileBitsEx(len - sizeof(*mfp), bytes + sizeof(*mfp)); - GlobalUnlock(ret); - } - - return ret; -} - - /************************************************************************** * import_nsfilenames_to_hdrop * @@ -1113,33 +1083,6 @@ failed: }
-/************************************************************************** - * export_metafilepict - * - * Export a metafile to data. - */ -static CFDataRef export_metafilepict(HANDLE data) -{ - CFMutableDataRef ret = NULL; - METAFILEPICT *mfp = GlobalLock(data); - unsigned int size = GetMetaFileBitsEx(mfp->hMF, 0, NULL); - - TRACE("data %p\n", data); - - ret = CFDataCreateMutable(NULL, sizeof(*mfp) + size); - if (ret) - { - CFDataAppendBytes(ret, (UInt8*)mfp, sizeof(*mfp)); - CFDataIncreaseLength(ret, size); - GetMetaFileBitsEx(mfp->hMF, size, (BYTE*)CFDataGetMutableBytePtr(ret) + sizeof(*mfp)); - } - - GlobalUnlock(data); - TRACE(" -> %s\n", debugstr_cf(ret)); - return ret; -} - - /************************************************************************** * export_text_to_utf8 *
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 84 +----------------------------------- 1 file changed, 1 insertion(+), 83 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index ec8aa130211..b3d7f79b7a9 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -71,7 +71,6 @@ static HANDLE import_bmp_to_dib(CFDataRef data); static HANDLE import_enhmetafile(CFDataRef data); static HANDLE import_html(CFDataRef data); static HANDLE import_nsfilenames_to_hdrop(CFDataRef data); -static HANDLE import_utf8_to_text(CFDataRef data); static HANDLE import_utf8_to_unicodetext(CFDataRef data); static HANDLE import_utf16_to_unicodetext(CFDataRef data);
@@ -80,7 +79,6 @@ static CFDataRef export_dib_to_bmp(HANDLE data); static CFDataRef export_enhmetafile(HANDLE data); static CFDataRef export_hdrop_to_filenames(HANDLE data); static CFDataRef export_html(HANDLE data); -static CFDataRef export_text_to_utf8(HANDLE data); static CFDataRef export_unicodetext_to_utf8(HANDLE data); static CFDataRef export_unicodetext_to_utf16(HANDLE data);
@@ -182,7 +180,7 @@ static const struct { wszPNG, CFSTR("public.png"), import_clipboard_data, export_clipboard_data }, { wszHTMLFormat, NULL, import_clipboard_data, export_clipboard_data }, { wszHTMLFormat, CFSTR("public.html"), import_html, export_html, TRUE }, - { CFSTR_SHELLURLW, CFSTR("public.url"), import_utf8_to_text, export_text_to_utf8 }, + { CFSTR_INETURLW, CFSTR("public.url"), import_utf8_to_unicodetext, export_unicodetext_to_utf8 }, };
/* The prefix prepended to a Win32 clipboard format name to make a Mac pasteboard type. */ @@ -725,45 +723,6 @@ done: }
-/************************************************************************** - * import_utf8_to_text - * - * Import a UTF-8 string, converting the string to CF_TEXT. - */ -static HANDLE import_utf8_to_text(CFDataRef data) -{ - HANDLE ret = NULL; - HANDLE unicode_handle = import_utf8_to_unicodetext(data); - LPWSTR unicode_string = GlobalLock(unicode_handle); - - if (unicode_string) - { - int unicode_len; - HANDLE handle; - char *p; - INT len; - - unicode_len = GlobalSize(unicode_handle) / sizeof(WCHAR); - - len = WideCharToMultiByte(CP_ACP, 0, unicode_string, unicode_len, NULL, 0, NULL, NULL); - if (!unicode_len || unicode_string[unicode_len - 1]) len += 1; - handle = GlobalAlloc(GMEM_FIXED, len); - - if (handle && (p = GlobalLock(handle))) - { - WideCharToMultiByte(CP_ACP, 0, unicode_string, unicode_len, p, len, NULL, NULL); - p[len - 1] = 0; - GlobalUnlock(handle); - ret = handle; - } - GlobalUnlock(unicode_handle); - } - - GlobalFree(unicode_handle); - return ret; -} - - /************************************************************************** * import_utf8_to_unicodetext * @@ -1083,47 +1042,6 @@ failed: }
-/************************************************************************** - * export_text_to_utf8 - * - * Export CF_TEXT to UTF-8. - */ -static CFDataRef export_text_to_utf8(HANDLE data) -{ - CFDataRef ret = NULL; - const char* str; - - if ((str = GlobalLock(data))) - { - int str_len = GlobalSize(data); - int wstr_len; - WCHAR *wstr; - HANDLE unicode; - char *p; - - wstr_len = MultiByteToWideChar(CP_ACP, 0, str, str_len, NULL, 0); - if (!str_len || str[str_len - 1]) wstr_len += 1; - wstr = HeapAlloc(GetProcessHeap(), 0, wstr_len * sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, str, str_len, wstr, wstr_len); - wstr[wstr_len - 1] = 0; - - unicode = GlobalAlloc(GMEM_FIXED, wstr_len * sizeof(WCHAR)); - if (unicode && (p = GlobalLock(unicode))) - { - memcpy(p, wstr, wstr_len * sizeof(WCHAR)); - GlobalUnlock(unicode); - } - - ret = export_unicodetext_to_utf8(unicode); - - GlobalFree(unicode); - GlobalUnlock(data); - } - - return ret; -} - - /************************************************************************** * export_unicodetext_to_utf8 *
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 153 +++++++++++++---------------------- 1 file changed, 55 insertions(+), 98 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index b3d7f79b7a9..af3870b4cc6 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -40,7 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard); * Types **************************************************************************/
-typedef HANDLE (*DRVIMPORTFUNC)(CFDataRef data); +typedef void *(*DRVIMPORTFUNC)(CFDataRef data, size_t *ret_size); typedef CFDataRef (*DRVEXPORTFUNC)(HANDLE data);
typedef struct _WINE_CLIPFORMAT @@ -66,13 +66,12 @@ typedef struct _WINE_CLIPFORMAT * Forward Function Declarations **************************************************************************/
-static HANDLE import_clipboard_data(CFDataRef data); -static HANDLE import_bmp_to_dib(CFDataRef data); -static HANDLE import_enhmetafile(CFDataRef data); -static HANDLE import_html(CFDataRef data); -static HANDLE import_nsfilenames_to_hdrop(CFDataRef data); -static HANDLE import_utf8_to_unicodetext(CFDataRef data); -static HANDLE import_utf16_to_unicodetext(CFDataRef data); +static void *import_clipboard_data(CFDataRef data, size_t *ret_size); +static void *import_bmp_to_dib(CFDataRef data, size_t *ret_size); +static void *import_html(CFDataRef data, size_t *ret_size); +static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size); +static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size); +static void *import_utf16_to_unicodetext(CFDataRef data, size_t *ret_size);
static CFDataRef export_clipboard_data(HANDLE data); static CFDataRef export_dib_to_bmp(HANDLE data); @@ -138,7 +137,7 @@ static const struct { { CF_DIBV5, CFSTR("org.winehq.builtin.dibv5"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_DIF, CFSTR("org.winehq.builtin.dif"), import_clipboard_data, export_clipboard_data, FALSE }, - { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_enhmetafile, export_enhmetafile, FALSE }, + { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_clipboard_data, export_enhmetafile, FALSE }, { CF_LOCALE, CFSTR("org.winehq.builtin.locale"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_OEMTEXT, CFSTR("org.winehq.builtin.oemtext"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_PALETTE, CFSTR("org.winehq.builtin.palette"), import_clipboard_data, export_clipboard_data, FALSE }, @@ -489,33 +488,18 @@ static const char* get_html_description_field(const char* data, const char* keyw * * Generic import clipboard data routine. */ -static HANDLE import_clipboard_data(CFDataRef data) +static void *import_clipboard_data(CFDataRef data, size_t *ret_size) { - HANDLE data_handle = NULL; + void *ret = NULL;
size_t len = CFDataGetLength(data); - if (len) + if (len && (ret = malloc(len))) { - LPVOID p; - - /* Turn on the DDESHARE flag to enable shared 32 bit memory */ - data_handle = GlobalAlloc(GMEM_FIXED, len); - if (!data_handle) - return NULL; - - if ((p = GlobalLock(data_handle))) - { - memcpy(p, CFDataGetBytePtr(data), len); - GlobalUnlock(data_handle); - } - else - { - GlobalFree(data_handle); - data_handle = NULL; - } + memcpy(ret, CFDataGetBytePtr(data), len); + *ret_size = len; }
- return data_handle; + return ret; }
@@ -525,59 +509,35 @@ static HANDLE import_clipboard_data(CFDataRef data) * Import BMP data, converting to CF_DIB or CF_DIBV5 format. This just * entails stripping the BMP file format header. */ -static HANDLE import_bmp_to_dib(CFDataRef data) +static void *import_bmp_to_dib(CFDataRef data, size_t *ret_size) { - HANDLE ret = 0; BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)CFDataGetBytePtr(data); CFIndex len = CFDataGetLength(data); + void *ret = NULL;
if (len >= sizeof(*bfh) + sizeof(BITMAPCOREHEADER) && bfh->bfType == 0x4d42 /* "BM" */) { BITMAPINFO *bmi = (BITMAPINFO*)(bfh + 1); - BYTE* p;
len -= sizeof(*bfh); - ret = GlobalAlloc(GMEM_FIXED, len); - if (!ret || !(p = GlobalLock(ret))) + if ((ret = malloc(len))) { - GlobalFree(ret); - return 0; + memcpy(ret, bmi, len); + *ret_size = len; } - - memcpy(p, bmi, len); - GlobalUnlock(ret); }
return ret; }
-/************************************************************************** - * import_enhmetafile - * - * Import enhanced metafile data, converting it to CF_ENHMETAFILE. - */ -static HANDLE import_enhmetafile(CFDataRef data) -{ - HANDLE ret = 0; - CFIndex len = CFDataGetLength(data); - - TRACE("data %s\n", debugstr_cf(data)); - - if (len) - ret = SetEnhMetaFileBits(len, (const BYTE*)CFDataGetBytePtr(data)); - - return ret; -} - - /************************************************************************** * import_html * * Import HTML data. */ -static HANDLE import_html(CFDataRef data) +static void *import_html(CFDataRef data, size_t *ret_size) { static const char header[] = "Version:0.9\n" @@ -587,18 +547,19 @@ static HANDLE import_html(CFDataRef data) "EndFragment:%010lu\n" "<!--StartFragment-->"; static const char trailer[] = "\n<!--EndFragment-->"; - HANDLE ret; + void *ret; SIZE_T len, total; size_t size = CFDataGetLength(data);
len = strlen(header) + 12; /* 3 * 4 extra chars for %010lu */ total = len + size + sizeof(trailer); - if ((ret = GlobalAlloc(GMEM_FIXED, total))) + if ((ret = malloc(total))) { char *p = ret; p += sprintf(p, header, total - 1, len, len + size + 1 /* include the final \n in the data */); CFDataGetBytes(data, CFRangeMake(0, size), (UInt8*)p); strcpy(p + size, trailer); + *ret_size = total; TRACE("returning %s\n", debugstr_a(ret)); } return ret; @@ -611,15 +572,14 @@ static HANDLE import_html(CFDataRef data) * Import NSFilenamesPboardType data, converting the property-list- * serialized array of path strings to CF_HDROP. */ -static HANDLE import_nsfilenames_to_hdrop(CFDataRef data) +static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size) { - HDROP hdrop = NULL; CFArrayRef names; CFIndex count, i; size_t len; char *buffer = NULL; WCHAR **paths = NULL; - DROPFILES* dropfiles; + DROPFILES *dropfiles = NULL; UniChar* p;
TRACE("data %s\n", debugstr_cf(data)); @@ -685,12 +645,10 @@ static HANDLE import_nsfilenames_to_hdrop(CFDataRef data) for (i = 0; i < count; i++) len += strlenW(paths[i]) + 1;
- hdrop = GlobalAlloc(GMEM_FIXED, sizeof(*dropfiles) + len * sizeof(WCHAR)); - if (!hdrop || !(dropfiles = GlobalLock(hdrop))) + *ret_size = sizeof(*dropfiles) + len * sizeof(WCHAR); + if (!(dropfiles = malloc(*ret_size))) { WARN("failed to allocate HDROP\n"); - GlobalFree(hdrop); - hdrop = NULL; goto done; }
@@ -708,8 +666,6 @@ static HANDLE import_nsfilenames_to_hdrop(CFDataRef data) } *p = 0;
- GlobalUnlock(hdrop); - done: if (paths) { @@ -719,7 +675,7 @@ done: } HeapFree(GetProcessHeap(), 0, buffer); if (names) CFRelease(names); - return hdrop; + return dropfiles; }
@@ -728,14 +684,14 @@ done: * * Import a UTF-8 string, converting the string to CF_UNICODETEXT. */ -static HANDLE import_utf8_to_unicodetext(CFDataRef data) +static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size) { const BYTE *src; unsigned long src_len; unsigned long new_lines = 0; LPSTR dst; unsigned long i, j; - HANDLE unicode_handle = NULL; + WCHAR *ret = NULL;
src = CFDataGetBytePtr(data); src_len = CFDataGetLength(data); @@ -747,8 +703,6 @@ static HANDLE import_utf8_to_unicodetext(CFDataRef data)
if ((dst = HeapAlloc(GetProcessHeap(), 0, src_len + new_lines + 1))) { - UINT count; - for (i = 0, j = 0; i < src_len; i++) { if (src[i] == '\n') @@ -756,22 +710,15 @@ static HANDLE import_utf8_to_unicodetext(CFDataRef data)
dst[j++] = src[i]; } - dst[j] = 0; - - count = MultiByteToWideChar(CP_UTF8, 0, dst, -1, NULL, 0); - unicode_handle = GlobalAlloc(GMEM_FIXED, count * sizeof(WCHAR)); + dst[j++] = 0;
- if (unicode_handle) - { - WCHAR *textW = GlobalLock(unicode_handle); - MultiByteToWideChar(CP_UTF8, 0, dst, -1, textW, count); - GlobalUnlock(unicode_handle); - } + if ((ret = malloc(j * sizeof(WCHAR)))) + *ret_size = MultiByteToWideChar(CP_UTF8, 0, dst, j, ret, j) * sizeof(WCHAR);
HeapFree(GetProcessHeap(), 0, dst); }
- return unicode_handle; + return ret; }
@@ -780,14 +727,13 @@ static HANDLE import_utf8_to_unicodetext(CFDataRef data) * * Import a UTF-8 string, converting the string to CF_UNICODETEXT. */ -static HANDLE import_utf16_to_unicodetext(CFDataRef data) +static void *import_utf16_to_unicodetext(CFDataRef data, size_t *ret_size) { const WCHAR *src; unsigned long src_len; unsigned long new_lines = 0; LPWSTR dst; unsigned long i, j; - HANDLE unicode_handle;
src = (const WCHAR *)CFDataGetBytePtr(data); src_len = CFDataGetLength(data) / sizeof(WCHAR); @@ -799,10 +745,9 @@ static HANDLE import_utf16_to_unicodetext(CFDataRef data) new_lines++; }
- if ((unicode_handle = GlobalAlloc(GMEM_FIXED, (src_len + new_lines + 1) * sizeof(WCHAR)))) + *ret_size = (src_len + new_lines + 1) * sizeof(WCHAR); + if ((dst = malloc(*ret_size))) { - dst = GlobalLock(unicode_handle); - for (i = 0, j = 0; i < src_len; i++) { if (src[i] == '\n') @@ -814,11 +759,9 @@ static HANDLE import_utf16_to_unicodetext(CFDataRef data) dst[j++] = '\n'; } dst[j] = 0; - - GlobalUnlock(unicode_handle); }
- return unicode_handle; + return dst; }
@@ -1180,7 +1123,18 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format)
if (pasteboard_data) { - data = best_format->import_func(pasteboard_data); + size_t size; + void *import = best_format->import_func(pasteboard_data, &size), *ptr; + if (import) + { + data = GlobalAlloc(GMEM_FIXED, size); + if (data && (ptr = GlobalLock(data))) + { + memcpy(ptr, import, size); + GlobalUnlock(data); + } + free(import); + } CFRelease(pasteboard_data); } } @@ -1494,9 +1448,12 @@ static void render_format(UINT id) pasteboard_data = macdrv_copy_pasteboard_data(NULL, current_mac_formats[i]->type); if (pasteboard_data) { - HANDLE handle = current_mac_formats[i]->import_func(pasteboard_data); + struct set_clipboard_params params = { 0 }; + params.data = current_mac_formats[i]->import_func(pasteboard_data, ¶ms.size); CFRelease(pasteboard_data); - if (handle) SetClipboardData(id, handle); + if (!params.data) continue; + NtUserSetClipboardData(id, 0, ¶ms); + free(params.data); break; } }
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 80c3e8520d3..f2be4386e65 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1337,11 +1337,10 @@ static BOOL render_format( UINT id )
for (i = 0; i < nb_current_x11_formats; i++) { - struct set_clipboard_params params; + struct set_clipboard_params params = { 0 }; if (current_x11_formats[i]->id != id) continue; if (!(params.data = import_selection( display, import_window, current_selection, current_x11_formats[i], ¶ms.size ))) continue; - params.seqno = 0; NtUserSetClipboardData( id, 0, ¶ms ); if (params.size) free( params.data ); return TRUE;
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/macdrv.h | 4 +--- dlls/winemac.drv/macdrv_main.c | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 68ab74dc56e..04a8af81c53 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -114,13 +114,11 @@ struct macdrv_thread_data WORD keyc2scan[128]; };
-extern DWORD thread_data_tls_index DECLSPEC_HIDDEN; - extern struct macdrv_thread_data *macdrv_init_thread_data(void) DECLSPEC_HIDDEN;
static inline struct macdrv_thread_data *macdrv_thread_data(void) { - return TlsGetValue(thread_data_tls_index); + return NtUserGetThreadInfo()->driver_data; }
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 2f05e55cb23..8c101576e99 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -46,8 +46,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
C_ASSERT(NUM_EVENT_TYPES <= sizeof(macdrv_event_mask) * 8);
-DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES; - int topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; int capture_displays_for_fullscreen = 0; BOOL skip_single_buffer_flushes = FALSE; @@ -463,8 +461,6 @@ static BOOL process_attach(void) setup_options(); load_strings(macdrv_module);
- if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE; - macdrv_err_on = ERR_ON(macdrv); if (macdrv_start_cocoa_app(GetTickCount64())) { @@ -493,7 +489,7 @@ void macdrv_ThreadDetach(void) CFRelease(data->keyboard_layout_uchr); HeapFree(GetProcessHeap(), 0, data); /* clear data in case we get re-entered from user32 before the thread is truly dead */ - TlsSetValue(thread_data_tls_index, NULL); + NtUserGetThreadInfo()->driver_data = 0; } }
@@ -556,7 +552,7 @@ struct macdrv_thread_data *macdrv_init_thread_data(void) macdrv_compute_keyboard_layout(data);
set_queue_display_fd(macdrv_get_event_queue_fd(data->queue)); - TlsSetValue(thread_data_tls_index, data); + NtUserGetThreadInfo()->driver_data = data;
NtUserActivateKeyboardLayout(data->active_keyboard_layout, 0); return data;
This merge request was approved by Huw Davies.