mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Linux: Avoid sending the string terminator to the X11 clipboard
This commit is contained in:
parent
ea5dae4ab6
commit
3366ad4ed4
1 changed files with 13 additions and 11 deletions
|
|
@ -1351,20 +1351,22 @@ namespace ClipboardHelpers
|
|||
{
|
||||
auto localContent = XWindowSystem::getInstance()->getLocalClipboardContent();
|
||||
|
||||
// translate to utf8
|
||||
numDataItems = localContent.getNumBytesAsUTF8() + 1;
|
||||
data.calloc (numDataItems);
|
||||
localContent.copyToUTF8 (data, numDataItems);
|
||||
propertyFormat = 8; // bits/item
|
||||
// Translate to utf8
|
||||
numDataItems = localContent.getNumBytesAsUTF8();
|
||||
auto numBytesRequiredToStore = numDataItems + 1;
|
||||
data.calloc (numBytesRequiredToStore);
|
||||
localContent.copyToUTF8 (data, numBytesRequiredToStore);
|
||||
propertyFormat = 8; // bits per item
|
||||
}
|
||||
else if (evt.target == atoms.targets)
|
||||
{
|
||||
// another application wants to know what we are able to send
|
||||
// Another application wants to know what we are able to send
|
||||
|
||||
numDataItems = 2;
|
||||
constexpr size_t atomSize = sizeof (Atom);
|
||||
static_assert (atomSize == 8, "Atoms are 32-bit");
|
||||
propertyFormat = atomSize * 4;
|
||||
data.calloc (numDataItems * atomSize);
|
||||
data.calloc (numDataItems * sizeof (Atom));
|
||||
|
||||
// Atoms are flagged as 32-bit irrespective of sizeof (Atom)
|
||||
propertyFormat = 32;
|
||||
|
||||
auto* dataAtoms = unalignedPointerCast<Atom*> (data.getData());
|
||||
|
||||
|
|
@ -1388,7 +1390,7 @@ namespace ClipboardHelpers
|
|||
{
|
||||
X11Symbols::getInstance()->xChangeProperty (evt.display, evt.requestor,
|
||||
evt.property, evt.target,
|
||||
propertyFormat /* 8 or 32 */, PropModeReplace,
|
||||
propertyFormat, PropModeReplace,
|
||||
reinterpret_cast<const unsigned char*> (data.getData()), (int) numDataItems);
|
||||
reply.property = evt.property; // " == success"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue