Fix copy and paste of unicode characters
This commit is contained in:
parent
5879933a23
commit
e6e302af1c
@ -73,7 +73,6 @@ namespace
|
|||||||
Atom X_ATOM_CLIPBOARD;
|
Atom X_ATOM_CLIPBOARD;
|
||||||
Atom X_ATOM_TARGETS;
|
Atom X_ATOM_TARGETS;
|
||||||
Atom X_ATOM_UTF8_STRING;
|
Atom X_ATOM_UTF8_STRING;
|
||||||
Atom X_ATOM_TEXT;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
@ -1721,7 +1720,7 @@ bool CIrrDeviceLinux::run()
|
|||||||
{
|
{
|
||||||
XEvent respond;
|
XEvent respond;
|
||||||
XSelectionRequestEvent *req = &(event.xselectionrequest);
|
XSelectionRequestEvent *req = &(event.xselectionrequest);
|
||||||
if ( req->target == XA_STRING)
|
if ( req->target == X_ATOM_UTF8_STRING)
|
||||||
{
|
{
|
||||||
XChangeProperty (display,
|
XChangeProperty (display,
|
||||||
req->requestor,
|
req->requestor,
|
||||||
@ -1734,14 +1733,13 @@ bool CIrrDeviceLinux::run()
|
|||||||
}
|
}
|
||||||
else if ( req->target == X_ATOM_TARGETS )
|
else if ( req->target == X_ATOM_TARGETS )
|
||||||
{
|
{
|
||||||
long data[2];
|
long data[1];
|
||||||
|
|
||||||
data[0] = X_ATOM_TEXT;
|
data[0] = X_ATOM_UTF8_STRING;
|
||||||
data[1] = XA_STRING;
|
|
||||||
|
|
||||||
XChangeProperty (display, req->requestor,
|
XChangeProperty (display, req->requestor,
|
||||||
req->property, req->target,
|
req->property, XA_ATOM,
|
||||||
8, PropModeReplace,
|
32, PropModeReplace,
|
||||||
(unsigned char *) &data,
|
(unsigned char *) &data,
|
||||||
sizeof (data));
|
sizeof (data));
|
||||||
respond.xselection.property = req->property;
|
respond.xselection.property = req->property;
|
||||||
@ -2583,7 +2581,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||||||
os::Printer::log("Couldn't access X clipboard", ELL_WARNING);
|
os::Printer::log("Couldn't access X clipboard", ELL_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window ownerWindow = XGetSelectionOwner(display, X_ATOM_CLIPBOARD);
|
Window ownerWindow = XGetSelectionOwner(display, X_ATOM_CLIPBOARD);
|
||||||
if (ownerWindow == window)
|
if (ownerWindow == window)
|
||||||
{
|
{
|
||||||
@ -2596,8 +2594,8 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Atom selection = XInternAtom(display, "IRR_SELECTION", False);
|
Atom selection = XInternAtom(display, "IRR_SELECTION", False);
|
||||||
XConvertSelection(display, X_ATOM_CLIPBOARD, XA_STRING, selection, window, CurrentTime);
|
XConvertSelection(display, X_ATOM_CLIPBOARD, X_ATOM_UTF8_STRING, selection, window, CurrentTime);
|
||||||
|
|
||||||
const int SELECTION_RETRIES = 500;
|
const int SELECTION_RETRIES = 500;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < SELECTION_RETRIES; i++)
|
for (i = 0; i < SELECTION_RETRIES; i++)
|
||||||
@ -2610,13 +2608,13 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||||||
|
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == SELECTION_RETRIES)
|
if (i == SELECTION_RETRIES)
|
||||||
{
|
{
|
||||||
os::Printer::log("Timed out waiting for SelectionNotify event", ELL_WARNING);
|
os::Printer::log("Timed out waiting for SelectionNotify event", ELL_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atom type;
|
Atom type;
|
||||||
int format;
|
int format;
|
||||||
unsigned long numItems, dummy;
|
unsigned long numItems, dummy;
|
||||||
@ -2628,7 +2626,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
|
|||||||
|
|
||||||
if (result == Success)
|
if (result == Success)
|
||||||
Clipboard = (irr::c8*)data;
|
Clipboard = (irr::c8*)data;
|
||||||
|
|
||||||
XFree (data);
|
XFree (data);
|
||||||
return Clipboard.c_str();
|
return Clipboard.c_str();
|
||||||
#else
|
#else
|
||||||
@ -2688,7 +2686,6 @@ void CIrrDeviceLinux::initXAtoms()
|
|||||||
X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False);
|
X_ATOM_CLIPBOARD = XInternAtom(display, "CLIPBOARD", False);
|
||||||
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
|
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
|
||||||
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
|
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
|
||||||
X_ATOM_TEXT = XInternAtom (display, "TEXT", False);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user