-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wayland qt kde clipboard fix #863
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
*******************************************************************************/ | ||
package org.eclipse.swt.dnd; | ||
|
||
import java.nio.charset.*; | ||
|
||
import org.eclipse.swt.internal.*; | ||
import org.eclipse.swt.internal.gtk.*; | ||
|
||
|
@@ -42,9 +44,11 @@ public class TextTransfer extends ByteArrayTransfer { | |
private static final String COMPOUND_TEXT = "COMPOUND_TEXT"; //$NON-NLS-1$ | ||
private static final String UTF8_STRING = "UTF8_STRING"; //$NON-NLS-1$ | ||
private static final String STRING = "STRING"; //$NON-NLS-1$ | ||
private static final String TEXT_PLAIN_UTF8 = "text/plain;charset=utf-8"; //RFC-1341 | ||
private static final int COMPOUND_TEXT_ID = GTK.GTK4 ? 0 : registerType(COMPOUND_TEXT); | ||
private static final int UTF8_STRING_ID = GTK.GTK4 ? 0 : registerType(UTF8_STRING); | ||
private static final int STRING_ID = GTK.GTK4 ? 0 : registerType(STRING); | ||
private static final int TEXT_PLAIN_UTF8_ID = GTK.GTK4 ? 0 : registerType(TEXT_PLAIN_UTF8); | ||
|
||
private TextTransfer() {} | ||
|
||
|
@@ -107,8 +111,29 @@ public void javaToNative (Object object, TransferData transferData) { | |
transferData.pValue = string_target; | ||
transferData.result = 1; | ||
} | ||
if (transferData.type == TEXT_PLAIN_UTF8_ID) { | ||
// Convert the text into RFC-1341 format | ||
byte[] rfc1341Data = encodeTextAsRFC1341(string); | ||
transferData.format = 8; // Format for UTF-8 | ||
transferData.length = rfc1341Data.length; | ||
transferData.pValue = OS.g_malloc(rfc1341Data.length); | ||
if (transferData.pValue != 0) { | ||
C.memmove(transferData.pValue, rfc1341Data, rfc1341Data.length); | ||
transferData.result = 1; | ||
} | ||
} | ||
} | ||
|
||
// New method to encode text as RFC-1341 | ||
private byte[] encodeTextAsRFC1341(String text) { | ||
// Implement encoding logic here, e.g., adding MIME headers and encoding text | ||
// This is a simplified example; actual encoding depends on RFC-1341 standards | ||
// String rfc1341Text = "Content-Type: " + TEXTPLAINUTF8 + "\r\n\r\n" + text; | ||
String rfc1341Text = text; | ||
return rfc1341Text.getBytes(StandardCharsets.UTF_8); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see #875 (comment) I have my doubts what this method does. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the method should be named |
||
} | ||
|
||
|
||
/** | ||
* This implementation of <code>nativeToJava</code> converts a platform specific | ||
* representation of plain text to a java <code>String</code>. | ||
|
@@ -145,7 +170,7 @@ protected int[] getTypeIds() { | |
if(GTK.GTK4) { | ||
return new int[] {(int) OS.G_TYPE_STRING()}; | ||
} | ||
return new int[] {UTF8_STRING_ID, STRING_ID}; | ||
return new int[] {UTF8_STRING_ID, STRING_ID, TEXT_PLAIN_UTF8_ID}; | ||
} | ||
|
||
@Override | ||
|
@@ -157,7 +182,7 @@ protected String[] getTypeNames() { | |
return new String[] {"text/plain", STRING}; | ||
} | ||
|
||
return new String[] {UTF8_STRING, STRING}; | ||
return new String[] {UTF8_STRING, STRING, TEXT_PLAIN_UTF8}; | ||
} | ||
|
||
boolean checkText(Object object) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is non-functional. Why it was added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 lines where needed to get Eclipse to present text/plain;uft-8 data to the clipboard.
Otherwise the javaToNative function in Texttreanfer.java was'nt called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I confirmed by the eclipse debugger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong - have you asked why does the rest of clipboard data works but only new type would need that? I would assume you've missed something else.
The javaToNative is called from
org.eclipse.swt.dnd.ClipboardProxy.getFunc(long, long, long, long)