Commit 65663132 authored by mercury233's avatar mercury233

fix build on linux, but the clipboard don't work

parent 1663df62
...@@ -56,7 +56,8 @@ const core::stringc& COSOperator::getOperatingSystemVersion() const ...@@ -56,7 +56,8 @@ const core::stringc& COSOperator::getOperatingSystemVersion() const
//! copies text to the clipboard //! copies text to the clipboard
void COSOperator::copyToClipboard(const c16* text) const void COSOperator::copyToClipboard(const c16* text) const
{ {
if (wcslen(text)==0) size_t len = wcslen(text);
if (len==0)
return; return;
// Windows version // Windows version
...@@ -70,7 +71,7 @@ void COSOperator::copyToClipboard(const c16* text) const ...@@ -70,7 +71,7 @@ void COSOperator::copyToClipboard(const c16* text) const
HGLOBAL clipbuffer; HGLOBAL clipbuffer;
wchar_t * buffer; wchar_t * buffer;
clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(wchar_t) * (wcslen(text) + 1)); clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(wchar_t) * (len + 1));
buffer = (wchar_t*)GlobalLock(clipbuffer); buffer = (wchar_t*)GlobalLock(clipbuffer);
wcscpy(buffer, text); wcscpy(buffer, text);
...@@ -86,7 +87,12 @@ void COSOperator::copyToClipboard(const c16* text) const ...@@ -86,7 +87,12 @@ 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 )
IrrDeviceLinux->copyToClipboard(text); {
char ctext[len*2 + 1];
size_t lenNew = wcstombs(ctext, text, len*2);
ctext[lenNew] = 0;
IrrDeviceLinux->copyToClipboard(ctext);
}
#else #else
#endif #endif
...@@ -116,7 +122,14 @@ const c16* COSOperator::getTextFromClipboard() const ...@@ -116,7 +122,14 @@ const c16* COSOperator::getTextFromClipboard() const
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux ) if ( IrrDeviceLinux )
return IrrDeviceLinux->getTextFromClipboard(); {
const c8 * p = IrrDeviceLinux->getTextFromClipboard();
size_t lenOld = strlen(p);
wchar_t *ws = new wchar_t[lenOld + 1];
size_t lenNew = mbstowcs(ws,p,lenOld);
ws[lenNew] = 0;
return ws;
}
return 0; return 0;
#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