Commit 61c1d515 authored by mercury233's avatar mercury233

fix linux copy

parent 1e05248e
...@@ -1107,11 +1107,14 @@ bool CIrrDeviceLinux::run() ...@@ -1107,11 +1107,14 @@ bool CIrrDeviceLinux::run()
{ {
XEvent respond; XEvent respond;
XSelectionRequestEvent *req = &(event.xselectionrequest); XSelectionRequestEvent *req = &(event.xselectionrequest);
if ( req->target == XA_STRING) if ( req->target == XA_STRING
|| req->target == X_ATOM_TEXT
|| req->target == X_ATOM_UTF8_STRING )
{ {
XChangeProperty (display, XChangeProperty (display,
req->requestor, req->requestor,
req->property, req->target, req->property,
req->target == X_ATOM_TEXT ? XA_STRING : req->target,
8, // format 8, // format
PropModeReplace, PropModeReplace,
(unsigned char*) Clipboard.c_str(), (unsigned char*) Clipboard.c_str(),
...@@ -1125,11 +1128,14 @@ bool CIrrDeviceLinux::run() ...@@ -1125,11 +1128,14 @@ bool CIrrDeviceLinux::run()
data[0] = X_ATOM_TEXT; data[0] = X_ATOM_TEXT;
data[1] = XA_STRING; data[1] = XA_STRING;
XChangeProperty (display, req->requestor, XChangeProperty (display,
req->property, req->target, req->requestor,
8, PropModeReplace, req->property,
(unsigned char *) &data, XA_ATOM,
sizeof (data)); 32, // format
PropModeReplace,
(unsigned char *) &X_ATOM_UTF8_STRING,
1);
respond.xselection.property = req->property; respond.xselection.property = req->property;
} }
else else
......
...@@ -89,9 +89,15 @@ void COSOperator::copyToClipboard(const c16* text) const ...@@ -89,9 +89,15 @@ void COSOperator::copyToClipboard(const c16* text) const
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux ) if ( IrrDeviceLinux )
{ {
char ctext[len*2 + 1]; size_t wlen = sizeof(wchar_t) * (len + 1);
size_t lenNew = wcstombs(ctext, text, len*2); char ctext[wlen];
char* oldLocale = setlocale(LC_CTYPE, NULL);
setlocale(LC_CTYPE, "");
size_t lenNew = wcstombs(ctext, text, wlen);
ctext[lenNew] = 0; ctext[lenNew] = 0;
setlocale(LC_CTYPE, oldLocale);
IrrDeviceLinux->copyToClipboard(ctext); IrrDeviceLinux->copyToClipboard(ctext);
} }
#else #else
......
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