clipboard fix
This commit is contained in:
parent
c133706890
commit
c864a2cb08
|
@ -57,8 +57,8 @@ namespace Platform
|
|||
/// Check if GL extension is supported
|
||||
bool isExtensionSupported(const char *ext);
|
||||
|
||||
const char *getTextFromClipboard();
|
||||
void copyToClipboard(const char *text);
|
||||
const char *getClipboardText();
|
||||
void setClipboardText(const char *text);
|
||||
|
||||
void hideMouseCursor();
|
||||
void showMouseCursor();
|
||||
|
|
|
@ -244,6 +244,29 @@ bool Platform::isExtensionSupported(const char *ext)
|
|||
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()
|
||||
{
|
||||
ShowCursor(false);
|
||||
|
|
|
@ -601,7 +601,7 @@ bool Platform::isExtensionSupported(const char *ext)
|
|||
return false;
|
||||
}
|
||||
|
||||
const char *Platform::getTextFromClipboard()
|
||||
const char *Platform::getClipboardText()
|
||||
{
|
||||
Window ownerWindow = XGetSelectionOwner(x11.display, x11.atomClipboard);
|
||||
if(ownerWindow == x11.window)
|
||||
|
@ -650,7 +650,7 @@ const char *Platform::getTextFromClipboard()
|
|||
return clipboard.c_str();
|
||||
}
|
||||
|
||||
void Platform::copyToClipboard(const char *text)
|
||||
void Platform::setClipboardText(const char *text)
|
||||
{
|
||||
x11.clipboardText = text;
|
||||
XSetSelectionOwner(x11.display, x11.atomClipboard, x11.window, CurrentTime);
|
||||
|
|
Loading…
Reference in New Issue