clipboard fix

This commit is contained in:
Henrique Santiago 2011-03-20 18:08:57 -03:00
parent c133706890
commit c864a2cb08
3 changed files with 27 additions and 4 deletions

View File

@ -57,8 +57,8 @@ namespace Platform
/// Check if GL extension is supported /// Check if GL extension is supported
bool isExtensionSupported(const char *ext); bool isExtensionSupported(const char *ext);
const char *getTextFromClipboard(); const char *getClipboardText();
void copyToClipboard(const char *text); void setClipboardText(const char *text);
void hideMouseCursor(); void hideMouseCursor();
void showMouseCursor(); void showMouseCursor();

View File

@ -244,6 +244,29 @@ bool Platform::isExtensionSupported(const char *ext)
return false; return false;
} }
const char *Platform::getClipboardText()
{
const char *text = "";
if(OpenClipboard(NULL)) {
text = (const char*)GetClipboardData(CF_TEXT);
CloseClipboard();
}
return text;
}
void Platform::setClipboardText(const char *text)
{
int textLenght = strlen(text);
HANDLE hData = new HANDLE[textLenght + 1];
memcpy(hData, text, textLenght + 1);
if(OpenClipboard(NULL)) {
EmptyClipboard();
SetClipboardData(CF_TEXT, hData);
CloseClipboard();
}
}
void Platform::hideMouseCursor() void Platform::hideMouseCursor()
{ {
ShowCursor(false); ShowCursor(false);

View File

@ -601,7 +601,7 @@ bool Platform::isExtensionSupported(const char *ext)
return false; return false;
} }
const char *Platform::getTextFromClipboard() const char *Platform::getClipboardText()
{ {
Window ownerWindow = XGetSelectionOwner(x11.display, x11.atomClipboard); Window ownerWindow = XGetSelectionOwner(x11.display, x11.atomClipboard);
if(ownerWindow == x11.window) if(ownerWindow == x11.window)
@ -650,7 +650,7 @@ const char *Platform::getTextFromClipboard()
return clipboard.c_str(); return clipboard.c_str();
} }
void Platform::copyToClipboard(const char *text) void Platform::setClipboardText(const char *text)
{ {
x11.clipboardText = text; x11.clipboardText = text;
XSetSelectionOwner(x11.display, x11.atomClipboard, x11.window, CurrentTime); XSetSelectionOwner(x11.display, x11.atomClipboard, x11.window, CurrentTime);