Skip to content

Fail to get text from the clipboard when text is Latin-1 encoded but transfer data type is UTF8_STRING #2149

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,29 @@ public Object getContents(Transfer transfer, int clipboards) {

long selection_data = 0;
int[] typeIds = transfer.getTypeIds();
boolean textTransfer = transfer.getTypeNames()[0].equals("UTF8_STRING");
Object result = null;
for (int i = 0; i < typeIds.length; i++) {
if ((clipboards & DND.CLIPBOARD) != 0) {
selection_data = gtk_clipboard_wait_for_contents(GTKCLIPBOARD, typeIds[i]);
}
if (selection_data != 0) break;
if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
if (selection_data == 0 && (clipboards & DND.SELECTION_CLIPBOARD) != 0) {
selection_data = gtk_clipboard_wait_for_contents(GTKPRIMARYCLIPBOARD, typeIds[i]);
}
if (selection_data != 0) {
TransferData tdata = new TransferData();
tdata.type = GTK3.gtk_selection_data_get_data_type(selection_data);
tdata.pValue = GTK3.gtk_selection_data_get_data(selection_data);
tdata.length = GTK3.gtk_selection_data_get_length(selection_data);
tdata.format = GTK3.gtk_selection_data_get_format(selection_data);
result = transfer.nativeToJava(tdata);
GTK3.gtk_selection_data_free(selection_data);
selection_data = 0;
if (result != null || !textTransfer) {
break;
}
}
}
if (selection_data == 0) return null;
TransferData tdata = new TransferData();
tdata.type = GTK3.gtk_selection_data_get_data_type(selection_data);
tdata.pValue = GTK3.gtk_selection_data_get_data(selection_data);
tdata.length = GTK3.gtk_selection_data_get_length(selection_data);
tdata.format = GTK3.gtk_selection_data_get_format(selection_data);
Object result = transfer.nativeToJava(tdata);
GTK3.gtk_selection_data_free(selection_data);
return result;
}

Expand Down
Loading