@@ -300,23 +300,29 @@ public Object getContents(Transfer transfer, int clipboards) {
300300
301301 long selection_data = 0 ;
302302 int [] typeIds = transfer .getTypeIds ();
303+ boolean textTransfer = transfer .getTypeNames ()[0 ].equals ("UTF8_STRING" );
304+ Object result = null ;
303305 for (int i = 0 ; i < typeIds .length ; i ++) {
304306 if ((clipboards & DND .CLIPBOARD ) != 0 ) {
305307 selection_data = gtk_clipboard_wait_for_contents (GTKCLIPBOARD , typeIds [i ]);
306308 }
307- if (selection_data != 0 ) break ;
308- if ((clipboards & DND .SELECTION_CLIPBOARD ) != 0 ) {
309+ if (selection_data == 0 && (clipboards & DND .SELECTION_CLIPBOARD ) != 0 ) {
309310 selection_data = gtk_clipboard_wait_for_contents (GTKPRIMARYCLIPBOARD , typeIds [i ]);
310311 }
312+ if (selection_data != 0 ) {
313+ TransferData tdata = new TransferData ();
314+ tdata .type = GTK3 .gtk_selection_data_get_data_type (selection_data );
315+ tdata .pValue = GTK3 .gtk_selection_data_get_data (selection_data );
316+ tdata .length = GTK3 .gtk_selection_data_get_length (selection_data );
317+ tdata .format = GTK3 .gtk_selection_data_get_format (selection_data );
318+ result = transfer .nativeToJava (tdata );
319+ GTK3 .gtk_selection_data_free (selection_data );
320+ selection_data = 0 ;
321+ if (result != null || !textTransfer ) {
322+ break ;
323+ }
324+ }
311325 }
312- if (selection_data == 0 ) return null ;
313- TransferData tdata = new TransferData ();
314- tdata .type = GTK3 .gtk_selection_data_get_data_type (selection_data );
315- tdata .pValue = GTK3 .gtk_selection_data_get_data (selection_data );
316- tdata .length = GTK3 .gtk_selection_data_get_length (selection_data );
317- tdata .format = GTK3 .gtk_selection_data_get_format (selection_data );
318- Object result = transfer .nativeToJava (tdata );
319- GTK3 .gtk_selection_data_free (selection_data );
320326 return result ;
321327}
322328
0 commit comments