Skip to content

Commit 0bd4417

Browse files
committed
2009-01-29 Carlos Alberto Cortez <[email protected]>
* XplatUIX11.cs: We should use utf8 handling clipboard transference with other x11 applications, and use utf16 when handling clipboard data in the class library. Update the related points as well. Fixes #468683. svn path=/trunk/mcs/; revision=124918
1 parent 3906946 commit 0bd4417

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2009-01-29 Carlos Alberto Cortez <[email protected]>
2+
3+
* XplatUIX11.cs: We should use utf8 handling clipboard transference
4+
with other x11 applications, and use utf16 when handling clipboard
5+
data in the class library. Update the related points as well.
6+
Fixes #468683.
7+
18
2009-01-28 Ivan N. Zlatev <[email protected]>
29

310
* DataGridViewCell.cs: Format strings according to the supplied

mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

+17-8
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ internal class XplatUIX11 : XplatUIDriver {
205205
private static IntPtr PRIMARY;
206206
//private static IntPtr DIB;
207207
private static IntPtr OEMTEXT;
208-
private static IntPtr UNICODETEXT;
208+
private static IntPtr UTF8_STRING;
209+
private static IntPtr UTF16_STRING;
209210
private static IntPtr RICHTEXTFORMAT;
210211
private static IntPtr TARGETS;
211212

@@ -619,6 +620,7 @@ private static void SetupAtoms() {
619620
"PRIMARY",
620621
"COMPOUND_TEXT",
621622
"UTF8_STRING",
623+
"UTF16_STRING",
622624
"RICHTEXTFORMAT",
623625
"TARGETS",
624626
"_SWF_AsyncAtom",
@@ -693,7 +695,8 @@ private static void SetupAtoms() {
693695
CLIPBOARD = atoms [off++];
694696
PRIMARY = atoms [off++];
695697
OEMTEXT = atoms [off++];
696-
UNICODETEXT = atoms [off++];
698+
UTF8_STRING = atoms [off++];
699+
UTF16_STRING = atoms [off++];
697700
RICHTEXTFORMAT = atoms [off++];
698701
TARGETS = atoms [off++];
699702
AsyncAtom = atoms [off++];
@@ -1248,7 +1251,12 @@ private void TranslatePropertyToClipboard(IntPtr property) {
12481251
// FIXME - convert pixmap to image
12491252
} else if (property == OEMTEXT) {
12501253
Clipboard.Item = Marshal.PtrToStringAnsi(prop);
1251-
} else if (property == UNICODETEXT) {
1254+
} else if (property == UTF8_STRING) {
1255+
byte [] buffer = new byte [(int)nitems];
1256+
for (int i = 0; i < (int)nitems; i++)
1257+
buffer [i] = Marshal.ReadByte (prop, i);
1258+
Clipboard.Item = Encoding.UTF8.GetString (buffer);
1259+
} else if (property == UTF16_STRING) {
12521260
Clipboard.Item = Marshal.PtrToStringUni (prop, Encoding.Unicode.GetMaxCharCount ((int)nitems));
12531261
} else if (property == RICHTEXTFORMAT)
12541262
Clipboard.Item = Marshal.PtrToStringAnsi(prop);
@@ -1703,7 +1711,8 @@ private void UpdateMessageQueue (XEventQueue queue) {
17031711
if (Clipboard.Item is String) {
17041712
atoms[atom_count++] = (int)Atom.XA_STRING;
17051713
atoms[atom_count++] = (int)OEMTEXT;
1706-
atoms[atom_count++] = (int)UNICODETEXT;
1714+
atoms[atom_count++] = (int)UTF8_STRING;
1715+
atoms[atom_count++] = (int)UTF16_STRING;
17071716
atoms[atom_count++] = (int)RICHTEXTFORMAT;
17081717
} else if (Clipboard.Item is Image) {
17091718
atoms[atom_count++] = (int)Atom.XA_PIXMAP;
@@ -1737,7 +1746,7 @@ private void UpdateMessageQueue (XEventQueue queue) {
17371746
while (Marshal.ReadByte(buffer, buflen) != 0) {
17381747
buflen++;
17391748
}
1740-
} else if (xevent.SelectionRequestEvent.target == UNICODETEXT) {
1749+
} else if (xevent.SelectionRequestEvent.target == UTF16_STRING) {
17411750
Byte [] bytes;
17421751

17431752
bytes = Encoding.Unicode.GetBytes ((string)Clipboard.Source);
@@ -2612,7 +2621,7 @@ internal override int ClipboardGetID(IntPtr handle, string format) {
26122621
//else if (format == "PenData" ) return 10;
26132622
//else if (format == "RiffAudio" ) return 11;
26142623
//else if (format == "WaveAudio" ) return 12;
2615-
else if (format == "UnicodeText" ) return UNICODETEXT.ToInt32();
2624+
else if (format == "UnicodeText" ) return UTF16_STRING.ToInt32();
26162625
//else if (format == "EnhancedMetafile" ) return 14;
26172626
//else if (format == "FileDrop" ) return 15;
26182627
//else if (format == "Locale" ) return 16;
@@ -4565,7 +4574,7 @@ internal override bool GetText(IntPtr handle, out string text) {
45654574

45664575
XGetWindowProperty(DisplayHandle, handle,
45674576
_NET_WM_NAME, IntPtr.Zero, new IntPtr (1), false,
4568-
UNICODETEXT, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
4577+
UTF8_STRING, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
45694578

45704579
if ((long)nitems > 0 && prop != IntPtr.Zero) {
45714580
text = Marshal.PtrToStringUni (prop, (int)nitems);
@@ -6018,7 +6027,7 @@ internal override bool Text(IntPtr handle, string text) {
60186027
hwnd = Hwnd.ObjectFromHandle(handle);
60196028

60206029
lock (XlibLock) {
6021-
XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_NAME, UNICODETEXT, 8,
6030+
XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_NAME, UTF8_STRING, 8,
60226031
PropertyMode.Replace, text, Encoding.UTF8.GetByteCount (text));
60236032

60246033
// XXX this has problems with UTF8.

0 commit comments

Comments
 (0)