mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-8066 Wayland: clipboard size is limited to 65000 symbols
This commit is contained in:
@@ -36,6 +36,8 @@ import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -223,15 +225,24 @@ public final class WLClipboard extends SunClipboard {
|
||||
}
|
||||
|
||||
if (flavor != null) {
|
||||
byte[] bytes = wlDataTransferer.translateTransferable(contents, flavor, targetFormat);
|
||||
if (bytes == null) return;
|
||||
FileDescriptor javaDestFD = new FileDescriptor();
|
||||
jdk.internal.access.SharedSecrets.getJavaIOFileDescriptorAccess().set(javaDestFD, destFD);
|
||||
|
||||
try (var out = new FileOutputStream(javaDestFD)) {
|
||||
byte[] bytes = wlDataTransferer.translateTransferable(contents, flavor, targetFormat);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("Clipboard: about to write " + (bytes != null ? bytes.length : 0) + " bytes to " + out);
|
||||
log.fine("Clipboard: about to write " + bytes.length + " bytes to " + out);
|
||||
}
|
||||
|
||||
FileChannel ch = out.getChannel();
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||
// Need to write with retries because when a pipe is in the non-blocking mode
|
||||
// writing more than its capacity (usually 16 pages or 64K) fails with EAGAIN.
|
||||
// Since we receive destFD from the Wayland sever, we can't assume it
|
||||
// to always be in the blocking mode.
|
||||
while (buffer.hasRemaining()) {
|
||||
ch.write(buffer);
|
||||
}
|
||||
out.write(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ Java_sun_awt_wl_WLClipboard_requestDataInFormat(
|
||||
const char * mimeType = (*env)->GetStringUTFChars(env, mimeTypeJava, NULL);
|
||||
if (mimeType) {
|
||||
int fds[2];
|
||||
int rc = pipe(fds);
|
||||
int rc = pipe2(fds, O_CLOEXEC);
|
||||
if (rc == 0) {
|
||||
if (isPrimary) {
|
||||
struct zwp_primary_selection_offer_v1 * offer = jlong_to_ptr(clipboardNativePtr);
|
||||
|
||||
Reference in New Issue
Block a user