[Wine-patches] [eterhack] winex11.drv: Fix paste strings from Unix programs into Wine non unicode program (eterbugs #60, #7047)
Konstantin Kondratyuk
kondratyuk на etersoft.ru
Вт Сен 13 09:56:07 MSD 2011
--
Best regards,
Konstantin Kondratyuk.
----------- следующая часть -----------
Вложение в формате HTML было удалено...
URL: <http://lists.etersoft.ru/pipermail/wine-patches/attachments/20110913/4c5b3f8f/attachment.html>
----------- следующая часть -----------
From b7e5bb8e186ecaac9b120ef3bc21c879e9d28777 Mon Sep 17 00:00:00 2001
From: Anatoly Lyutin <vostok на etersoft.ru>
Date: Tue, 13 Sep 2011 09:52:24 +0400
Subject: [PATCH] winex11.drv: Fix paste strings from Unix programs into Wine
non unicode program (eterbugs #60, #7047)
---
dlls/winex11.drv/clipboard.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index e779495..a7dfde0 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -143,6 +143,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *d, Window w, Atom prop);
static HANDLE X11DRV_CLIPBOARD_ImportImageBmp(Display *d, Window w, Atom prop);
static HANDLE X11DRV_CLIPBOARD_ImportXAString(Display *d, Window w, Atom prop);
static HANDLE X11DRV_CLIPBOARD_ImportUTF8(Display *d, Window w, Atom prop);
+static HANDLE X11DRV_CLIPBOARD_ImportUcsString(Display *d, Window w, Atom prop);
static HANDLE X11DRV_CLIPBOARD_ImportCompoundText(Display *d, Window w, Atom prop);
static HANDLE X11DRV_CLIPBOARD_ExportClipboardData(Display *display, Window requestor, Atom aTarget,
Atom rprop, LPWINE_CLIPDATA lpData, LPDWORD lpBytes);
@@ -210,6 +211,7 @@ static const struct
{ CF_DSPMETAFILEPICT, XATOM_WCF_DSPMETAFILEPICT, X11DRV_CLIPBOARD_ImportClipboardData, X11DRV_CLIPBOARD_ExportClipboardData },
{ CF_DSPENHMETAFILE, XATOM_WCF_DSPENHMETAFILE, X11DRV_CLIPBOARD_ImportClipboardData, X11DRV_CLIPBOARD_ExportClipboardData },
{ CF_DIB, XATOM_image_bmp, X11DRV_CLIPBOARD_ImportImageBmp, X11DRV_CLIPBOARD_ExportImageBmp },
+ { CF_TEXT, XATOM_UTF8_STRING, X11DRV_CLIPBOARD_ImportUcsString, X11DRV_CLIPBOARD_ExportString},
};
static struct list format_list = LIST_INIT( format_list );
@@ -1062,7 +1064,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAString(Display *display, Window w, Atom p
if (!X11DRV_CLIPBOARD_ReadProperty(display, w, prop, &lpdata, &cbytes))
return 0;
- for (i = 0; i <= cbytes; i++)
+ for (i = 0; i < cbytes; i++)
{
if (lpdata[i] == '\n')
inlcount++;
@@ -1072,7 +1074,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAString(Display *display, Window w, Atom p
{
lpstr = GlobalLock(hText);
- for (i = 0, inlcount = 0; i <= cbytes; i++)
+ for (i = 0, inlcount = 0; i < cbytes; i++)
{
if (lpdata[i] == '\n')
lpstr[inlcount++] = '\r';
@@ -1080,6 +1082,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAString(Display *display, Window w, Atom p
lpstr[inlcount++] = lpdata[i];
}
+ lpstr[inlcount] = '\0';
GlobalUnlock(hText);
}
@@ -1106,7 +1109,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportUTF8(Display *display, Window w, Atom prop)
if (!X11DRV_CLIPBOARD_ReadProperty(display, w, prop, &lpdata, &cbytes))
return 0;
- for (i = 0; i <= cbytes; i++)
+ for (i = 0; i < cbytes; i++)
{
if (lpdata[i] == '\n')
inlcount++;
@@ -1116,13 +1119,14 @@ static HANDLE X11DRV_CLIPBOARD_ImportUTF8(Display *display, Window w, Atom prop)
{
UINT count;
- for (i = 0, inlcount = 0; i <= cbytes; i++)
+ for (i = 0, inlcount = 0; i < cbytes; i++)
{
if (lpdata[i] == '\n')
lpstr[inlcount++] = '\r';
lpstr[inlcount++] = lpdata[i];
}
+ lpstr[inlcount] = '\0';
count = MultiByteToWideChar(CP_UTF8, 0, lpstr, -1, NULL, 0);
hUnicodeText = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, count * sizeof(WCHAR));
@@ -1214,6 +1218,36 @@ static HANDLE X11DRV_CLIPBOARD_ImportCompoundText(Display *display, Window w, At
return hUnicodeText;
}
+/**************************************************************************
+ * X11DRV_CLIPBOARD_ImportUcsString
+ *
+ * Import UCS string, converting the string to CF_TEXT.
+ */
+HANDLE X11DRV_CLIPBOARD_ImportUcsString(Display *d, Window w, Atom prop)
+{
+ LPSTR lpstr = NULL;
+ int len;
+ HANDLE hText;
+ LPWSTR lpstrW;
+
+ hText = X11DRV_CLIPBOARD_ImportUTF8(d, w, prop);
+ lpstrW = GlobalLock(hText);
+
+ if (lpstrW)
+ {
+ len = WideCharToMultiByte(CP_ACP, 0, lpstrW, -1, NULL, 0, NULL, NULL);
+ lpstr = HeapAlloc(GetProcessHeap(), 0, sizeof(char) * (len) );
+ WideCharToMultiByte(CP_ACP, 0, lpstrW, -1, lpstr, len, NULL, NULL);
+ if(strlenW(lpstrW) >= strlen(lpstr))
+ strcpy((LPSTR)lpstrW, lpstr);
+ else
+ ERR("WCHAR buffer overfloat(%p)!\n", lpstrW);
+ HeapFree(GetProcessHeap(), 0, lpstr);
+ GlobalUnlock(hText);
+ }
+
+ return hText;
+}
/**************************************************************************
* X11DRV_CLIPBOARD_ImportXAPIXMAP
--
1.7.6.1
Подробная информация о списке рассылки Wine-patches