FIRE-31976 - Linux/X11: fix pasting text being cropped to 64k bytes

master
Zi Ree 2022-10-05 00:10:45 +02:00
parent 9fb09ce231
commit 48282c7fea
1 changed files with 17 additions and 4 deletions

View File

@ -130,7 +130,8 @@ namespace
Atom XA_CLIPBOARD;
Atom XA_TARGETS;
Atom PVT_PASTE_BUFFER;
long const MAX_PASTE_BUFFER_SIZE = 16383;
// Unused in the current clipboard implementation -Zi
// long const MAX_PASTE_BUFFER_SIZE = 16383;
void filterSelectionRequest( XEvent aEvent )
{
@ -277,11 +278,23 @@ bool LLWindowSDL::getSelectionText( Atom aSelection, Atom aType, LLWString &text
maybe_lock_display();
Atom type;
int format{};
unsigned long len{},remaining {};
int format {};
unsigned long len {}, size {};
unsigned char* data = nullptr;
// get type and size of the clipboard contents first
XGetWindowProperty( mSDL_Display, mSDL_XWindowID,
PVT_PASTE_BUFFER, 0, 0, False,
AnyPropertyType, &type, &format, &len,
&size, &data);
XFree(data);
// now get the real data, we don't really have a size limit here, but we need
// to tell the X11 clipboard how much space we have, which happens to be exactly
// the size of the current clipboard contents
unsigned long remaining {};
int res = XGetWindowProperty(mSDL_Display, mSDL_XWindowID,
PVT_PASTE_BUFFER, 0, MAX_PASTE_BUFFER_SIZE, False,
PVT_PASTE_BUFFER, 0, size, False,
AnyPropertyType, &type, &format, &len,
&remaining, &data);
if (data && len)